Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Last active December 19, 2015 23:08
Show Gist options
  • Save yrgoldteeth/6032008 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/6032008 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function aliasestext()
{
cat<<EOF
alias gplom="git pull origin master"
alias gpsom="git push origin master"
alias gcow='git checkout work'
alias gcom='git checkout master'
alias gmw='git merge work'
alias gmm='git merge master'
alias gs='git status'
alias gf='git fetch'
alias gmod='git merge origin/develop'
alias gcod='git checkout develop'
#grep stuff
alias grep='grep --color '
alias pgrep='pgrep -l '
#rails/ruby
alias rdb='rake db:migrate'
alias rdbp='rake db:migrate:plugins'
alias rdbtp='rake db:test:prepare'
alias rsc='ruby script/console'
alias rss='ruby script/server'
alias ss='bundle exec script/rails s'
alias ss1='ss -p3001'
alias ss2='ss -p3002'
alias ss3='ss -p3003'
alias ss15='ss -p3015'
alias ss17='ss -p3017'
alias sc='bundle exec script/rails c'
#file stuff
alias cp='cp -v'
alias mv='mv -v'
#directory stuff
alias l='ls'
alias la='l -a'
alias ll='l -l'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ~='cd ~'
EOF
}
shell_aliases_path=$HOME/.ndfine-shell-aliases
# Push this into .bashrc or .profile or .zshrc or whatever
function sourcealiasestext()
{
cat<<EOF
if [ -f $shell_aliases_path ];
then
source $shell_aliases_path
fi
EOF
}
# Create .ndfine-shell-aliases
if [ ! -f $shell_aliases_path ]
then
echo "Creating $shell_aliases_path"
aliasestext > $shell_aliases_path
fi
# If there's a .zshrc or .bashrc check for
# my aliases file being sourced and add it
# if not...
if [ -f $HOME/.zshrc ];
then
grep -q 'ndfine-shell-aliases' $HOME/.zshrc
if [ $? -ne 0 ]
then
echo "Adding aliases sourcing to .zshrc"
sourcealiasestext >> $HOME/.zshrc
fi
elif [ -f $HOME/.bashrc ];
then
grep -q 'ndfine-shell-aliases' $HOME/.bashrc
if [ $? -ne 0 ]
then
echo "Adding aliases sourcing to .bashrc"
sourcealiasestext >> $HOME/.bashrc
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment