-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc_scripts
32 lines (28 loc) · 964 Bytes
/
zshrc_scripts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env zsh
# $PATH adjustment utilities
# http://superuser.com/a/753948
pathappend() {
for ARG in "$@"
do
if [ -d "$ARG" ] && [[ ":$PATH:" != *":$ARG:"* ]]; then
PATH="${PATH:+"$PATH:"}$ARG"
fi
done
}
pathprepend() {
for ARG in "$@"
do
if [ -d "$ARG" ] && [[ ":$PATH:" != *":$ARG:"* ]]; then
PATH="$ARG${PATH:+":$PATH"}"
fi
done
}
# Inspired by https://medium.com/in-the-weeds/automating-amending-to-older-commits-c33740c1beb3
# A use case is to automate interactive rebase by putting the current fixup commit with the commit
# where the same file was last changed, e.g.
# ❯ for f in $(git status -uno --porcelain | awk -F ' ' '{print $2}'); do git add $f && amend-fixup $(git --no-pager log -n 1 --pretty=format:%H -- $f); done
amend-fixup() {
SHA=$1
git commit --fixup $SHA &&
GIT_EDITOR="cat" git rebase --autosquash --autostash --interactive $SHA^
}