-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
142 lines (122 loc) · 4.14 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
#
# ~/.zshrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export EDITOR=emacs
export GIT_EDITOR=vim
export BROWSER=chromium
export PATH="/home/luc/.local/bin/:${PATH}"
# Prompt:
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function parse_git_branch() {
(command git symbolic-ref -q HEAD || command git name-rev --name-only --no-undefined --always HEAD) 2>/dev/null
}
function parse_git_dirty() {
if command git diff-index --quiet HEAD 2>/dev/null; then
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
else
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
fi
}
setopt prompt_subst
ZSH_THEME_GIT_PROMPT_CLEAN="%{%F{green}%}✔ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{%F{red}%}✗ %{$reset_color%}"
#ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✔ %{$reset_color%}"
#ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✗ %{$reset_color%}"
PROMPT='%{%F{white}%}[ %{%F{blue}%}%n@%m %{%F{white}%}%~%{%F{red}%} $(git_prompt_info) $(parse_git_dirty)%{%F{white}%}] %{%F{reset}%}$ '
#PS1='[\u@\h \W]\$ '
# Aliases:
alias ls='ls --color=auto --human-readable --group-directories-first'
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -iv'
alias ln='ln -v'
alias chmod='chmod -c'
alias chown='chown -c'
alias grep='egrep --colour=auto'
alias su='su -'
alias I='nix-env --install'
alias R='nix-env --uninstall'
alias U='sudo nixos-rebuild test'
alias UU='sudo nixos-rebuild switch'
alias S='nix-env -qaP | grep'
alias tree='tree -C'
alias shutdown='sudo shutdown -h 0'
alias yt='youtube-viewer'
alias xssh='ssh -YC -c blowfish-cbc,arcfour'
# Better ls colors in terminal
export CLICOLOR=TRUE
export LSCOLORS=Gxfxbxdxcxegedabagacad
# Zsh options:
# Tab completion + load theme
autoload -U compinit promptinit colors
compinit
promptinit
# Alias autocompletion
setopt completealiases
# Extended globbing (completion)
setopt extendedglob
# Parameter/arithmetic expansion + command substitution
setopt promptsubst
# No flowcontrol
setopt noflowcontrol
# Ignore lines starting with #
setopt interactivecomments
# Case-insensitive (uppercase from lowercase) completion
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-slashes 'yes'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# History:
HISTFILE=~/.zsh_history
HISTSIZE=3000
SAVEHIST=3000
# History options:
setopt incappendhistory \
extendedhistory \
histfindnodups \
histreduceblanks \
histignorealldups \
histsavenodups
# Add extra specific keys:
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# Key bindings:
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
bindkey '^Y' yank
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# Check if terminal is in application mode:
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
printf '%s' "${terminfo[smkx]}"
}
function zle-line-finish () {
printf '%s' "${terminfo[rmkx]}"
}
zle -N zle-line-init
zle -N zle-line-finish
fi
# NOTE: requires https://github.com/zsh-users/zsh-syntax-highlighting
source ~/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh