Skip to content

Instantly share code, notes, and snippets.

@nickcarenza
Created February 25, 2015 18:26
Show Gist options
  • Save nickcarenza/535313e62b3f07c8f416 to your computer and use it in GitHub Desktop.
Save nickcarenza/535313e62b3f07c8f416 to your computer and use it in GitHub Desktop.
Useful shell functions
dotil() {
echo "Trying '${@}'"
until $@; do :; done
}
inTmux() {
if ! { [ "$TERM" = "screen" ] && [ -n "$TMUX" ]; } then return 1; fi
}
pane() {
if ! inTmux; then tmux "pane ${@}" && return; fi
tmux split-window -l 5 "${@} && sleep 5 && exit" -d
#echo "${@}"
#tmux split-window -d -l 5 -t "${@}"
#tmux split-window -l 5
#$@
#echo "Process completed. Exiting in 20 seconds"
#sleep 10
#exit
}
# Attempt to determine what went wrong with previous command
# and suggest a different command to run instead
_() {
# TODO check if previous command was git push
if [[ $? == 128 ]] ; then
# get local branch name
# maybe prompt for remote
read -n 1 -p "git push --set-upstream origin master? " yn
printf "\n"
case $yn in
[Yy]* ) git push --set-upstream origin master; printf "\n";;
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment