You can also create functions in your ~/.bashrc instead (zsh users do it in your ~/.zshrc). But this is more useful for using statements / longer more complex tasks.
For example:
Check for and reinstall any broken packages. Contains a check to prevent running sudo eopkg it --reinstall
when there are no broken packages detected so you do not get eopkg printing help due to a missing argument (package name).
solchk() {
brokenpkgs=( $(sudo eopkg check | tee /dev/stderr | grep Broken | awk '{print $4}') )
nbroken=${#brokenpkgs[@]}
if [ $nbroken -gt 0 ]; then
sudo eopkg it --reinstall ${brokenpkgs[*]}
else
echo -e "\nThere were no broken packages."
fi
}
Display current time for multiple timezones.
wclock () {
echo -n 'Local : '
date '+%a %d %B %Y - %r'
echo -n 'New York : '
TZ=America/New_York date '+%a %d %B %Y - %r'
echo -n 'London : '
TZ=Europe/London date '+%a %d %B %Y - %r'
echo -n 'Zurich : '
TZ=Europe/Zurich date '+%a %d %B %Y - %r'
}
algent
Recently ~/.local/bin/
was added to the default PATH, so you could use that instead of ~/.bin/ if you prefer, 1 less change to make on a new install. https://dev.getsol.us/source/bash/browse/master/files/profile/10-path.sh$17