Created
April 23, 2014 07:18
-
-
Save superfawkes/11205421 to your computer and use it in GitHub Desktop.
Useful bash settings for the OS X Terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sets the terminal tab-name | |
function tabname { | |
printf "\e]1;$1\a" | |
} | |
# some git-stash-like goodies for svn | |
function shelf { | |
if [[ $# -lt 2 ]]; then | |
echo "Usage: $0 <patch-file-path> <files>" | |
return | |
fi | |
patchFile=$1 | |
shift | |
echo "Shelfing changes in $@ to $patchFile" | |
svn diff $@ >> $patchFile | |
echo -e "Revert files? [y/n]: \c" | |
read -n1 ans | |
echo "" | |
if [[ $ans == 'y' || $ans == 'Y' ]]; then | |
svn revert -R $@ | |
fi | |
echo "Done" | |
} | |
function unshelf { | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: $0 <patch-path> [<dir-to-change> (default: pwd)]" | |
fi | |
patchFile=$1 | |
if [[ $# -eq 1 ]]; then | |
tgtDir=. | |
else | |
tgtDir=$2 | |
fi | |
pushd $tgtDir | |
patch -p0 < $patchFile | |
echo -e "Erase patchfile? [y/n]: \c" | |
read -n1 ans | |
echo "" | |
if [[ $ans == 'y' || $ans == 'Y' ]]; then | |
rm -f $patchFile | |
fi | |
} | |
alias shelfls='grep "^\-\-\- " ../*.patch | sed -e "s/---/\t\t/g" | sed -e "s/\.\.\///g"' | |
function shelfpeek() { | |
if [[ $# -ge 1 ]]; then | |
cat $1 | grep -A10 "^\-\-\- " | grep -iE "^(\-|\+|\@\@)" | sed -e "s/^+++.*//g" | sed -e "s/^---//g" | |
else | |
grep -A10 "^\-\-\- " ../*.patch | sed -e "s/^--$/patch-@@ .../" | grep -iE "patch(\.|:|\-\-|\-\+|\-\@\@)" | sed -e "s/^.*patch-+++.*//g" | sed -e "s/patch:---/patch:=====>/g" | sed -e "s/^.*patch-+/\t\t\t+/g" | sed -e "s/^.*patch--/\t\t\t-/g" | sed -e "s/^.*patch-@/\t\t/g" | |
fi | |
} | |
# I prefer having diffs opened in TW - replace with patch-path and editor of your choice. | |
function sd { | |
svn diff $@ > ~/Desktop/patches/svdiff.patch && open -a /Applications/TextWrangler.app ~/Desktop/patches/svdiff.patch | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment