Skip to content

Instantly share code, notes, and snippets.

@so-jelly
Created March 27, 2022 17:14
Show Gist options
  • Save so-jelly/674088a9ef5403c3815890e0915a9b37 to your computer and use it in GitHub Desktop.
Save so-jelly/674088a9ef5403c3815890e0915a9b37 to your computer and use it in GitHub Desktop.
public shell functions
branchclean () {
for branch in $(git branch | grep -v master)
do
git branch -d $branch
done
}
gbc () {
git branch $1
git checkout $1
git push --set-upstream origin $1
}
sconnect() {
port=$(docker run 0bel1sk/open-ports)
case $2 in
443)
echo "$1 will be available at https://localhost:${port}"
;;
7075)
echo "$1 will be available at http://localhost:${port}"
;;
*)
echo "$1:$2 forwarding to $port"
;;
esac
ssh $1 -L "${port}:localhost:${2}"
}
watch () {
while true
do
clear
printf "[%s] Output of %s:\n" "$(date)" "$*"
${SHELL-/bin/zsh} -c "$*"
sleep 1
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment