-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
73 lines (62 loc) · 2.32 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
eval "$(starship init zsh)"
# history-related settings for zsh
# src: https://www.soberkoder.com/better-zsh-history/
# ref: https://zsh.sourceforge.io/Doc/Release/Options.html
export HISTFILESIZE=200000
export HISTSIZE=200000
export SAVEHIST=100000
export HISTTIMEFORMAT="[%F %T] "
setopt SHARE_HISTORY # all sessions write to history as and when the command happens
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE # if the first char is a space don't save command to history
setopt HIST_EXPIRE_DUPS_FIRST
# normal output in ansible (not cowsay)
export ANSIBLE_NOCOWS=1
# aliases
alias ls='lsd'
alias gfp='git fetch --prune'
alias gpfp='git pull && git fetch --prune'
alias df='duf'
# functions
# indeed cd
function icd {
# cd $(find ~/indeed -mindepth 2 -maxdepth 2 -type d -name "$1")
cd $(fd --exact-depth 2 -t d ... ${HOME}/indeed | fzf)
}
# fzf cd
function fcd {
cd $(fd -t d . | fzf)
}
# gurl -> git url -> print URL of file passed as argument
function gurl {
REPO=$(git remote get-url origin | sed 's/^git@//g' | sed 's/.git$//g' | sed 's/\:/\//g')
FILE_PATH_IN_REPO=$(git ls-files --full-name $1)
CURRENT_BRANCH=$(git branch --show-current)
echo "https://${REPO}/-/tree/${CURRENT_BRANCH}/${FILE_PATH_IN_REPO}"
}
# gurlo -> gurl open -> git url open
function gurlo {
open $(gurl $1)
}
# imports
source /opt/homebrew/Cellar/git-extras/7.2.0/share/git-extras/git-extras-completion.zsh
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# kubectl aliases
alias kubectl='grc kubectl' # generic colorizer
alias k='kubectl'
alias kc='kubectx'
alias kn='kubens'
# faster than the ketall plugin. stolen from a colleague who I won't name without checking with them first
function kga {
namespaced_resources() {
kubectl api-resources --cached --namespaced --verbs get --no-headers -o name |
grep -E -v '^events(\.events\.k8s\.io)?$' | grep -E -v 'externalmetrics'
}
kubectl get $(namespaced_resources | sort | paste -sd ,) "$@" 2> >(grep -v '^Error from server (Forbidden):' >&2)
}
# prevent the vi editor problem described at https://github.com/kubernetes/website/issues/674
export KUBE_EDITOR=emacsclient
# use bat to show pretty man pages
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
eval "$(zoxide init zsh)"