Compare commits

...

9 Commits

Author SHA1 Message Date
anmiller
efa9a422ad Update vim-helm 2025-11-25 18:57:55 +00:00
anmiller
d67b07d275 Only source direnv if it hasn't already been sourced 2025-08-12 21:41:58 +00:00
anmiller
dda5fcc784 Update prompt manipulation with functions! 2025-08-12 21:41:41 +00:00
b66b03bc78 Fix nix installer 2025-05-23 14:05:57 +00:00
da7a244f95 Fix nix installer up 2025-05-20 18:45:04 +00:00
4a461eb974 More specifically identify if nix is installed 2025-05-20 18:03:39 +00:00
a6257ed7d1 Pass through shell environment variable 2025-05-12 23:24:15 -04:00
d487ade6f2 Add vim-helm for helm file detection 2025-05-01 18:46:29 +00:00
e24e8a1c49 Add prompt generation commands for git/kubernetes 2025-04-08 15:29:36 +00:00
6 changed files with 168 additions and 102 deletions

3
.gitmodules vendored
View File

@@ -61,3 +61,6 @@
[submodule "vim/.vim/nvim-bundle/zk-nvim"]
path = vim/.vim/nvim-bundle/zk-nvim
url = https://github.com/zk-org/zk-nvim.git
[submodule "vim/.vim/bundle/vim-helm"]
path = vim/.vim/bundle/vim-helm
url = https://github.com/towolf/vim-helm.git

View File

