blob: 140f9584da48176117a6915818ac8ef32e12b746 (
plain) (
tree)
|
|
# -*- 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
|