A well crafted $CDPATH helps me jump from project to project and from directory to directory within a project without having to type many ../:
CDPATH=./:~/:~/Documents/:[...]
I often grep/ag stuff only to think afterwards that I should have done that from Vim, so I have this to rerun the previous command and feed its output to Vim's quickfix:
vimq() {
vim -q
Speaking of Vim, this one lets me open an arbitrary file from the current project in Vim without having to glob:
vimf() {
vim +find\ **/*$1
}
Create a directory and cd to it:
mkcd() {
mkdir -p "$*"
cd "$*"
}
It's not in my .bash_profile but I use this little command all over the place to get my IP address (and I need my IP address a lot):
#!/usr/bin/env sh
SYSTEM=$(\uname | \tr /a-z/ /A-Z/ | \cut -c-5)
# MacOS
if [ "$SYSTEM" = "DARWI" ]; then
\ifconfig | \sed '/vboxnet/{N;N;d;}' | \grep 'inet ' | \grep -v '127.0.0.1' | \awk '{print $2}' | \tr '\n' '-' | \sed 's/-.*//' | \tr -d '\n'
\exit 0
fi
# Linux
if [ "$SYSTEM" = "LINUX" ]; then
\ip route get 1 | \awk '{print $NF}' | \tr -d '\n'
\exit 0
fi
# MINGW/CYGWIN on Windows
if [ "$SYSTEM" = "MINGW" -o "$SYSTEM" = "CYGWI" ]; then
\ipconfig | \grep 'IPv4' | \awk '{print $NF}' | \tr -d '\n'
\exit 0
fi