dotfiles/bash/.aliases
Andrew R. M 6935843cee Move vim option select to execute logic at alias def time
Using the function would cause problems when trying to perform a `sudo
vim`. The sudo command would run in a root shell which does not have my
shells functions (but does have it's aliases) so then any attempt to
sudo vim would fail with "vim_option_select: command not found"
2025-04-05 16:38:28 -04:00

75 lines
1.7 KiB
Plaintext

#{- ~/.aliases -}#
#{- FILE OPERATIONS -}#
# Allow alias expansion for commands executed with sudo
alias sudo="sudo "
#{- VIM OPTION SELECT -}#
if which nvim &> /dev/null; then
export PREFERRED_VIM=nvim
else
export PREFERRED_VIM=vim
fi
alias vim="$PREFERRED_VIM "
#{- GNU COREUTILS -}#
# Sort directories first and colorize output
alias ls="ls -hF --color=auto --group-directories-first"
alias la="ls -AF"
alias ll="ls -lF"
# Ask before overwriting files
alias mv="mv -i"
alias cp="cp -i"
alias rm="rm -i --preserve-root --one-file-system"
# Create and remove empty subdirectories
alias mkdir="mkdir -p"
alias rmdir="rmdir -p"
# Don't recursively modify permissions on root directory
alias chmod="chmod --preserve-root"
alias chown="chown --preserve-root"
alias chgrp="chgrp --preserve-root"
# Colorize output
alias grep="grep --color"
alias egrep="grep -E --color"
alias fgrep='grep -F --color'
# Human readable file system inspection
alias df="df -h"
# Human readable file size inspection
alias du="du -sh"
# History searches
alias phistory='cat ${PERSISTENT_HISTFILE}'
alias hgrep='history | grep --color'
alias phgrep="cat ${PERSISTENT_HISTFILE} | grep --color"
alias hfzf='history | fzf'
alias phfzf="cat ${PERSISTENT_HISTFILE} | fzf"
#{- NETWORKING -}#
# Don't ping infinitely
alias ping="ping -c 4"
# Show progress while syncing
alias rsync="rsync --progress"
# Force a newline at the end of curl responses to prevent artifacting
alias curl="curl -w '\n'"
#{- SHELL INTROSPECTION -}#
# Print the value of the $PATH variable in a human readable format
alias path='printf "${PATH//:/\\n}\n"'
# Print current aliases in a human readable format
alias aliases='alias | sed -e "s/=/ -> /" -e "s/alias //"'