Skip to content

Instantly share code, notes, and snippets.

@sarciszewski
Created August 27, 2014 16:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarciszewski/9b6589a502170f6ab83d to your computer and use it in GitHub Desktop.
Save sarciszewski/9b6589a502170f6ab83d to your computer and use it in GitHub Desktop.
Scott's Bashrc
cl()
{
# change directory then view its contents in one step
if [ -z $2 ]
then
cd $1 && ls -lah
else
cd $1 && ls $2
fi
}
fliptable() {
# Taken from https://twitter.com/climagic/status/370595711483514880
# Example usage:
# gpg --verify file.sig file || fliptable
echo "(╯°□°)╯ ┻━┻";
}
function fuck() {
# Example usage: `fuck you java`
killall -9 $2;
if [ $? == 0 ]
then
echo
echo " (╯°□°)╯︵$(echo $2|flip &2>/dev/null)"
echo
fi
}
banip() {
if [ -z $1 ]
then
echo "Parameter not passed."
else
iptables -A INPUT -s $1 -j DROP
iptables -A OUTPUT -d $1 -j DROP
echo "$1 banned."
#If you get an error, switch the comment out below
#/etc/init.d/iptables save
iptables-save
fi
}
#usage: banip XX.XX.XX.XX
# Blocks incoming and outgoing connections to a given IP or subnet
function git-branch-name {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\e[38;5;154m\u@\h\e[0m \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
github_sync() {
if [ -z $1 ]; then
echo "Usage: github_sync branch_name"
else
upstream_exists=`git show-ref | grep upstream | wc -l`
if [[ $upstream_exists -eq 0 ]]; then
echo "There is no upstream branch. Make sure you run:"
echo "git remote add upstream https://github.com/___/___.git"
else
git fetch upstream $1
git checkout $1
git rebase upstream/$1
git push --force origin master
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment