Compare commits

..
1 Commits
Author SHA1 Message Date
nixy e8fca12861 Prototype for trying out blesh 2025-10-12 17:54:04 -04:00
11 changed files with 61 additions and 46 deletions
+11 -29
View File
@@ -5,11 +5,6 @@ apply_dotfile() {
stow --adopt -S -t "${HOME}" "${directory_to_stow}" stow --adopt -S -t "${HOME}" "${directory_to_stow}"
} }
revert_dotfile() {
directory_to_stow="${1}"
stow -D -t "${HOME}" "${directory_to_stow}"
}
# Adopt will change the files in stow to match existing files. # Adopt will change the files in stow to match existing files.
# We don't want this, we just want to handle existing files gracefully. # We don't want this, we just want to handle existing files gracefully.
# We simply adopt all the files and then at the end restore our git repo to undo changes # We simply adopt all the files and then at the end restore our git repo to undo changes
@@ -17,35 +12,22 @@ restore_from_adoption() {
git restore . git restore .
} }
mode_command=${1:-apply} apply_dotfile bash
if [ "${mode_command}" != "apply" ] && [ "${mode_command}" != "revert" ]; then apply_dotfile sh
echo "$0: mode command ("'${1}'") must be apply or revert" 1>&2 apply_dotfile readline
exit 1 apply_dotfile screen
fi
operation() { apply_dotfile git
${mode_command}_dotfile ${1} apply_dotfile xdg
}
# Create .local/bin to prevent tree folding apply_dotfile vim
mkdir -p ~/.local/bin
operation bash apply_dotfile ruby
operation sh apply_dotfile python
operation readline
operation screen
operation git
operation xdg
operation vim
operation ruby
operation python
# Only if inside a coder instance # Only if inside a coder instance
if [ -n "${CODER}" ]; then if [ -n "${CODER}" ]; then
operation gnupg apply_dotfile gnupg
fi fi
# Check that SSH version is above 9.2 (where EnableEscapeCommandline was added) before conditionally adding # Check that SSH version is above 9.2 (where EnableEscapeCommandline was added) before conditionally adding
@@ -56,6 +38,6 @@ cat <<CONFIG > ssh/.ssh/extra.conf
EnableEscapeCommandline yes EnableEscapeCommandline yes
CONFIG CONFIG
fi fi
operation ssh apply_dotfile ssh
restore_from_adoption restore_from_adoption
+12 -5
View File
@@ -36,6 +36,11 @@ if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then
. "$HOME/.private_functions" . "$HOME/.private_functions"
fi fi
if blesh-available; then
# blesh-activate
:
fi
#{- PROMPT -}# #{- PROMPT -}#
if which tput &> /dev/null && tput bold &> /dev/null; then if which tput &> /dev/null && tput bold &> /dev/null; then
@@ -90,7 +95,7 @@ if which direnv &> /dev/null; then
PS1=${ORIG_PS1} PS1=${ORIG_PS1}
fi fi
} }
prompt_command_prepend update_prompt prompt_command_prepend "update_prompt"
fi fi
# Continuation Prompt: "> " in cyan # Continuation Prompt: "> " in cyan
@@ -100,11 +105,14 @@ export PS4="${blue}#${no_color} "
#{- HISTORY -}# #{- HISTORY -}#
if blesh-attached; then
bleopt history_share=1
else
prompt_command_prepend "history -r" prompt_command_prepend "history -r"
prompt_command_prepend "history -c" prompt_command_prepend "history -c"
prompt_command_prepend "history -w" prompt_command_prepend "history -w"
prompt_command_prepend "history -n" 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" fi
export HISTFILE="$HOME/.history/bash" export HISTFILE="$HOME/.history/bash"
export HISTTIMEFORMAT="%F %T " export HISTTIMEFORMAT="%F %T "
export HISTCONTROL="erasedups:ignoreboth" export HISTCONTROL="erasedups:ignoreboth"
@@ -133,7 +141,6 @@ log_bash_persistent_history()
prompt_command_prepend "log_bash_persistent_history" prompt_command_prepend "log_bash_persistent_history"
# Source bash completion, this file will then lazy load all other completions # Source bash completion, this file will then lazy load all other completions
source_completions() { source_completions() {
if [ -r "/usr/share/bash-completion/bash_completion" ]; then if [ -r "/usr/share/bash-completion/bash_completion" ]; then
@@ -159,8 +166,8 @@ preserve_xtrace_reset() {
fi fi
} 2>/dev/null } 2>/dev/null
prompt_command_prepend preserve_xtrace prompt_command_prepend "preserve_xtrace"
prompt_command_append preserve_xtrace_reset prompt_command_append "preserve_xtrace_reset"
if $(which direnv &> /dev/null); then if $(which direnv &> /dev/null); then
# Only if direnv isn't already defined in our prompt_command # Only if direnv isn't already defined in our prompt_command
+26
View File
@@ -74,3 +74,29 @@ prompt_command_prepend() {
arg=${1} arg=${1}
PROMPT_COMMAND="${arg}"${PROMPT_COMMAND:+"; $PROMPT_COMMAND"} PROMPT_COMMAND="${arg}"${PROMPT_COMMAND:+"; $PROMPT_COMMAND"}
} }
blesh-activate()
{
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
if [ -r $BLESH_PATH ]; then
[[ $- == *i* ]] && . $HOME/.nix-profile/share/blesh/ble.sh
[[ ! ${BLE_VERSION-} ]] || ble-attach
fi
}
blesh-available() {
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
if [ -r $BLESH_PATH ]; then
return 0
else
return 1
fi
}
blesh-attached () {
if [ -z ${BLE_VERSION:+x} ]; then
return 1
else
return 0
fi
}