-
Notifications
You must be signed in to change notification settings - Fork 0
/
shrc
192 lines (150 loc) · 5.35 KB
/
shrc
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
export EDITOR=vim
_has() {
return $( which $1 &>/dev/null )
}
alias mkdir='mkdir -p'
alias which='type -a'
alias ls='ls --color'
# cd
alias ..2='cd ../..'
alias ..3='cd ../../..'
alias ..4='cd ../../../..'
alias ..5='cd ../../../../..'
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias cman='man -M /usr/share/man/zh_CN'
if _has vimx; then
alias vi='vimx'
alias vim='vimx'
export EDITOR=vimx
fi
alias tmux='tmux -2'
alias tree='tree -CN'
alias e='vim'
alias cls='clear'
# alias ip='colorize-ip'
alias ccat="highlight --out-format=xterm256"
# alias indent='indent -npro -gnu -i4 -ts4 -sob -l80 -ss -bl -bli 0 -npcs -npsl -nut'
alias indent='indent -npro -kr -i4 -ts4 -sob -l80 -ss -ncs -cp1 -il0'
# alias dstat='dstat -cdlmnpsy'
if _has delta; then
alias diff='delta'
else
alias diff='diff -urNwB'
fi
alias proxy="export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890"
alias unproxy="unset http_proxy https_proxy all_proxy no_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY NO_PROXY"
# command -v bat >/dev/null && alias cat='bat -p'
_has bat && alias less='bat -p'
_has btm && alias top='btm'
_has duf && alias df='duf'
_has viddy && alias watch='viddy'
# command -v lsd >/dev/null && alias ls='lsd'
# command -v rsync >/dev/null && alias scp='rsync -avuzP'
# alias starwars="telnet towel.blinkenlights.nl"
mkcd() { mkdir -p "$@" && cd "$_"; }
weath() { curl wttr.in/"$1" ;}
macinfo() { curl https://api.macvendors.com/"$1" ;}
# No args query myip info
ipinfo() { curl -L ipinfo.io/"$1" ;}
_has rg && export FZF_DEFAULT_COMMAND='rg --hidden -l ""'
_has tree && export FZF_ALT_C_OPTS="--preview 'tree -C {}'"
_has bat && export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always {}'"
yz() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd -- "$cwd"
fi
rm -f -- "$tmp"
}
# unalias z 2> /dev/null
# z() {
# [ $# -gt 0 ] && _z "$*" && return
# cd "$(_z -l 2>&1 | fzf --height 60% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')" || exit
# }
v() {
local files
files=$(grep '^>' ~/.viminfo | cut -c3- |
while read -r line; do
[ -f "${line/\~/$HOME}" ] && echo "$line"
done | fzf -d -m -q "$*" -1) && vim "${files//\~/$HOME}"
}
tm() {
if (( $# )); then
tmux has-session -t "$*" && tmux attach -t "$*" || tmux new-session -s "$*"
else
tmux attach || tmux new-session -s default
fi
}
alias i3keys='grep ^bindsym ~/.i3/config | fzf'
# fzf-locate() { xdg-open "$(locate "*" | fzf -e)" ; }
# fzf-cd() { cd "$(locate "*" | fzf -e)" ; }
te() { [ "$(gnuclient -batch -eval t 2>&-)" = "t" ] && gnuclient -q "$@" || ( xemacs "$@" &); }
firefox() { command firefox "$@" & }
evince() { command evince "$@" & }
zathura() { command zathura "$@" & }
shotwell() { command shotwell "$@" & }
office() { command libreoffice "$@" & }
# set -o vi # Shell is vi mode
# -i turns on "smartcase" search by default
export LESS="-iR"
# Enable colors for ls, etc. Prefer ~/.dir_colors
if _has dircolors; then
if [ -f ~/.dir_colors ]; then
eval "$(dircolors -b ~/.dir_colors)"
elif [ -f /etc/DIR_COLORS ]; then
eval "$(dircolors -b /etc/DIR_COLORS)"
else
dircolors -p > ~/.dir_colors
eval "$(dircolors -b ~/.dir_colors)"
fi
fi
export PATH="$HOME/.bin:/usr/local/sbin:$PATH"
# export BAT_THEME="Material-Theme-Darker"
export BAT_THEME="Dracula"
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
if [ -d "${HOME}/.devenv/go" ];then
export GOROOT="$HOME/.devenv/go"
export GOPATH="$HOME/workspace/go"
export GOBIN="$GOPATH/bin"
export PATH="$GOROOT/bin:$GOBIN:$PATH"
alias go_build_linux="CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build"
fi
# Make Python use UTF-8 encoding for output to stdin, stdout, and stderr.
export PYTHONIOENCODING='UTF-8'
if [ -d "$HOME/.nvm" ];then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
fi
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
if [ -d "$HOME/.jenv" ]; then
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
fi
export SDKMAN_DIR="$HOME/.sdkman"
[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ] && . "$HOME/.sdkman/bin/sdkman-init.sh"
export MACOS_JAVA_8_HOME=~/.devenv/jdk1.8.0_401.jdk/Contents/Home
export JAVA_HOME="$MACOS_JAVA_8_HOME"
# export MACOS_JAVA_17_HOME=~/.devenv/jdk-17.0.7.jdk/Contents/Home
# export JAVA_HOME="$MACOS_JAVA_17_HOME"
export PATH="$JAVA_HOME/bin:$PATH"
export M2_HOME="$HOME/.devenv/apache-maven-3.9.4"
export MAVEN_OPTS="-Xmx1024m"
export PATH="${M2_HOME}/bin:$PATH"
# export GRADLE_HOME="$HOME/.devenv/gradle-8.2.1"
# export GRADLE_HOME="$HOME/.devenv/gradle-6.9.3"
export GRADLE_HOME="$HOME/.devenv/gradle-8.5"
export PATH="${GRADLE_HOME}/bin:$PATH"
export PATH="$HOME/.bin:$HOME/.local/bin:$PATH"
eval "$(fzf --${SHELL##*/})"
eval "$(zoxide init ${SHELL##*/})"
# vim: set ft=sh syn=sh sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker: