dotfiles/config/shell/shrc
2019-04-14 19:41:33 +02:00

89 lines
1.8 KiB
Bash

#!/usr/bin/env sh
#
# Shell common aliases and customizations (BusyBox compatible)
#
## COMMAND CONFIGURATION
# Completion for existing commands
alias ls='ls -h --color=auto'
alias mkdir='mkdir -v'
alias cp="cp -i"
alias mv="mv -iv"
alias free='free -h'
alias df='df -h'
alias ffmpeg='ffmpeg -hide_banner'
alias ffprobe='ffprobe -hide_banner'
alias ffplay='ffplay -hide_banner'
# ALIASES
# Frequent mistakes
alias sl=ls
alias al=la
alias mdkir=mkdir
alias systemclt=systemctl
alias please=sudo
# Shortcuts for commonly used commands
alias ll="ls -l"
alias la="ls -la"
alias s='sudo -s -E'
alias n='urxvtc &'
alias x='startx; logout'
alias nx='nvidia-xrun; logout'
# FUNCTIONS
trysource() {
if [ -f "$1" ]
then
. "$1"
else
return 1
fi
}
# Superseding commands with better ones if they are present
_rank_select() { # executables... -- arguments...
for ex in "$@"; do
[ "$ex" = "--" ] && break
if which "$ex" &>/dev/null; then
for al in "$@"; do
shift
[ "$al" = "--" ] && break
alias "$al"="$ex"
done
"$ex" "$@"
return $?
fi
done
for ex in "$@"; do
[ "$al" = "--" ] && break
if [ -z "$list" ]; then
list=$ex
else
list=$list, $ex
fi
done
echo "Not installed: $list"
}
_rank_install() { # executables...
for ex in "$@"; do
list=$@
alias "$ex"="_rank_select $list --"
done
}
_rank_install nvim vim vi
_rank_install gopass pass
_rank_install wakeonlan wol
_rank_install neomutt mutt
## COLORS
[ -f ~/.local/bin/colorSchemeApply ] && . ~/.local/bin/colorSchemeApply
# Needed because xterm/urxvt won't use the last color, needed for vim