-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
201 lines (159 loc) · 5.03 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Configs
export EDITOR='vim'
# Disable XON/XOFF
stty -ixon
# Install zplug if not presente
if [[ ! -d ~/.zplug ]]; then
git clone https://github.com/zplug/zplug ~/.zplug
source ~/.zplug/init.zsh && zplug update --self
fi
# Source zplug/zplug
source ~/.zplug/init.zsh
#
# Declare custom theme segments here
# https://github.com/Powerlevel9k/powerlevel9k#custom_command
#
custom::is_git() {
# See https://git.io/fp8Pa for related discussion
[[ $(command git rev-parse --is-inside-work-tree 2>/dev/null) == true ]]
}
custom_dir() {
local 'dir' 'trunc_prefix'
# Threat repo root as a top-level directory or not
if custom::is_git; then
local git_root=$(git rev-parse --show-toplevel)
dir="$git_root:t${${PWD:A}#$~~git_root}"
else
dir="%~"
fi
echo "$dir"
}
###########
# PLUGINS #
###########
# oh-my-zsh
export ZSH=$HOME/.zplug/repos/robbyrussell/oh-my-zsh
zplug "plugins/gnu-utils", from:oh-my-zsh
# zplug "plugins/archlinux", from:oh-my-zsh, if:"which pacman"
zplug "plugins/systemd", from:oh-my-zsh, if:"which systemctl"
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/grep", from:oh-my-zsh
# zplug "plugins/colored-man-pages", from:oh-my-zsh
zplug "plugins/docker", from:oh-my-zsh
zplug "plugins/node", from:oh-my-zsh
zplug "plugins/npm", from:oh-my-zsh
zplug "plugins/yarn", from:oh-my-zsh
# zplug "plugins/rsync", from:oh-my-zsh
zplug "plugins/sudo", from:oh-my-zsh
# #zplug "plugins/tmux", from:oh-my-zsh
zplug "plugins/ruby", from:oh-my-zsh
zplug "plugins/rails", from:oh-my-zsh
zplug "plugins/bundler", from:oh-my-zsh
# zsh-user
zplug "zsh-users/zsh-completions", defer:3
zplug "zsh-users/zsh-syntax-highlighting", defer:3
zplug "zsh-users/zsh-autosuggestions", defer:3
zplug "zsh-users/zsh-history-substring-search", defer:2
# fzy
zplug "aperezdc/zsh-fzy"
# theme
POWERLEVEL9K_MODE='awesome-fontconfig'
# POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context ssh custom_dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time)
POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
POWERLEVEL9K_SHORTEN_DIR_LENGTH=3
export DEFAULT_USER="$USER"
zplug "bhilburn/powerlevel9k", use:powerlevel9k.zsh-theme
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Then, source plugins and add commands to $PATH
zplug load # --verbose
# Autocomplete from man pages
#zstyle ':completion:*:manuals' separate-sections true
#zstyle ':completion:*:manuals.*' insert-sections true
#zstyle ':completion:*:man:*' menu yes select
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
source $ZSH/oh-my-zsh.sh
# zsh-fzy
# ALT-C: cd into the selected directory
bindkey '\ec' fzy-cd-widget
# CTRL-T: Place the selected file path in the command line
zstyle :fzy:file command rg --files
bindkey '^T' fzy-file-widget
# CTRL-R: Place the selected command from history in the command line
# bindkey '^R' fzy-history-widget
# CTRL-P: Place the selected process ID in the command line
bindkey '^P' fzy-proc-widget
# direnv
eval "$(direnv hook zsh)"
# fzf
source '/usr/share/fzf/key-bindings.zsh'
# Less
export LESS='--RAW-CONTROL-CHARS --LINE-NUMBERS --no-init'
# fasd
eval "$(fasd --init auto)"
alias v='f -e vim'
# thefuck
eval $(thefuck --alias)
# yarn
export PATH="$(yarn global bin):$PATH"
# Encoding stuff for the terminal
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# local bins
export PATH="$HOME/.local/bin:$PATH"
# Local config
[[ -f ~/.local/.zshrc ]] && source ~/.local/.zshrc
# aliases
[[ -f ~/.aliases ]] && source ~/.aliases
[[ -f ~/.local/.aliases ]] && source ~/.local/.aliases
########################################### testing
# Apply changes to keyboard key mapping
# (removed due to it turning on and off randomly)
# xmodmap ~/.Xmodmap
##########################################
#######################################
# Some usefull kubectl commands
#######################################
function kube-find-namespace() {
kubectl get namespaces | tail -n +2 | fzf -q "$1" | awk '/(.*)/ {print $1}'
}
function kube-app-pod() {
local namespace
namespace=$1
kubectl get pods --field-selector status.phase=Running -n "$namespace" | awk '/(.*)-app-(.*) / {print $1}' | head -n 1
}
function kube-rc() {
local namespace
namespace="$(kube-find-namespace "$1")"
local pod
pod="$(kube-app-pod "$namespace")"
echo "Dropping into rails console on $pod in $namespace"
kubectl exec -it "$pod" -n "$namespace" -- rails c
}
function kube-ssh() {
local namespace
namespace="$(kube-find-namespace "$1")"
local pod
pod="$(kube-app-pod "$namespace")"
echo "Dropping into bash on $pod in $namespace"
kubectl exec -it "$pod" -n "$namespace" bash
}
function kube-log() {
local namespace
namespace="$(kube-find-namespace "$1")"
local pod
pod="$(kube-app-pod "$namespace")"
echo "Tailing logs on $pod in $namespace"
kubectl logs "$pod" -n "$namespace" -f
}
alias kssh="kube-ssh"
alias krc="kube-rc"
alias klog="kube-log"