Skip to content

Commit 784e90d

Browse files
feat(zsh): add git functions
1 parent c1f830b commit 784e90d

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

zsh/functions/$

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# vim: set ts=4 sw=4 tw=80 ft=zsh et :
2+
# Ever pasted "$ somecommand" into the terminal and gotten this error?
3+
# -bash: $: command not found
4+
5+
# Begone, silly errors! Lazy copy + paste forever!! ETCETERA!!!!
6+
#
7+
8+
unalias $ 2> /dev/null
9+
10+
echo 'Quit pasting in commands from the internet, you lazy bum.'
11+
"$@"

zsh/functions/git-deinit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# vim: set ts=4 sw=4 tw=80 ft=zsh et :
2+
# Simple tool to remove a git repo from somewhere. Just run `git deinit`
3+
4+
unalias unixtime 2> /dev/null
5+
6+
REPO_PATH=$(git rev-parse --show-toplevel)
7+
8+
if [[ -d "${REPO_PATH}/.git" ]]; then
9+
read -p "De-initialize this git repo? [y/N]" -n 1 -r
10+
if [[ $REPLY =~ ^[Yy]$ ]]; then
11+
echo
12+
echo "Removing ${REPO_PATH}/.git…"
13+
rm -rf "${REPO_PATH}/.git"
14+
echo "Done ✓"
15+
else
16+
echo "Aborting…"
17+
fi
18+
else
19+
echo "Not in a git repository"
20+
fi

zsh/functions/git-delete-tags

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# vim: set ts=4 sw=4 tw=80 ft=zsh et :
2+
# Delete all git remote tags
3+
4+
unalias git-delete-tags 2> /dev/null
5+
6+
# Exit if git is not installed
7+
(( $+commands[git] )) || return 0
8+
9+
# Taken from https://gist.github.com/okunishinishi/9424779
10+
11+
#Delete local tags.
12+
git tag -l | xargs git tag -d
13+
#Fetch remote tags.
14+
git fetch
15+
#Delete remote tags.
16+
git tag -l | xargs git push --delete origin
17+
#Delete local tags.
18+
git tag -l | xargs git tag -d

zsh/functions/git-nuke

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# vim: set ts=4 sw=4 tw=80 ft=zsh et :
2+
# Nukes a branch locally and on the origin remote.
3+
4+
unalias git-nuke 2> /dev/null
5+
6+
# Exit if git is not installed
7+
(( $+commands[git] )) || return 0
8+
9+
if [[ -z "$1" ]]; then
10+
echo "USAGE: git-nuke Branch name"
11+
return 1
12+
fi
13+
14+
git branch -D "$1"
15+
git push origin :"$1"

zsh/functions/killport

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# vim: set ts=4 sw=4 tw=80 ft=zsh et :
2+
# Kills all processes running on the specified port (e.g. 'killport 8080')
3+
4+
unalias killport 2> /dev/null
5+
6+
# Exit if git is not installed
7+
(( $+commands[awk] )) || return 0
8+
9+
if [[ -z "$1" ]]; then
10+
echo "USAGE: killport PORT"
11+
return 1
12+
fi
13+
14+
15+
lsof -i tcp:"$1" | awk '(NR!=1) && ($1!="Google") && ($1!="firefox") {print $2}' | xargs kill

0 commit comments

Comments
 (0)