From 6fa55234f744f3e56024d36dcf0cab4df2d8d878 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:30:59 +0000 Subject: Add apk --- bash/aliases.bash | 1 + 1 file changed, 1 insertion(+) (limited to 'bash') diff --git a/bash/aliases.bash b/bash/aliases.bash index f2d6776..eba0673 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash @@ -8,6 +8,7 @@ sudo_cmds=( mount umount visudo + apk ) for cmd in "${sudo_cmds[@]}"; do alias $cmd="sudo $cmd" -- cgit 1.4.1-21-gabe81 From 4484a9d9d9975e78e5b2f68e0226739a4169cbe4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:31:03 +0000 Subject: Remove color from ls --- bash/aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash') diff --git a/bash/aliases.bash b/bash/aliases.bash index eba0673..89c33ce 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash @@ -15,7 +15,7 @@ for cmd in "${sudo_cmds[@]}"; do done # LS -alias ls='ls -F --color=auto' +alias ls='ls -F --color=never' alias ll='ls -l' # tree alias tree='tree -F' -- cgit 1.4.1-21-gabe81 From 8b352cf25190e877a00343153fd74a3c59d93066 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:31:16 +0000 Subject: Move please to functions.bash --- bash/functions.bash | 15 +++++++++++++++ bash/please.bash | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 bash/please.bash (limited to 'bash') diff --git a/bash/functions.bash b/bash/functions.bash index 058e0f9..5e99a82 100644 --- a/bash/functions.bash +++ b/bash/functions.bash @@ -1,3 +1,5 @@ +# Functions + memq() { # memq ITEM ARRAY # Test whether an ITEM is a member of ARRAY. # Pass ARRAY as ${ARRAY[@]}. @@ -9,3 +11,16 @@ memq() { # memq ITEM ARRAY done return 1 } + +please() { # please [COMMAND...] + # if run without arguments, run the last command with 'sudo' (aka sudo !!) + # if run WITH arguments, alias as sudo + history -d -1 + if [ -z "$1" ]; then + #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q') + set -- $(fc -lnr | sed 1q) + fi + echo >&2 sudo "$@" + history -s sudo "$@" + "${DEBUG:-false}" || sudo "$@" +} diff --git a/bash/please.bash b/bash/please.bash deleted file mode 100644 index 179ed17..0000000 --- a/bash/please.bash +++ /dev/null @@ -1,14 +0,0 @@ -# PLEASE -# if run without arguments, run the last command with 'sudo' (aka sudo !!) -# if run WITH arguments, alias as sudo - -please() { - history -d -1 - if [ -z "$1" ]; then - #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q') - set -- $(fc -lnr | sed 1q) - fi - echo >&2 sudo "$@" - history -s sudo "$@" - "${DEBUG:-false}" || sudo "$@" -} -- cgit 1.4.1-21-gabe81 From 9daa93094de07cd382d59affabd91cb1681d8375 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:32:13 +0000 Subject: Accomodate more types of completion setups --- bash/completion.bash | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'bash') diff --git a/bash/completion.bash b/bash/completion.bash index 50e8f35..764463e 100644 --- a/bash/completion.bash +++ b/bash/completion.bash @@ -1,7 +1,15 @@ -# source completions +# Completions.bash +# Source bash completion libraries -. /etc/bash_completion +POSSIBLE_COMPLETION_FILES=( + /etc/bash_completion # Debian + /etc/profile.d/bash_completion.sh # Alpine + # I'm sure there are many more +) -# for file in /etc/bash_completion.d/*; do -# [ -r "$file" ] && source "$file" -# done +for candidate in "${POSSIBLE_COMPLETION_FILES[@]}"; do + if [[ -r "$candidate" ]]; then + source "$candidate" + break # XXX: Do I want this? + fi +done -- cgit 1.4.1-21-gabe81 From 7f435c1a60ddcdbd5459c04aace1bd021610660e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:36:45 +0000 Subject: Change prompt --- bash/prompt.bash | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'bash') diff --git a/bash/prompt.bash b/bash/prompt.bash index df30c82..02d9c98 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash @@ -4,22 +4,25 @@ PS1= # user, host, and cwd PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') -PS1+='\[\e[36m\]\u@\h \w' +PS1+='\[\e[34m\]# \u@\h \w' # git bit # see https://unix.stackexchange.com/questions/278206 possible_git_prompt_locations=( - /usr/share/git/git-prompt.sh # Arch, etc. (default?) - /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... - /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? + /usr/share/git/git-prompt.sh # Arch, etc. (default?) + /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... + /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? + # I have yet to find Alpine's git prompt location. ) for file in "${possible_git_prompt_locations[@]}"; do - if [[ -f "$file" ]]; then - source "$file" && - PS1+='\[\e[35m\]$(__git_ps1)' - break - fi + if [[ -f "$file" ]]; then + source "$file" && + PS1+='\[\e[35m\]$(__git_ps1)' + break + else + true + fi done # newline @@ -27,9 +30,9 @@ PS1+='\[\e[0m\]\n' # exit code (only if error) __prompt_exit_code() { - local ec=$? - (( $ec > 0 )) && - printf "$ec" + local ec=$? + (( $ec > 0 )) && + printf "$ec" } PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' -- cgit 1.4.1-21-gabe81 From dcb05f00e1ad6083d6a9aa0590440b5b9ef37ec1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 13 Mar 2022 05:36:53 +0000 Subject: Whitespace and formatting --- bash/bashrc | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'bash') diff --git a/bash/bashrc b/bash/bashrc index 854fe7e..e167fee 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -14,28 +14,41 @@ BASH_SOURCE_LAST=( for f in "${BASH_SOURCE_FIRST[@]}"; do file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" - [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" + if [[ -r "$file" ]]; then + # echo >&2 "Sourcing '$file'" + source "$file" + else + : + # echo >&2 "No '$file' found" + fi done for file in "$XDG_CONFIG_HOME"/bash/*.bash; do file_base="${file##*/}" - memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}" && { + if memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}"; then # echo >&2 "'$file' in BASH_SOURCE_FIRST, skipping" continue - } - memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}" && { + elif memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}"; then # echo >&2 "'$file' in BASH_SOURCE_LAST, skipping" continue - } - [[ -r "$file" ]] && { + elif [[ -r "$file" ]]; then # echo >&2 "Sourcing '$file'" source "$file" - } + else + : + # echo >&2 "No '$file' found" + fi unset file_base done for f in "${BASH_SOURCE_LAST[@]}"; do file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" - [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" - true + if [[ -r "$file" ]]; then + source "$file" + else + : + #echo >&2 "No '$file' found" + fi done + +true -- cgit 1.4.1-21-gabe81 From 03bc179ce8133d703bc9734666603a5714bfe028 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 Apr 2022 12:38:44 -0500 Subject: Remove dependency on tput --- bash/man.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bash') diff --git a/bash/man.bash b/bash/man.bash index 4927952..5a28066 100644 --- a/bash/man.bash +++ b/bash/man.bash @@ -3,7 +3,7 @@ export MANWIDTH=80 # on smaller terminals, use their width # (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width) man() { - local width=$(tput cols) - [ $width -gt $MANWIDTH ] && width=$MANWIDTH - env MANWIDTH=$width man "$@" + local width=$COLUMNS # bashism! + [ $width -gt $MANWIDTH ] && width=$MANWIDTH + env MANWIDTH=$width man "$@" } -- cgit 1.4.1-21-gabe81 From ac5ddf2771b1e96022bd5fc98777aabaf0bd308c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 Apr 2022 12:38:52 -0500 Subject: Remove apk from sudo aliases --- bash/aliases.bash | 1 - 1 file changed, 1 deletion(-) (limited to 'bash') diff --git a/bash/aliases.bash b/bash/aliases.bash index 89c33ce..59e76d3 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash @@ -8,7 +8,6 @@ sudo_cmds=( mount umount visudo - apk ) for cmd in "${sudo_cmds[@]}"; do alias $cmd="sudo $cmd" -- cgit 1.4.1-21-gabe81