add check for command on certain systems before adding alias

This commit is contained in:
2026-10-29 10:42:45 -06:00
parent a2acf44f91
commit 40a51e8511

View File

@@ -1,15 +1,15 @@
# Custom Bash Aliases # Custom Bash Aliases
## system services # system services
alias restart="sudo systemctl restart" alias restart="sudo systemctl restart"
alias status="sudo systemctl status" alias status="sudo systemctl status"
## navigation # navigation
alias ..='cd ..' alias ..='cd ..'
alias ...='cd ../../' alias ...='cd ../../'
alias ....='cd ../../../' alias ....='cd ../../../'
## system information # system information
alias connections="sudo netstat -tunlp" alias connections="sudo netstat -tunlp"
alias ports='netstat -tulanp' alias ports='netstat -tulanp'
alias path='echo -e ${PATH//:/\\n}' alias path='echo -e ${PATH//:/\\n}'
@@ -17,39 +17,44 @@ alias free='free -m -l -t'
alias psmem='ps auxf | sort -nr -k 4 | head -10' alias psmem='ps auxf | sort -nr -k 4 | head -10'
alias pscpu='ps auxf | sort -nr -k 3 | head -10' alias pscpu='ps auxf | sort -nr -k 3 | head -10'
## system logs # system logs
alias logtail="tail -n 200 /var/log/syslog" alias logtail="tail -n 200 /var/log/syslog"
## system administration # system administration
alias upgrade="sudo apt update && sudo apt upgrade -y" alias upgrade="sudo apt update && sudo apt upgrade -y"
alias syscat='systemctl cat' alias syscat='systemctl cat'
alias sysls='systemctl list-unit-files --type=service --state=enabled' alias sysls='systemctl list-unit-files --type=service --state=enabled'
alias syslsa='systemctl list-unit-files --type=service' alias syslsa='systemctl list-unit-files --type=service'
## safe defaults # safe defaults
alias rm='rm -I --preserve-root' alias rm='rm -I --preserve-root'
alias chown='chown --preserve-root' alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root' alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root' alias chgrp='chgrp --preserve-root'
## apps # alias `git` and add completion
alias g='git' alias g='git'
# enable tab completion for 'g' by marking as alias for 'git' # enable tab completion for 'g' by marking as alias for 'git'
if type _git &> /dev/null; then if type _git &> /dev/null; then
complete -o default -o nospace -F _git g; complete -o default -o nospace -F _git g;
fi fi
alias bat='batcat' # bat[cat] setup -- check for command name and alias accordingly
if command -q batcat; and not command -q bat
alias bat='batcat'
end
# use `bat` for help command (override bash built-in)
alias bathelp='bat --plain --language=help' alias bathelp='bat --plain --language=help'
help() { help() {
"$@" --help 2>&1 | bathelp "$@" --help 2>&1 | bathelp
} }
## text editing # text editing
alias edit="emacs" alias edit="emacs"
alias sedit="sudo emacs" alias sedit="sudo emacs"
## ls helpers # ls helpers
alias l="ls -lFh --color" alias l="ls -lFh --color"
alias la="ls -AF --color" # exclude . and .. alias la="ls -AF --color" # exclude . and ..
alias lsd="ls -lFh --color | grep --color=never '^d'" # only directories alias lsd="ls -lFh --color | grep --color=never '^d'" # only directories
@@ -61,7 +66,7 @@ alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto' alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto' alias egrep='egrep --color=auto'
## misc utils # misc utils
alias ip="dig +short myip.opendns.com @resolver1.opendns.com" alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ping='ping -c 5' alias ping='ping -c 5'
alias reload="exec ${SHELL} -l" # reload the shell alias reload="exec ${SHELL} -l" # reload the shell