From 5a7db2f34aa6a6787d98a001b6d28be97f36abf4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 25 Jun 2021 12:56:30 +0200 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- bash/aliases | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 bash/aliases (limited to 'bash/aliases') 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 [] +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 "" +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 -- cgit v1.2.3-70-g09d2