-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.aliases
More file actions
91 lines (80 loc) · 2.72 KB
/
.aliases
File metadata and controls
91 lines (80 loc) · 2.72 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
###########
# General #
###########
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias ls='ls -G'
alias lsa='ls -lah'
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/^.*\[//" | sed "s/[\^~].*//"'
git_purge_local () {
readonly branches=${$(git branch --merged | egrep -v "(^\*|$(git 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
}
rebase() {
local stash_arg='--no-autostash'
if ! git diff-index --quiet HEAD; then
printf "Stash? (Y/n): "
read -r should_stash
[[ ! $should_stash =~ ^[Nn]$ ]] && stash_arg='--autostash'
fi
local base_branch="${1:-$(git_parent)}"
if [[ -z "$base_branch" ]]; then
echo "Could not detect parent branch. Pass one explicitly: rebase <branch>"
return 1
fi
local merge_base
merge_base=$(git merge-base HEAD "$base_branch") || {
echo "Could not find merge-base with '$base_branch'"
return 1
}
echo "Parent branch: $base_branch"
echo ""
git log --color=always \
--pretty=format:'%C(green)%h%Creset %s %C(green)(%cr)%Creset %C(bold blue)<%an>%Creset' \
--abbrev-commit "${merge_base}..HEAD"
echo ""
printf "Rebase [a]ll commits or [p]ick one? (a/p): "
read -r choice
case "$choice" in
p|P)
local selected
selected=$(
git log --color=always \
--pretty=format:'%h %s %C(green)(%cr)%Creset %C(bold blue)<%an>%Creset' \
--abbrev-commit "${merge_base}..HEAD" \
| fzf --ansi --no-sort --header="Pick the oldest commit to include"
)
[[ -z "$selected" ]] && return 0
local hash
hash=$(echo "$selected" | awk '{print $1}')
git rebase -i --autosquash "$stash_arg" "${hash}^"
;;
*)
git rebase -i --autosquash "$stash_arg" "$merge_base"
;;
esac
}
##########
# Elixir #
##########
# Require an elixir project with Phoenix
alias search_routes="mix phx.routes | fzf"
alias mix_fast="MIX_OS_DEPS_COMPILE_PARTITION_COUNT=5 mix"
alias iex_mix_min="iex -S mix do loadpaths + app.config"