-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
59 lines (47 loc) · 1.8 KB
/
.aliases
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
###########
# General #
###########
alias ll="ls -lha"
alias latest="ls -lhat | head"
alias vim="nvim"
alias hidden_off='defaults write com.apple.Finder AppleShowAllFiles NO'
alias hidden_on='defaults write com.apple.Finder AppleShowAllFiles YES'
alias weather='curl wttr.in'
#######
# Git #
#######
alias git_rel="git log \$(git tag --sort=committerdate | tail -1)..HEAD --pretty=format:\"* %s\""
alias git_parent='git show-branch | sed "s/].*//" | grep "\*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed "s/^.*\[//"'
git_purge_local () {
readonly main_branch=${1:?"Please specify your 'trunk' branch, ex. main or master."}
readonly branches=${$(git branch --merged | egrep -v "(^\*|$main_branch)"):?"No branches found – aborting."}
echo "The following LOCAL branches seem to be merged and will be purged:"'\n'
echo "$branches"'\n'
if read -q "choice? Press Y/y to continue"$'\n'; then
echo '\n'
echo "$branches" | xargs git branch -d
else
echo '\n'"Aborted!"
fi
}
alias fixup="git commit --fixup=\$(git log --no-decorate --oneline master..HEAD | fzf | awk '{print \$1}')"
rebase() {
stashArg='--no-autostash'
if ! git diff-index --quiet HEAD; then
# We only care about stashing if there are unstaged changes
printf "Stash? (Y/n): "
read -r shouldStash
if [[ ! $shouldStash =~ ^[Nn]$ ]]; then
stashArg='--autostash'
fi
fi
git log --color --graph --pretty=format:'%Cgreen%h%Creset %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | cat -n | less -R
printf "Commit #: "
read -r commit
git rebase -i --autosquash $stashArg HEAD~$commit
}
##########
# Elixir #
##########
# Require an elixir project with Phoenix
alias search_routes="mix phx.routes | fzf"