diff options
Diffstat (limited to '')
-rw-r--r-- | bash/aliases | 87 | ||||
-rw-r--r-- | bash/aliases-Zenith | 17 |
2 files changed, 104 insertions, 0 deletions
diff --git a/bash/aliases b/bash/aliases new file mode 100644 index 0000000..140f958 --- /dev/null +++ b/bash/aliases @@ -0,0 +1,87 @@ +# -*- shell-script -*- + +# DESCRIPTION: Create directories and parents, if missing, and move into the first one +# USAGE: mkcd <directory> [<additional directories to create>] +mkcd () { + mkdir -p -- "$@" + cd -- "$1" +} + +# DESCRIPTION: Start bash in a temporary directory and destroy it after exiting the new bash instance +# USAGE: tmpsh +tmpsh () ( + local tmpdir + tmpdir="${XDG_RUNTIME_DIR}" + if test -z "$tmpdir"; then + tmpdir=/tmp + fi + tmpdir="$tmpdir/tmpsh-$$.d" + mkdir -p -- "$tmpdir" + cd -- "$tmpdir" + bash + cd / + rm -rf -- "$tmpdir" + test ! -e "$tmpdir" +) + +#DESCRIPTION: Reload the shell configurations +#USAGE: resh +resh () { + . ~/.bashrc +} + +#DESCRIPTION: Edit the shell configurations +#USAGE: edsh +edsh () { + if [ -z "$EDITOR" ]; then + echo 'No default editor is set, please configure the environment variable EDITOR' + else + $EDITOR ~/.bashrc + fi +} + +# DESCRIPTION: Run a command in a infinite loop with a sleep between executions +# USAGE: forever "<arguments for sleep>" <command> +forever () { + time="$1" + shift 1 + while true; do + "$@" + sleep $time + done +} + +#DESCRIPTION: ls with long listing, classification with appendix character, hidden files and the . and .. directories +alias ll='ls -alF' + +#DESCRIPTION: ls with hidden files +alias la='ls -A' + +#DESCRIPTION: ls with classification with appendix character +alias l='ls -CF' + +#DESCRIPTION: Go to the parent directory +alias ..="cd .." + + + +#libnotify +# DESCRIPTION: Add an "alert" alias for long running commands. Use like so: sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history | tail -n1 | sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + + + +for __script in ~/.config/bash/aliases.d/*; do + if test -r "${__script}"; then + . "${__script}" + fi +done +unset __script + +if test -r ~/.config/bash/"aliases-$(hostname)"; then + . ~/.config/bash/"aliases-$(hostname)" +fi + +if test -r ~/work/.config/bash/aliases; then + . ~/work/.config/bash/aliases +fi diff --git a/bash/aliases-Zenith b/bash/aliases-Zenith new file mode 100644 index 0000000..ac794c9 --- /dev/null +++ b/bash/aliases-Zenith @@ -0,0 +1,17 @@ +# -*- shell-script -*- + +mount-crypt () { + sudo printf '' && \ + device="$(sudo losetup --show -f -P /media/Secondary/.crypt/crypt.img)" && \ + printf '%s\n' "${device}" > "${XDG_RUNTIME_DIR}/CryptCrypt" && \ + gpg --decrypt /media/Secondary/.crypt/crypt.key | sudo cryptsetup -d - open "${device}" CryptCrypt && \ + mkdir -p ~/Crypt && \ + sudo mount /dev/mapper/CryptCrypt ~/Crypt +} + +umount-crypt () { + sudo umount ~/Crypt + rmdir ~/Crypt + sudo cryptsetup close CryptCrypt + sudo losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/CryptCrypt")" +} |