mord shell

This commit is contained in:
Geoffrey Frogeye 2019-04-16 19:18:16 +02:00
parent 20e67036df
commit 3697eec6e1
4 changed files with 35 additions and 33 deletions

View file

@ -45,44 +45,35 @@ trysource() {
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 $?
_i_prefer() { # executables...
for candidate in "$@"
do
if [ -x "$(command -v "$candidate")" ]
then
choice="$candidate"
break
fi
done
for ex in "$@"; do
[ "$al" = "--" ] && break
if [ -z "$list" ]; then
list=$ex
else
list=$list, $ex
if [ -z "$choice" ]
then
return
fi
for candidate in "$@"
do
if [ "$candidate" != "$choice" ]
then
alias "$candidate"="$choice"
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
_i_prefer nvim vim vi
_i_prefer gopass pass
_i_prefer wakeonlan wol
_i_prefer neomutt mutt
unset _i_prefer
## COLORS
[ -f ~/.local/bin/colorSchemeApply ] && . ~/.local/bin/colorSchemeApply
trysource ~/.local/bin/colorSchemeApply
# Needed because xterm/urxvt won't use the last color, needed for vim