-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
69 lines (55 loc) · 1.71 KB
/
dot_zshrc
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
DISABLE_AUTO_UPDATE="true"
ZSH_THEME="powerlevel10k/powerlevel10k"
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export ZSH="$HOME/.oh-my-zsh"
source $ZSH/oh-my-zsh.sh
source ~/.p10k.zsh
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# -gt 0 ]]; then
git "$@"
else
git status
fi
}
alias gaa='git add --all'
alias gane='git commit --amend --no-edit'
alias gd='git diff'
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# git commit with message argument
gc() {
if [[ $# != 1 ]]; then
echo "Usage: gc <MESSAGE>" >&2
return $?
fi
git commit -m $1
}
# git branch (interactive)
gb() {
if [[ "$#" -gt 0 ]]; then
git branch "$@"
return $?
fi
local branches selection branch
branches=$(git branch --sort=-committerdate -vv) &&
selection=$(echo "$branches" | fzf --height=20% +m) &&
branch=$(echo "$selection" | awk '{print $1}' | sed "s/.* //") &&
if [[ -t 1 ]]; then git checkout "$branch"; else echo $branch; fi
}
# start a new branch
gs() {
if [[ $# != 1 ]]; then
echo "Usage: gs <NAME>" >&2
return $?
fi
defaultBranchName=$(git branch -l main master | sed 's/[\* ]*//' | head -n 1)
git fetch origin
git switch -c "jfuchs/$1" "origin/$defaultBranchName"
git push -u origin "jfuchs/$1"
}