@@ -1,104 +1,7 @@
#{- ~/.bashrc -}#
#{- PROMPT -}#
if which tput &> /dev/null && tput bold &> /dev/null; then
red="\001$(tput bold)$(tput setaf 1)\002"
green="\001$(tput bold)$(tput setaf 2)\002"
yellow="\001$(tput bold)$(tput setaf 3)\002"
blue="\001$(tput bold)$(tput setaf 4)\002"
magenta="\001$(tput bold)$(tput setaf 5)\002"
cyan="\001$(tput bold)$(tput setaf 6)\002"
no_color="\001$(tput sgr0)\002"
else
red="\[\033[1;31m\]"
green="\[\033[1;32m\]"
yellow="\[\033[1;33m\]"
blue="\[\033[1;34m\]"
magenta="\[\033[1;35m\]"
cyan="\[\033[1;36m\]"
no_color="\[\033[0m\]"
fi
export PS1="${green}"'\$'"${no_color} "
export DIRENV_PS1="${red}"'\$'"${no_color} "
export NIX_SHELL_PS1="${blue}"'λ'"${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${CONTAINER_ID}" != "" ] || [ "${SSH_TTY}" != "" ]; then
if [ "${CONTAINER_ID}" ]; then
OLD_HOSTNAME="${HOSTNAME}"
HOSTNAME="${CONTAINER_ID}"
fi
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
NIX_SHELL_PS1="${NIX_SHELL_PS1}${green}${HOSTNAME} ${NIX_SHELL_PS1}"
if [ "${CONTAINER_ID}" ]; then
PS1="${PS1}${magenta}${HOSTNAME} ${PS1}"
else
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
fi
if [ "${CONTAINER_ID}" ]; then
HOSTNAME="${OLD_HOSTNAME}"
fi
fi
export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then
update_prompt() {
if [ -n "${IN_NIX_SHELL}" ]; then
PS1=${NIX_SHELL_PS1}
elif direnv status | grep -iEq 'RC allowed (true|0)'; then
PS1=${DIRENV_PS1}
else
PS1=${ORIG_PS1}
fi
}
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
fi
# Continuation Prompt: "> " in cyan
export PS2="${cyan}>${no_color} "
# Debugging Prompt: "# " in blue
export PS4="${blue}#${no_color} "
#{- HISTORY -}#
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
# PROMPT_COMMAND="echo hist1; history; history -n; echo hist2; history; history -w; echo hist3; history; history -c; echo hist4; history; history -r; echo hist5; history; $PROMPT_COMMAND"
export HISTFILE="$HOME/.history/bash"
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL="erasedups:ignoreboth"
export HISTFILESIZE=-1
export HISTSIZE=-1
export PERSISTENT_HISTFILE="${HOME}/.history/bash_persistent_history"
log_bash_persistent_history()
{
local rc=$?
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
# Ensure file exists
if ! [ -w "$(dirname ${PERSISTENT_HISTFILE})" ]; then
mkdir -p $(dirname ${PERSISTENT_HISTFILE})
fi
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}"
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
PROMPT_COMMAND="log_bash_persistent_history; $PROMPT_COMMAND"
#{- SOURCING -}#
# Source profile, if it hasn't already been loaded
if [ -z "$__PROFILE_DONE" ]; then
. $HOME/.profile
@@ -133,6 +36,104 @@ if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then
. "$HOME/.private_functions"
fi
#{- PROMPT -}#
if which tput &> /dev/null && tput bold &> /dev/null; then
red="\001$(tput bold)$(tput setaf 1)\002"
green="\001$(tput bold)$(tput setaf 2)\002"
yellow="\001$(tput bold)$(tput setaf 3)\002"
blue="\001$(tput bold)$(tput setaf 4)\002"
magenta="\001$(tput bold)$(tput setaf 5)\002"
cyan="\001$(tput bold)$(tput setaf 6)\002"
no_color="\001$(tput sgr0)\002"
else
red="\[\033[1;31m\]"
green="\[\033[1;32m\]"
yellow="\[\033[1;33m\]"
blue="\[\033[1;34m\]"
magenta="\[\033[1;35m\]"
cyan="\[\033[1;36m\]"
no_color="\[\033[0m\]"
fi
export PS1="${green}"'\$'"${no_color} "
export DIRENV_PS1="${red}"'\$'"${no_color} "
export NIX_SHELL_PS1="${blue}"'λ'"${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${CONTAINER_ID}" != "" ] || [ "${SSH_TTY}" != "" ]; then
if [ "${CONTAINER_ID}" ]; then
OLD_HOSTNAME="${HOSTNAME}"
HOSTNAME="${CONTAINER_ID}"
fi
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
NIX_SHELL_PS1="${NIX_SHELL_PS1}${green}${HOSTNAME} ${NIX_SHELL_PS1}"
if [ "${CONTAINER_ID}" ]; then
PS1="${PS1}${magenta}${HOSTNAME} ${PS1}"
else
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
fi
if [ "${CONTAINER_ID}" ]; then
HOSTNAME="${OLD_HOSTNAME}"
fi
fi
export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then
update_prompt() {
if [ -n "${IN_NIX_SHELL}" ]; then
PS1=${NIX_SHELL_PS1}
elif direnv status | grep -iEq 'RC allowed (true|0)'; then
PS1=${DIRENV_PS1}
else
PS1=${ORIG_PS1}
fi
}
prompt_command_prepend update_prompt
fi
# Continuation Prompt: "> " in cyan
export PS2="${cyan}>${no_color} "
# Debugging Prompt: "# " in blue
export PS4="${blue}#${no_color} "
#{- HISTORY -}#
prompt_command_prepend "history -r"
prompt_command_prepend "history -c"
prompt_command_prepend "history -w"
prompt_command_prepend "history -n"
# PROMPT_COMMAND="echo hist1; history; history -n; echo hist2; history; history -w; echo hist3; history; history -c; echo hist4; history; history -r; echo hist5; history; $PROMPT_COMMAND"
export HISTFILE="$HOME/.history/bash"
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL="erasedups:ignoreboth"
export HISTFILESIZE=-1
export HISTSIZE=-1
export PERSISTENT_HISTFILE="${HOME}/.history/bash_persistent_history"
log_bash_persistent_history()
{
local rc=$?
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
# Ensure file exists
if ! [ -w "$(dirname ${PERSISTENT_HISTFILE})" ]; then
mkdir -p $(dirname ${PERSISTENT_HISTFILE})
fi
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}"
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
prompt_command_prepend "log_bash_persistent_history"
# Source bash completion, this file will then lazy load all other completions
source_completions() {
if [ -r "/usr/share/bash-completion/bash_completion" ]; then
@@ -158,8 +159,12 @@ preserve_xtrace_reset() {
fi
} 2>/dev/null
PROMPT_COMMAND="preserve_xtrace; $PROMPT_COMMAND preserve_xtrace_reset"
prompt_command_prepend preserve_xtrace
prompt_command_append preserve_xtrace_reset
if $(which direnv &> /dev/null); then
# Only if direnv isn't already defined in our prompt_command
if ! grep -q _direnv_hook <<< $PROMPT_COMMAND; then
eval "$(direnv hook bash)"
fi
fi

View File

@@ -18,6 +18,59 @@ maths()
cat_with_newline()
{
cat "$@" && echo
\cat "$@" && echo
}
alias cat="cat_with_newline"
k_prompt()
{
set -x
if [ -z ${KUBE_PROMPT+x} ]; then
export KUBE_PROMPT=1
else
unset KUBE_PROMPT
fi
set +x
}
kube_prompt()
{
set -x
if ! [ -z ${KUBE_PROMPT+x} ]; then
context=$(\cat ${KUBECONFIG} \
| grep "current-context: " \
| sed "s/current-context: //")
echo {$context}
fi
set +x
}
g_prompt()
{
if ! [ -z ${GIT_PROMPT+x} ]; then
export GIT_PROMPT=1
else
unset GIT_PROMPT
fi
}
git_prompt()
{
if ! [ -z ${GIT_PROMPT+x} ]; then
# Determine if we are in a git repository
if git rev-parse --is-inside-work-tree &> /dev/null; then
branch=$(git rev-parse --abbrev-ref HEAD)
echo [$branch]
fi
fi
}
prompt_command_append() {
arg=${1}
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}"${arg}"
}
prompt_command_prepend() {
arg=${1}
PROMPT_COMMAND="${arg}"${PROMPT_COMMAND:+"; $PROMPT_COMMAND"}
}

View File

@@ -7,8 +7,12 @@ set -e
set -x
# Abort installation if Nix is already installed
if [ -d /nix ]; then
if [ -d /nix/store ]; then
exit 0
elif [ -d /nix ] && ! [ -O /nix ]; then
# If we don't own /nix use sudo to chown it.
# If we can't sudo then nothing we do here will work so we just let this fail
sudo chown $UID /nix
fi
# Workaround to make a single user install work as root

View File

@@ -1,5 +1,5 @@
# Defaults to using bash as the shell
defshell bash
defshell $SHELL
# Extend scrollback buffer
defscrollback 100000
# Disable startup message