-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh-config.zsh
executable file
·142 lines (103 loc) · 3.99 KB
/
zsh-config.zsh
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
#! /bin/zsh
# SHELL_CONFIG_DIR this need to point to the repo folder this file is in. The scirpt rely on this
# to find relative file location
[ -z ${SHELL_CONFIG_DIR+x} ] && SHELL_CONFIG_DIR="$(dirname $(realpath $0))"
#########################################
# Setup antigen
source ${SHELL_CONFIG_DIR}/antigen.zsh
antigen init ${SHELL_CONFIG_DIR}/antigenrc
#########################################
#########################################
# These are settings for oh my zsh
export ZSH="${HOME}/.oh-my-zsh"
ZSH_THEME_RANDOM_CANDIDATES=(
"avit" "bira" "fishy" "gnzh")
ZSH_THEME=random
HYPHEN_INSENSITIVE="true"
COMPLETION_WAITING_DOTS="true"
source $ZSH/oh-my-zsh.sh
######################################
######################################
# Configure and Enable CD history.
# source: https://unix.stackexchange.com/a/157773
setopt AUTO_PUSHD # pushes the old directory onto the stack
# PushHD Minus is a matter of persional taste, and I don't think this change anything on my machine.
# setopt PUSHD_MINUS # exchange the meanings of '+' and '-'
setopt CDABLE_VARS # expand the expression (allows 'cd -2/<subfolder>')
autoload -U compinit && compinit # load + start completion
zstyle ':completion:*:directory-stack' list-colors '=(#b) #([0-9]#)*( *)==95=38;5;12'
# Config No glob match behavior. I want it more like bash, pass the glob down.
# Source: https://superuser.com/a/982399
# This change the default NOMATCH to off,
# and pass the glob down instead of throwing error
setopt NO_NOMATCH
# Short cuts to remember:
# ctrl q : push-input - push the entire input (multi-line) onto a stach. And pop back into
# command prompt after a command
# explain: https://sgeb.io/posts/bash-zsh-half-typed-commands/
######################################
######################################
# special fix for systemd
_systemctl_unit_state() {
typeset -gA _sys_unit_state
_sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" | awk '{print $1, $2}') ) }
######################################
######################################
# Source my custom helper
# These need to be sourced early so I can use the inner functions
source ${SHELL_CONFIG_DIR}/setup-shell-helpers.sh
######################################
######################################
# External tools, changing system editor/pager/etc
export EDITOR='micro' # always default to micro first
# Setting for using editor
if [[ -z ${SSH_CONNECTION+x} ]]; then
# # Case of non ssh, try to use vscode as editor
# [ -n $(command -v code) ] && export EDITOR='code --wait'
#
export EDITOR='micro'
else
# Case of ssh connection
LIBGL_ALWAYS_INDIRECT=1
fi
# Change pager to most if it exists
if type most > /dev/null; then
export PAGER="most"
fi
# enable mcfly
if type mcfly > /dev/null; then
eval "$(mcfly init zsh)"
export MCFLY_FUZZY=2
export MCFLY_RESULTS=30
fi
######################################
######################################
# Section for adding additional PATH.
# Seems like zsh doesnt auto add ~/.local/bin
# set PATH so it includes user's private ~/.local/bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# Specific one for rust cargo
if [ -f "$HOME/.cargo/env" ] ; then
source "$HOME/.cargo/env"
fi
# Add emcas bin folder if exits
if [ -d "$HOME/.config/emacs/bin" ] ; then
PATH="$HOME/.config/emacs/bin:$PATH"
fi
######################################
######################################
# Alias
alias pssh="parallel-ssh"
alias bat="batcat"
######################################
######################################
# Additional notes:
# To get python arg completion, the following packages are needed
# argcomplete
# Then this command needs to be executed to register into zshenv `activate-global-python-argcomplete`
# To get rclone tab complete,
# sudo rclone genautocomplete zsh
# Also if not done before, `/usr/share/zsh/vendor-completions` folder needs to be manually created.
######################################