-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
148 lines (120 loc) · 4.45 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
##############################
# #
# OH-MY-ZSH CONFIG #
# #
##############################
export ZSH=~/.oh-my-zsh
ZSH_THEME="robbyrussell"
HYPHEN_INSENSITIVE="true"
HIST_STAMPS="dd.mm.yyyy"
plugins=(docker git vi-mode zsh-syntax-highlighting)
setopt correct
source $ZSH/oh-my-zsh.sh
export SSH_KEY_PATH="~/.ssh/rsa_id"
export EDITOR='vim'
# Diable vi-mode translating shift-tab to esc.
bindkey '^[[Z' reverse-menu-complete
##############################
# #
# ALIASES #
# #
##############################
alias vim="nvim"
alias day="base16_atelier-forest-light"
alias night="base16_materia"
alias randomtheme="ls ~/.config/base16-shell/scripts/*.sh | shuf -n 1 | xargs -i -- echo echo 'Switching to random theme: ' {}\; source {} | bash"
alias killp="bash ~/Documents/GitHub/Scripts/scripts/killp/killp.sh"
##############################
# #
# CUSTOM FUNCTIONS #
# #
##############################
# Create and go to dir
function mkcdir {
mkdir -p -- "$1" &&
cd -P -- "$1"
}
# Wrap tmux-template script in a function for compatibility with autocompletion
function tmux-template {
bash ~/Documents/GitHub/Scripts/tmux-sessions/tmux-template.sh $*
}
# Set up autocomplete for tmux-template
function _tmux_template_options {
local -a options
options=("capra" "easybudget" "riot" "samf" "thesis")
_describe "values" options
}
compdef _tmux_template_options tmux-template
# Remap keys on Logitech K811 Bluetooth keyboard to match ThinkPad T460
# Remap <Shift>4 to '$'
function configure_k811_bluetooth_keyboard {
local k811_keyboard_id=$(xinput | egrep 'Logitech K811' | sed -r 's/^.*id=([0-9]+).*/\1/g')
if [ "$k811_keyboard_id" ]; then
# xdotool has to fake a button press for the changes to stick
# Ref. https://bugs.freedesktop.org/show_bug.cgi?id=91571
setxkbmap -device $k811_keyboard_id -print | \
sed 's/\(xkb_keycodes.*\)"/\1+custom(k811)"/' | \
sed 's/\(xkb_symbols.*\)"/\1+custom(mac)"/' | \
xkbcomp -I$HOME/dotfiles/xkb -i $k811_keyboard_id -synch - $DISPLAY &>/dev/null && \
xdotool key Ctrl || echo "Failed to set up mappings for K811 Bluetooth keyboard"
fi
}
# Global remap of '<Shift>4' to '$'
function configure_keyboard {
setxkbmap -print | \
sed 's/\(xkb_symbols.*\)"/\1+custom(mac)"/' | \
xkbcomp -I$HOME/dotfiles/xkb -synch - $DISPLAY &>/dev/null && \
xdotool key Ctrl || echo "Failed to map '<Shift>4' to '$'"
}
# These two functions must be run in this exact order to avoid overwriting each other's settings
configure_keyboard
configure_k811_bluetooth_keyboard
# Do not log jrnl entries
setopt HIST_IGNORE_SPACE
alias jrnl=" jrnl"
function log_question {
echo $1
read
jrnl today: ${1}. $REPLY
}
##############################
# #
# MISC. #
# #
##############################
# Configure base16-shell
BASE16_SHELL=$HOME/.config/base16-shell/
[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"
# Set default theme for base16-shell
[ ! -e ~/.base16_theme ] && night
# Add global yarn binary to PATH if it exists
if which yarn &> /dev/null; then
export PATH="$PATH:$(yarn global bin)"
fi
# Configure fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='ag --hidden --ignore-dir={.cache,.git,node_modules} -g ""'
export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND
##############################
# #
# VERSION MANAGERS #
# #
##############################
# Configure nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# Add RVM to PATH for scripting.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
# Add pyenv to path
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# https://medium.com/@henriquebastos/the-definitive-guide-to-setup-my-python-workspace-628d68552e14
export WORKON_HOME=~/.ve
export PROJECT_HOME=~/pyworkspace
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv virtualenvwrapper_lazy
# Needs to be done after pyenv setup, as it is as python package
eval $(thefuck --alias)