Skip to content

Instantly share code, notes, and snippets.

@ordinz
Created June 30, 2020 04:36
Show Gist options
  • Save ordinz/2411697ea8e631246175b9a44d4bf1c3 to your computer and use it in GitHub Desktop.
Save ordinz/2411697ea8e631246175b9a44d4bf1c3 to your computer and use it in GitHub Desktop.
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
alias pwdc="pwd | pbcopy"
alias redotfile="cd ~; rm -rf dotfiles/; git clone https://github.com/lukelove/dotfiles.git && cd dotfiles && source bootstrap.sh"
alias d="cd ~/dev"
#GIT
alias g="git"
alias gf="git diff"
alias gfa="git diff | atom"
alias go="git checkout"
alias gom="go master"
alias gs="git status"
alias gb="git branch"
alias ga="git add"
alias gc="git commit"
alias gpom="git pull origin master"
alias gpod="git pull origin develop"
alias gac="ga .; gc"
alias stash="git stash"
alias git_reset_gpg="git config --global --unset commit.gpgsign; git config --global user.name 'Your Name'; git config --global user.email you@example.com; echo 'gpg reset';"
alias git_undo_commit="git reset HEAD~"
function fixup(){
ga .; gc -m "fixup"; git rebase -i master
}
git_grep(){ # grep across all branches
git grep "$1" $(git rev-list --all)
}
# create branch and check it out
gbo(){ #git branch $1; git branch $1
git branch $1;
git checkout $1;
echo "Hey `whoami`, You are now in your new branch ___ $1 ___"
}
# active branch name
git_branch_name(){
git rev-parse --abbrev-ref HEAD
}
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
else # macOS `ls`
colorflag="-G"
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi
# List all files colorized in long format, including dot files
alias l="ls -laF ${colorflag}"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
### Terminal.
alias k='clear; echo -e "\033c\e[3J"' #Clear Console
# Find and Kill anything associated with this PID
# ie: `kill_all_pids_for ngrok`
kill_all_pids_for(){
find_pids_for $1 | xargs kill -9
}
find_all_pids_for(){
ps aux | grep $1 | grep -v grep | awk '{ print $2 }'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment