Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created August 19, 2016 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yrgoldteeth/8370a0cc56f0139874665c999de3df72 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/8370a0cc56f0139874665c999de3df72 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function aliasestext()
{
cat<<EOF
alias gpsom="git push origin master"
alias gcom='git checkout 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='bin/rake db:migrate'
alias rdbp='bin/rake db:migrate:plugins'
alias rdbtp='bin/rake db:test:prepare'
alias ss='bin/rails s'
alias ss1='ss -p3001'
alias ss2='ss -p3002'
alias ss3='ss -p3003'
alias ss15='ss -p3015'
alias ss17='ss -p3017'
alias sc='bin/rails c'
alias rsp='bin/rspec'
alias b='bundle'
#file stuff
alias cp='cp -v'
alias mv='mv -v'
#directory stuff
alias l='ls'
alias la='l -a'
alias ll='l -hl'
alias lrt='l -hrt'
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 $HOME/.ndfine-shell-aliases ]
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