-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
165 lines (138 loc) · 4.66 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
# vim:fdm=marker
# echo $PATH | tr ":" "\n"
# zmodload zsh/zprof
# Spack and Lmod {{{
if [ -f $HOME/sw/spack/share/spack/setup-env.sh ]; then
# Get lmod path with `$(spack location -i lmod)`.
lmod_path="$HOME/sw/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/lmod-7.8.15-oq3ljl2vcih7w5y4piibmgi2zsxs3n3h"
export MODULEPATH="$HOME/sw/modulefiles/Core:$MODULEPATH"
source $HOME/sw/spack/share/spack/setup-env.sh
#source ${lmod_path}/lmod/lmod/init/zsh
#source $HOME/sw/spack/share/spack/setup-env.sh
fi
# }}}
# Zplug {{{
source $HOME/.zplug/init.zsh
# Let zplug manage itself.
zplug 'zplug/zplug', hook-build:'zplug --self-manage'
# Completion settings.
zplug "lib/completion", from:oh-my-zsh
# Directory traversal options.
zplug "lib/directories", from:oh-my-zsh
# History options.
zplug "lib/history", from:oh-my-zsh
# Keybindings options.
zplug "lib/key-bindings", from:oh-my-zsh
# Add useful aliases and functions to work with git.
zplug "plugins/git", from:oh-my-zsh
# Autoload of the environment settings.
AUTOENV_FILE_ENTER=autoenv-enter.zsh
AUTOENV_FILE_LEAVE=autoenv-leave.zsh
zplug "Tarrasch/zsh-autoenv"
# Enable highlighing of commands whilst they are typed at a zsh prompt
# into an interactive terminal.
zplug "zsh-users/zsh-syntax-highlighting", defer:3
# Fish-like fast/unobtrusive autosuggestions for zsh.
# It suggests commands as you type based on history and completions.
zplug "zsh-users/zsh-autosuggestions"
zplug "spaceship-prompt/spaceship-prompt", use:spaceship.zsh, from:github, as:theme
zplug load
# }}}
# Environment variables {{{
if type nvim > /dev/null 2>&1; then
export EDITOR=nvim
else
export EDITOR=vim
fi
#export BROWSER=google-chrome
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export dev=~/Sync/dev
export APPS_DIR=/sw
# }}}
# Aliases {{{
alias -g L="| less -R"
alias -g LL="2>&1 | less -R"
alias .....='cd ../../../..'
alias ....='cd ../../..'
alias ...='cd ../..'
alias ..='cd ..'
alias echoldlibrarypath='echo $LD_LIBRARY_PATH | tr : "\n"'
alias echomanpath='echo $MANPATH | tr : "\n"'
alias echopath='echo $PATH | tr : "\n"'
alias ls='ls -G' # Colorize ls output
alias l='ls -lAhF'
alias notes='cd $HOME/Documents/Notes && vim'
alias posixtime='/usr/bin/time -p'
alias zshconfig="$EDITOR ~/.zshrc"
alias zshrestart="source ~/.zshrc"
if type nvim > /dev/null 2>&1; then
alias v='nvim'
fi
alias dateiso8601='date "+%Y-%m-%d"'
alias dtiso8601='date "+%Y-%m-%d_%H.%M.%S"' # e.g. 2024-01-02_14.16.27
# Tmux aliases.
alias tmat='tmux attach -t'
alias tmad='tmux attach -d -t'
alias tmns='tmux new-session -s'
alias tmls='tmux list-sessions'
alias tmks='tmux kill-session -t'
# }}}
# ZSH options {{{
# AUTOCD option lets you type the name of a directory to change into into it.
setopt autocd
setopt extendedglob
# Autocomplete filenames after = sign (e.g., in ./configure --prefix=PREFIX).
setopt magic_equal_subst
# }}}
# man customization {{{
man() {
# Attributes are set using escape sequences starting with `\e[`.
# Attributes codes can be found here:
# http://www.termsys.demon.co.uk/vtansi.htm
local mb=$(printf "\e[1;31m") # Begin blinking.
local md=$(printf "\e[1;31m") # Begin bold.
local me=$(printf "\e[0m") # End mode.
local so=$(printf "\e[7m") # Begin standout mode.
local se=$(printf "\e[0m") # End standout mode.
local us=$(printf "\e[4;32m") # Begin underline.
local ue=$(printf "\e[0m") # End underline.
env LESS_TERMCAP_mb=$mb \
LESS_TERMCAP_md=$md \
LESS_TERMCAP_me=$me \
LESS_TERMCAP_so=$so \
LESS_TERMCAP_se=$se \
LESS_TERMCAP_us=$us \
LESS_TERMCAP_ue=$ue \
MANWIDTH=80 \
man "$@"
}
# }}}
# Dircolors for `ls` and `grep` {{{
if [ -x /usr/bin/dircolors -a -r $HOME/.dircolors ]; then
eval "$(dircolors $HOME/.dircolors)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
fi
# }}}
# Starship prompt.
eval "$(starship init zsh)"
# Setup fuzzy search with FZF {{{
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND="fd --type f --exclude pCloud\ Drive --exclude sw --hidden"
export FZF_CTRL_T_COMMAND="fd --type f --exclude pCloud\ Drive --exclude sw --hidden"
export FZF_ALT_C_COMMAND="fd --type d --exclude pCloud\ Drive --exclude sw --hidden"
# }}}
fpath=(~/.zsh $fpath)
# stt - set tab title
# Sets terminal tab title, particularly for Gnome Terminal that does not
# have GUI functionality for this.
function stt() {
# Options for echo:
# `-n` do not add a new line character in the end
# `-e` interpret escape sequences (character sequences starting with \)
echo -ne "\033]0;$*\007"
}
if [ -e "$HOME/.zshrc.local" ]; then
. "$HOME/.zshrc.local"
fi