Skip to content

Instantly share code, notes, and snippets.

@tdreid
Last active June 12, 2020 22:52
Show Gist options
  • Save tdreid/9c4edc984e3aaa4ecfc97c89335f592b to your computer and use it in GitHub Desktop.
Save tdreid/9c4edc984e3aaa4ecfc97c89335f592b to your computer and use it in GitHub Desktop.
A modest set of useful aliases for git and bash productivity
alias ls='ls --color=auto -F'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias less="less -R "
alias mint='git co master && git branch | grep -v "master" | xargs git branch -D'
# alias rake="for BRANCH in `ls .git/refs/heads`; do git checkout $BRANCH; git mn master; done"
alias php="php -c ~/workspace/php.ini"
alias hott="prettier --write --tab-width 4 --single-quote \"{,!(node_modules)/**/}*.js\""
alias newex="express --git --view pug"
alias dpak="npm i -D babel-core babel-preset-env babelify browserify uglify-js"
alias bump="npm --no-git-tag version"
alias pack="cat ~/.bash_history | sort | uniq > ~/.bash_history && history -c && history -r"
alias b="'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'"
alias {c,e}="code ."
alias ep="code ~/.profile"
alias ea="code ~/.gitconfig"
alias g="git"
alias r="source ~/.profile"
alias x="explorer ."
alias dev="cd c:/dev"
alias repos="cd ~/source/repos"
alias dl="cd ~/Downloads"
alias docs="cd ~/Documents"
alias pics="cd ~/Pictures"
alias home="cd ~"
alias ..="cd .."
alias up="cd .."
alias up2="cd ../.."
alias up3="cd ../../.."
alias up4="cd ../../../.."
[alias]
co = checkout
ci = commit
cip = commit -p
st = status
br = branch
hist = log -n8 --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
histl = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
fit = cat-file -t
fip = cat-file -p
fa = fetch --all
pa = pull --all
mn = merge --no-ff
ap = add -p
lsa = config --get-regexp alias
wip = ci -am "WIP"
mfc = ci -m "First!"
mic = ci -m "Initial commit"
mmc = ci -m "Make initial commit"
#!/bin/bash
# by http://github.com/jehiah
# this prints out some branch status
# It is similar to the '... ahead' info you get from git status
# example:
# $ git branch-status
# dns_check (ahead 1) | (behind 112) origin/master
# master (ahead 2) | (behind 0) origin/master
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \
while read local remote
do
[ -z "$remote" ] && continue
git rev-list --left-right ${local}...${remote} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue
LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta)
RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)
echo "$local (ahead $LEFT_AHEAD) | (behind $RIGHT_AHEAD) $remote"
done
#!/bin/bash
if [ $# -gt 0 ]; then
OUT_DIRECTORY=$1
else
OUT_DIRECTORY="."
fi
git for-each-ref --format='%(refname:short)' refs/heads | \
while read branch; do
git archive --format zip --output ${OUT_DIRECTORY}/${branch}.zip $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment