about summary refs log tree commit diff stats
path: root/bash
diff options
context:
space:
mode:
authorCase Duckworth2021-08-23 23:07:31 -0500
committerCase Duckworth2021-08-23 23:07:31 -0500
commite292eb508413b9174684a8e75c93474a7f5351ee (patch)
treee7e59b21c817bfd1c438ef3cfc68b9021e786d7c /bash
downloadetc-e292eb508413b9174684a8e75c93474a7f5351ee.tar.gz
etc-e292eb508413b9174684a8e75c93474a7f5351ee.zip
Initial
Diffstat (limited to 'bash')
-rw-r--r--bash/aliases.bash26
-rw-r--r--bash/blesh.bash.disable1
-rw-r--r--bash/dircolors.bash1
-rw-r--r--bash/functions.bash11
-rw-r--r--bash/guix.bash3
-rw-r--r--bash/history.bash35
-rw-r--r--bash/man.bash9
-rw-r--r--bash/please.bash14
-rw-r--r--bash/prompt.bash25
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
4sudo_cmds=(
5 shutdown
6 reboot
7 halt
8 mount
9 umount
10 visudo
11)
12for cmd in "${sudo_cmds[@]}"; do
13 alias $cmd="sudo $cmd"
14done
15
16# LS
17alias ls='ls -F --color=auto'
18alias ll='ls -l'
19# tree
20alias tree='tree -F'
21
22# make locally
23alias lake='make PREFIX=~/usr'
24
25# bash meta
26alias 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 @@
1memq() { # 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 @@
1export 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
6HISTFILE="$XDG_DATA_HOME/bash/history"
7mkdir -p "$XDG_DATA_HOME/bash"
8
9# Don't truncate history
10HISTFILESIZE=-1 # numeric values less than zero => don't truncate
11HISTSIZE=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.
15shopt -s histappend
16
17# History editing with readline
18shopt -s histreedit # allow re-editing of a failed history substitution
19shopt -s histverify # verify a history expansion before running it
20
21# Save command invocation time to HISTFILE, and format it thusly
22HISTTIMEFORMAT="%F %T "
23
24# Erase all duplicates before saving the current line
25HISTCONTROL=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
30HISTIGNORE='&:[ ]*'
31# Other commands to ignore
32HISTIGNORE="$HISTIGNORE:ls:exit:cd"
33
34# Automatically append to HISTFILE on every command
35PROMPT_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 @@
1export MANWIDTH=80
2
3# on smaller terminals, use their width
4# (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width)
5man() {
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
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 new file mode 100644 index 0000000..c61266b --- /dev/null +++ b/bash/prompt.bash
@@ -0,0 +1,25 @@
1# bash prompt
2
3PS1=
4
5# user, host, and cwd
6PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
7PS1+='\[\e[36m\]\u@\h \w'
8
9# git bit
10source /usr/share/git/git-prompt.sh &&
11 PS1+='\[\e[35m\]$(__git_ps1)'
12
13# newline
14PS1+='\[\e[0m\]\n'
15
16# exit code (only if error)
17__prompt_exit_code() {
18 local ec=$?
19 (( $ec > 0 )) &&
20 printf "$ec"
21}
22PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]'
23
24# delimiter
25PS1+='; '