diff --git a/add-new.zsh b/add-new.zsh new file mode 100755 index 0000000..6118a06 --- /dev/null +++ b/add-new.zsh @@ -0,0 +1,16 @@ +#!/bin/zsh +if git status --porcelain | grep -q '^A'; then + echo 'You have uncommited but staged changes. Aborting' + exit 1 +fi +if [[ ! -e $1 ]]; then + echo "$1 not found" + exit 1 +fi +if ! git status --porcelain -- $1 | grep -q '^\?\?'; then + echo "$1 already in repository" + exit 1 +fi + +git add $1 +git commit -m "New script: $1"