-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
96 lines (74 loc) · 1.71 KB
/
.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Prompt
# Returns prefix of $1, clipped by ..., with total length at most $2
function dots()
{
s=$1
n=$2
m=$((n-3))
if [ ${#s} -gt $n ];
then
echo "${s:0:$m}..."
else
echo $s
fi
}
# Returns "(curr-branch-nam...) " or "" otherwise
function git_branch()
{
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [ "$branch" = "" ];
then
echo ""
else
echo "($(dots $branch 18)) "
fi
}
setopt prompt_subst
PROMPT='%F{203}%n:%f %F{038}%.%f %F{035}$(git_branch)%f%F{215}%%%f '
# Aliases
alias ls='ls -Gh'
alias lsl='ls -AGhl'
alias dush='du -sh *'
alias less='less -Nr'
alias viv='vi ~/.vimrc'
alias viz='vi ~/.zshrc'
alias soz='source ~/.zshrc'
alias cds='cd ~/code'
alias python='python3'
alias pip='pip3'
fined() {
ag -l --follow --hidden | grep "$1"
}
# fzf setup
source /opt/homebrew/opt/fzf/shell/*.zsh # Necessary on Mac I think
export FZF_DEFAULT_OPTS='-m --height 40% --min-height 3'
export FZF_COMPLETION_TRIGGER="'"
# Use ag to list files
export FZF_DEFAULT_COMMAND='ag -l --follow --hidden --ignore ".git"'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
_fzf_compgen_path() {
eval "$FZF_DEFAULT_COMMAND . $1"
}
# git shortcuts
alias ga='git add'
alias gb='git branch'
alias gbd='git branch -D'
alias gc='git commit -m'
alias gco='git checkout'
alias gcb='git checkout -B'
alias gcm='git checkout master'
alias gc-='git checkout -'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gp='git pull'
alias grh='git reset HEAD~1'
alias gs='git status'
gmm() {
git checkout master
git pull
git checkout -
git merge master
}
# Path
export PATH="/opt/homebrew/bin:$PATH"