Skip to content

Instantly share code, notes, and snippets.

@jarod51
Forked from jednano/.zshrc
Created January 9, 2017 12:27
Show Gist options
  • Save jarod51/2c4f640545e9a5717df64225f9e02e78 to your computer and use it in GitHub Desktop.
Save jarod51/2c4f640545e9a5717df64225f9e02e78 to your computer and use it in GitHub Desktop.
# copy into ~/.profile or ~/.bashrc
#alias ls='ls -F --color --show-control-chars'
alias ls='ls -F --show-control-chars'
alias ll='ls -l'
# Windows aliases
alias cls='clear'
alias dir='ls -F --color=always'
alias del='rm'
alias deltree='rm -Rf'
alias edit='nano'
alias find='grep --color=auto -in'
alias rd='rmdir'
alias ren='mv'
alias md='mkdir'
# Python commands
alias cwd='pwd'
# git commands
alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gd='git diff'
alias gf='git fetch'
alias gm='git merge'
alias gr='git rebase'
alias gs='git status'
alias gt='git tag'
alias dt='git difftool'
alias mt='git mergetool'
alias co='git checkout'
alias pull='git pull'
alias push='git push'
# compass commands
alias cw='compass watch'
alias cc='compass compile --force'
# Hautelook commands
alias app='cd /z/Documents/GitHub/halo/halo-symfony/src/Hautelook/LayoutBundle/Resources/Frontend/app'
function halo() {
cd /z/Documents/GitHub/halo
if [ "$1" == "rack" ]; then
cd "rack"
elif [ ! -z "$1" ]; then
cd "halo-$1"
fi
}
function sup() {
pwd=$(pwd)
halo
sup_sync halo-env
sup_sync halo-solr
sup_sync halo-symfony
sup_sync halo-www
sup_sync rack
cd $pwd
}
function sup_sync() {
echo -e "\n\n$1\n"
cd $1
this_branch=$(cb)
if [ $this_branch != "master" ]; then
co master
fi
pull upstream master
# blam
gs
if [ $this_branch != "master" ]; then
co $this_branch
fi
cd ..
}
# Function aliases
alias sq=squash
alias cb=current_branch
# Functions
function squash() {
git rebase -i HEAD~$1
}
function current_branch() {
gb 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function blam() {
push origin $(cb) $@
}
function sync() {
gf --multiple origin upstream
this_branch=$(cb)
co master && pull && blam && gs
co $this_branch
}
function rebase() {
sync && gr master
}
function track_upstream_master() {
git fetch upstream
git config branch.master.remote upstream
git config branch.master.merge refs/heads/master
pull
}
function npm_uninstall_all() {
for package in `ls node_modules`; do npm uninstall $package; done;
}
function shortwd() {
num_dirs=3
pwd_symbol="..."
newPWD="${PWD/#$HOME/~}"
if [ $(echo -n $newPWD | awk -F '/' '{print NF}') -gt $num_dirs ]; then
newPWD=$(echo -n $newPWD | awk -F '/' '{print $1 "/.../" $(NF-1) "/" $(NF)}')
fi
echo -n $newPWD
}
alias gfre=git_folder_rename_ext
function git_folder_rename_ext() {
for glob in "${1}/*${2}" "${1}/**/*${2}"; do
for f in $glob; do
git_rename_ext "${f}" "${2}" "${3}"
done
done
}
function git_rename_ext() {
git mv "${1}" "${1/%${2}/${3}}"
}
PS1='\n\n\e[0;36m$(shortwd)\e[0;32m$(__git_ps1)\n\e[1;30m$(date +%H:%M) \e[0m$'
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM='verbose git'
export PS1 GIT_PS1_SHOWDIRTYSTATE GIT_PS1_SHOWUPSTREAM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment