summaryrefslogtreecommitdiff
path: root/terminal/dot-zshrc
blob: 3258454cd4db966e1880237f8e0c9dbd66172293 (plain)
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
export LANG=en_US.UTF-8
export EDITOR=nvim

# Set editor default keymap to emacs (`-e`) or vi (`-v`)
bindkey -e

export HISTFILE=~/.zsh_history
export HISTSIZE=268435456
export SAVEHIST="$HISTSIZE"

setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_VERIFY
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
setopt NO_NOMATCH

# Remove path separator from WORDCHARS.
WORDCHARS=${WORDCHARS//[\/]}

# -----------------
# Zim configuration
# -----------------

setopt nopromptbang prompt{cr,percent,sp,subst}

zstyle ':zim:git-info' verbose yes
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:stashed' format '%F{#40995A}%S%f'
zstyle ':zim:git-info:dirty' format '%F{red}⚡%f'
zstyle ':zim:git-info:clean' format '%F{green}✓%f'
zstyle ':zim:git-info:indexed' format '%F{#F88C15}✚%f'
zstyle ':zim:git-info:untracked' format '%F{red}✹%f'
zstyle ':zim:git-info:keys' format 'prompt' '  %b%c %D%S%C%i%u '

zstyle ':zim:prompt-pwd' git-root no
zstyle ':zim:prompt-pwd:tail' length 2

autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info

# PS1='%K{#5F87AF}%F{yellow}  $(prompt-pwd) %f%k%F{blue}%K{yellow}${(e)git_info[prompt]}%k%f %B%(?:%F{green}:%F{red})%{%G➤%}%b '
PS1='%F{#F88C15}@${(%):-%m} %F{yellow} $(prompt-pwd) %f%F{#AACCFF}${(e)git_info[prompt]}%f %B%(?:%F{green}:%F{red})%{%G➤%}%b '

# termtitle

# Set a custom terminal title format using prompt expansion escape sequences.
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
# If none is provided, the default '%n@%m: %~' is used.
# zstyle ':zim:termtitle' format '%1~'

# zsh-autosuggestions

# Disable automatic widget re-binding on each precmd. This can be set when
# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc.
ZSH_AUTOSUGGEST_MANUAL_REBIND=1

# Customize the style that the suggestions are shown with.
# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242'

# zsh-syntax-highlighting

# Set what highlighters will be used.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)

# Customize the main highlighter styles.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
# typeset -A ZSH_HIGHLIGHT_STYLES
# ZSH_HIGHLIGHT_STYLES[comment]='fg=242'

# ------------------
# Initialize modules
# ------------------

ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Download zimfw plugin manager if missing.
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
  if (( ${+commands[curl]} )); then
    curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
        https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
  else
    mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \
        https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
  fi
fi
# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
  source ${ZIM_HOME}/zimfw.zsh init -q
fi
# Initialize modules.
source ${ZIM_HOME}/init.zsh

# ------------------------------
# Post-init module configuration
# ------------------------------

# zsh-history-substring-search

zmodload -F zsh/terminfo +p:terminfo
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up
for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down
for key ('k') bindkey -M vicmd ${key} history-substring-search-up
for key ('j') bindkey -M vicmd ${key} history-substring-search-down
unset key

# ------------------------------
# My Stuff
alias grep='grep --color=auto'
alias ip='ip -color=auto'
alias xproxy='ssh -N -D 9090 illyria'
alias gk='gitk --all &'
alias ls='exa --icons'
alias tree='exa --icons --tree'
alias undercurl='echo -e "\e[4:3mUNDERCURL!"'

alias mpd-start='systemctl start --user mpd'

alias nocontrol="rm ~/.ssh/control:*"
alias mute_notifications="dunstify 'Muting notifications' && sleep 2 && dunstctl set-paused true"
alias unmute_notifications="dunstctl close-all && dunstctl set-paused false && dunstify 'Notifications unmutted'"

eval "$(zoxide init zsh --cmd cd)"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# Source: https://github.com/rvm/rvm/issues/3212#issuecomment-274912875
# Squelch the warning by appending ' > /dev/null 2>&1' here
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" > /dev/null 2>&1

# RVM fixes whatever it considers the problem to be, on its own, in `rvm use`.
# It also prints some junk we don't care about, so we squelch its output in the same way.
rvm use default > /dev/null 2>&1

export ZK_NOTEBOOK_DIR="$HOME/Documents/zk"
fpath+=${ZDOTDIR:-~}/.zsh_functions