about summary refs log tree commit diff stats
path: root/bash
diff options
context:
space:
mode:
authorCase Duckworth2022-04-13 17:20:13 -0500
committerCase Duckworth2022-04-13 17:20:13 -0500
commit34d6372186b79a9b1004884152ec022fa43ef81d (patch)
tree6b3248a12d35c7aa06959fa5e226055756f32f8b /bash
parentEmacs stuff (diff)
parentRemove apk from sudo aliases (diff)
downloadetc-34d6372186b79a9b1004884152ec022fa43ef81d.tar.gz
etc-34d6372186b79a9b1004884152ec022fa43ef81d.zip
Merge branch 'main' of github.com:duckwork/etc
Diffstat (limited to 'bash')
-rw-r--r--bash/aliases.bash2
-rw-r--r--bash/bashrc31
-rw-r--r--bash/completion.bash18
-rw-r--r--bash/functions.bash15
-rw-r--r--bash/man.bash6
-rw-r--r--bash/please.bash14
-rw-r--r--bash/prompt.bash7
7 files changed, 58 insertions, 35 deletions
diff --git a/bash/aliases.bash b/bash/aliases.bash index 03361fa..7875574 100644 --- a/bash/aliases.bash +++ b/bash/aliases.bash
@@ -14,7 +14,7 @@ for cmd in "${sudo_cmds[@]}"; do
14done 14done
15 15
16# LS 16# LS
17alias ls='ls -F --color=auto' 17alias ls='ls -F --color=never'
18alias ll='ls -l' 18alias ll='ls -l'
19# tree 19# tree
20alias tree='tree -F' 20alias tree='tree -F'
diff --git a/bash/bashrc b/bash/bashrc index a1bfade..f9f17e7 100644 --- a/bash/bashrc +++ b/bash/bashrc
@@ -15,28 +15,41 @@ BASH_SOURCE_LAST=(
15 15
16for f in "${BASH_SOURCE_FIRST[@]}"; do 16for f in "${BASH_SOURCE_FIRST[@]}"; do
17 file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" 17 file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash"
18 [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" 18 if [[ -r "$file" ]]; then
19 # echo >&2 "Sourcing '$file'"
20 source "$file"
21 else
22 :
23 # echo >&2 "No '$file' found"
24 fi
19done 25done
20 26
21for file in "$XDG_CONFIG_HOME"/bash/*.bash; do 27for file in "$XDG_CONFIG_HOME"/bash/*.bash; do
22 file_base="${file##*/}" 28 file_base="${file##*/}"
23 memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}" && { 29 if memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}"; then
24 # echo >&2 "'$file' in BASH_SOURCE_FIRST, skipping" 30 # echo >&2 "'$file' in BASH_SOURCE_FIRST, skipping"
25 continue 31 continue
26 } 32 elif memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}"; then
27 memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}" && {
28 # echo >&2 "'$file' in BASH_SOURCE_LAST, skipping" 33 # echo >&2 "'$file' in BASH_SOURCE_LAST, skipping"
29 continue 34 continue
30 } 35 elif [[ -r "$file" ]]; then
31 [[ -r "$file" ]] && {
32 # echo >&2 "Sourcing '$file'" 36 # echo >&2 "Sourcing '$file'"
33 source "$file" 37 source "$file"
34 } 38 else
39 :
40 # echo >&2 "No '$file' found"
41 fi
35 unset file_base 42 unset file_base
36done 43done
37 44
38for f in "${BASH_SOURCE_LAST[@]}"; do 45for f in "${BASH_SOURCE_LAST[@]}"; do
39 file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" 46 file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash"
40 [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" 47 if [[ -r "$file" ]]; then
41 true 48 source "$file"
49 else
50 :
51 #echo >&2 "No '$file' found"
52 fi
42done 53done
54
55true
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 @@
1# source completions 1# Completions.bash
2# Source bash completion libraries
2 3
3. /etc/bash_completion 4POSSIBLE_COMPLETION_FILES=(
5 /etc/bash_completion # Debian
6 /etc/profile.d/bash_completion.sh # Alpine
7 # I'm sure there are many more
8)
4 9
5# for file in /etc/bash_completion.d/*; do 10for candidate in "${POSSIBLE_COMPLETION_FILES[@]}"; do
6# [ -r "$file" ] && source "$file" 11 if [[ -r "$candidate" ]]; then
7# done 12 source "$candidate"
13 break # XXX: Do I want this?
14 fi
15done
diff --git a/bash/functions.bash b/bash/functions.bash index cce92be..98872f2 100644 --- a/bash/functions.bash +++ b/bash/functions.bash
@@ -1,3 +1,5 @@
1# Functions
2
1memq() { # memq ITEM ARRAY 3memq() { # memq ITEM ARRAY
2 ## Test whether an ITEM is a member of ARRAY. 4 ## Test whether an ITEM is a member of ARRAY.
3 ## Pass ARRAY as ${ARRAY[@]}. 5 ## Pass ARRAY as ${ARRAY[@]}.
@@ -28,3 +30,16 @@ first_which() { # first_which COMMAND...
28 shift 30 shift
29 done 31 done
30} 32}
33
34please() { # please [COMMAND...]
35 # if run without arguments, run the last command with 'sudo' (aka sudo !!)
36 # if run WITH arguments, alias as sudo
37 history -d -1
38 if [ -z "$1" ]; then
39 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
40 set -- $(fc -lnr | sed 1q)
41 fi
42 echo >&2 sudo "$@"
43 history -s sudo "$@"
44 "${DEBUG:-false}" || sudo "$@"
45}
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
3# on smaller terminals, use their width 3# on smaller terminals, use their width
4# (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width) 4# (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width)
5man() { 5man() {
6 local width=$(tput cols) 6 local width=$COLUMNS # bashism!
7 [ $width -gt $MANWIDTH ] && width=$MANWIDTH 7 [ $width -gt $MANWIDTH ] && width=$MANWIDTH
8 env MANWIDTH=$width man "$@" 8 env MANWIDTH=$width man "$@"
9} 9}
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 @@
1# PLEASE
2# if run without arguments, run the last command with 'sudo' (aka sudo !!)
3# if run WITH arguments, alias as sudo
4
5please() {
6 history -d -1
7 if [ -z "$1" ]; then
8 #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
9 set -- $(fc -lnr | sed 1q)
10 fi
11 echo >&2 sudo "$@"
12 history -s sudo "$@"
13 "${DEBUG:-false}" || sudo "$@"
14}
diff --git a/bash/prompt.bash b/bash/prompt.bash index dfb84ca..f1bdd69 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash
@@ -9,9 +9,10 @@ PS1+='\[\e[0;46m\]\u@\h \w'
9# git bit 9# git bit
10# see https://unix.stackexchange.com/questions/278206 10# see https://unix.stackexchange.com/questions/278206
11possible_git_prompt_locations=( 11possible_git_prompt_locations=(
12 /usr/share/git/git-prompt.sh # Arch, etc. (default?) 12 /usr/share/git/git-prompt.sh # Arch, etc. (default?)
13 /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... 13 /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ...
14 /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? 14 /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ??
15 # I have yet to find Alpine's git prompt location.
15) 16)
16 17
17for file in "${possible_git_prompt_locations[@]}"; do 18for file in "${possible_git_prompt_locations[@]}"; do