diff options
Diffstat (limited to 'bash')
-rw-r--r-- | bash/aliases.bash | 26 | ||||
-rw-r--r-- | bash/blesh.bash.disable | 1 | ||||
-rw-r--r-- | bash/dircolors.bash | 1 | ||||
-rw-r--r-- | bash/functions.bash | 11 | ||||
-rw-r--r-- | bash/guix.bash | 3 | ||||
-rw-r--r-- | bash/history.bash | 35 | ||||
-rw-r--r-- | bash/man.bash | 9 | ||||
-rw-r--r-- | bash/please.bash | 14 | ||||
-rw-r--r-- | bash/prompt.bash | 25 |
9 files changed, 125 insertions, 0 deletions
diff --git a/bash/aliases.bash b/bash/aliases.bash new file mode 100644 index 0000000..f2d6776 --- /dev/null +++ b/bash/aliases.bash | |||
@@ -0,0 +1,26 @@ | |||
1 | # Bash aliases | ||
2 | |||
3 | # sudo | ||
4 | sudo_cmds=( | ||
5 | shutdown | ||
6 | reboot | ||
7 | halt | ||
8 | mount | ||
9 | umount | ||
10 | visudo | ||
11 | ) | ||
12 | for cmd in "${sudo_cmds[@]}"; do | ||
13 | alias $cmd="sudo $cmd" | ||
14 | done | ||
15 | |||
16 | # LS | ||
17 | alias ls='ls -F --color=auto' | ||
18 | alias ll='ls -l' | ||
19 | # tree | ||
20 | alias tree='tree -F' | ||
21 | |||
22 | # make locally | ||
23 | alias lake='make PREFIX=~/usr' | ||
24 | |||
25 | # bash meta | ||
26 | alias rebash='source ~/.bash_profile' | ||
diff --git a/bash/blesh.bash.disable b/bash/blesh.bash.disable new file mode 100644 index 0000000..9fc617b --- /dev/null +++ b/bash/blesh.bash.disable | |||
@@ -0,0 +1 @@ | |||
source "$XDG_DATA_HOME/blesh/ble.sh" | |||
diff --git a/bash/dircolors.bash b/bash/dircolors.bash new file mode 100644 index 0000000..597ee95 --- /dev/null +++ b/bash/dircolors.bash | |||
@@ -0,0 +1 @@ | |||
eval $(dircolors --sh "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors") | |||
diff --git a/bash/functions.bash b/bash/functions.bash new file mode 100644 index 0000000..058e0f9 --- /dev/null +++ b/bash/functions.bash | |||
@@ -0,0 +1,11 @@ | |||
1 | memq() { # memq ITEM ARRAY | ||
2 | # Test whether an ITEM is a member of ARRAY. | ||
3 | # Pass ARRAY as ${ARRAY[@]}. | ||
4 | local e needle="$1"; shift | ||
5 | for e; do | ||
6 | [[ "$e" == "$needle" ]] && { | ||
7 | return 0 | ||
8 | } | ||
9 | done | ||
10 | return 1 | ||
11 | } | ||
diff --git a/bash/guix.bash b/bash/guix.bash new file mode 100644 index 0000000..127afef --- /dev/null +++ b/bash/guix.bash | |||
@@ -0,0 +1,3 @@ | |||
1 | export GUIX_PROFILE="$HOME/.config/guix/current" | ||
2 | |||
3 | . "$GUIX_PROFILE/etc/profile" | ||
diff --git a/bash/history.bash b/bash/history.bash new file mode 100644 index 0000000..95edf9d --- /dev/null +++ b/bash/history.bash | |||
@@ -0,0 +1,35 @@ | |||
1 | # Bash history settings | ||
2 | # I don't export any variables in this file because history settings | ||
3 | # really only apply in an interactive session. | ||
4 | |||
5 | # XDG compliance | ||
6 | HISTFILE="$XDG_DATA_HOME/bash/history" | ||
7 | mkdir -p "$XDG_DATA_HOME/bash" | ||
8 | |||
9 | # Don't truncate history | ||
10 | HISTFILESIZE=-1 # numeric values less than zero => don't truncate | ||
11 | HISTSIZE=100000 # ideally, I wouldn't truncate at all, but after a while shell | ||
12 | # startup might be affected. | ||
13 | |||
14 | # Append the history to HISTFILE. | ||
15 | shopt -s histappend | ||
16 | |||
17 | # History editing with readline | ||
18 | shopt -s histreedit # allow re-editing of a failed history substitution | ||
19 | shopt -s histverify # verify a history expansion before running it | ||
20 | |||
21 | # Save command invocation time to HISTFILE, and format it thusly | ||
22 | HISTTIMEFORMAT="%F %T " | ||
23 | |||
24 | # Erase all duplicates before saving the current line | ||
25 | HISTCONTROL=erasedups | ||
26 | # Don't save some commands to history | ||
27 | # "'HISTIGNORE' subsumes the function of 'HISTCONTROL'. A pattern of | ||
28 | # '&' is identical to 'ignoredups', and a pattern of '[ ]*' is | ||
29 | # identical to 'ignorespace'." -- info (bash)Bash Variables | ||
30 | HISTIGNORE='&:[ ]*' | ||
31 | # Other commands to ignore | ||
32 | HISTIGNORE="$HISTIGNORE:ls:exit:cd" | ||
33 | |||
34 | # Automatically append to HISTFILE on every command | ||
35 | PROMPT_COMMAND="history -a; ${PROMPT_COMMAND:-:}" | ||
diff --git a/bash/man.bash b/bash/man.bash new file mode 100644 index 0000000..4927952 --- /dev/null +++ b/bash/man.bash | |||
@@ -0,0 +1,9 @@ | |||
1 | export MANWIDTH=80 | ||
2 | |||
3 | # on smaller terminals, use their width | ||
4 | # (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width) | ||
5 | man() { | ||
6 | local width=$(tput cols) | ||
7 | [ $width -gt $MANWIDTH ] && width=$MANWIDTH | ||
8 | env MANWIDTH=$width man "$@" | ||
9 | } | ||
diff --git a/bash/please.bash b/bash/please.bash new file mode 100644 index 0000000..179ed17 --- /dev/null +++ b/bash/please.bash | |||
@@ -0,0 +1,14 @@ | |||
1 | # PLEASE | ||
2 | # if run without arguments, run the last command with 'sudo' (aka sudo !!) | ||
3 | # if run WITH arguments, alias as sudo | ||
4 | |||
5 | please() { | ||
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 new file mode 100644 index 0000000..c61266b --- /dev/null +++ b/bash/prompt.bash | |||
@@ -0,0 +1,25 @@ | |||
1 | # bash prompt | ||
2 | |||
3 | PS1= | ||
4 | |||
5 | # user, host, and cwd | ||
6 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') | ||
7 | PS1+='\[\e[36m\]\u@\h \w' | ||
8 | |||
9 | # git bit | ||
10 | source /usr/share/git/git-prompt.sh && | ||
11 | PS1+='\[\e[35m\]$(__git_ps1)' | ||
12 | |||
13 | # newline | ||
14 | PS1+='\[\e[0m\]\n' | ||
15 | |||
16 | # exit code (only if error) | ||
17 | __prompt_exit_code() { | ||
18 | local ec=$? | ||
19 | (( $ec > 0 )) && | ||
20 | printf "$ec" | ||
21 | } | ||
22 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' | ||
23 | |||
24 | # delimiter | ||
25 | PS1+='; ' | ||