Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (83 sloc) 2.05 KB
# vim:set ft=sh et sw=2:
# shellcheck shell=sh disable=SC2039
indirect_expand () {
eval printf '%s' "\"\$$var\""
}
remove_path () {
local IFS=':'
local dir val
local var="$1"
for dir in $(indirect_expand "$var"); do
[ "$dir" != "$2" ] && val="${val:+$val:}$dir"
done
eval "$var=\$val"
}
prepend_path () {
local dir
local var="$1"
shift
for dir in "$@"; do
remove_path "$var" "$dir"
[ -d "$dir" ] && eval "${var}=\${dir}\${${var}:+:\$${var}}"
done
}
append_path () {
local dir
local var="$1"
shift
for dir in "$@"; do
remove_path "$var" "$dir"
[ -d "$dir" ] && eval "${var}=\${${var}:+\$${var}:}\${dir}"
done
}
prepend_path PATH /sbin /usr/sbin /bin /usr/bin
prepend_path PATH /usr/local/sbin /usr/local/bin
prepend_path PATH "$HOME/.local/bin"
prepend_path INFOPATH /usr/share/info /usr/local/share/info
export PATH INFOPATH
GPG_TTY=$(tty)
export GPG_TTY
[ ! -x /bin/stty ] || stty -ixon
alias du1="du -h -d1"
alias fkill="fuzzy-kill"
alias fps="fuzzy-ps"
alias grep="grep -In --color=auto --exclude-dir=.git --exclude=tags"
alias egrep="grep -E"
alias fgrep="grep -F"
alias helptags="vim -e -c Helptags -c q"
alias lstcp="sudo lsof -Pn -iTCP"
alias lsudp="sudo lsof -Pn -iUDP"
alias rg="rg --line-number --no-heading --hidden"
alias tree="tree -ACFIa .git --dirsfirst"
alias vi="vim"
sudo () {
case "$1" in
vi|vim)
echo "use sudoedit or sudo -e" >&2
return 1
;;
*)
command sudo "$@"
;;
esac
}
inpath () {
type "$1" >/dev/null 2>&1
}
case "$(uname)" in
Darwin)
inpath ggrep && alias grep="ggrep -In --color=auto --exclude-dir=.git --exclude=tags"
inpath sudoedit || alias sudoedit="sudo -e"
alias ls="ls -AFGbh"
alias flushdns="sudo -k killall -HUP mDNSResponder"
alias resetlaunchpad="defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock"
COPYFILE_DISABLE=1
export COPYFILE_DISABLE
HOMEBREW_NO_EMOJI=1
HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_EMOJI HOMEBREW_NO_ANALYTICS
;;
Linux)
alias ls="ls -AFbh --color=auto"
;;
esac