-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shell.rc.sh
170 lines (145 loc) · 4.36 KB
/
.shell.rc.sh
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
# User config paths
export PATH=$HOME/.bin:$HOME/bin:$HOME/.local/bin:$PATH
# rust env setup
[ -s "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
[ -s "$HOME/.shell.secret.sh" ] && source $HOME/.shell.secret.sh
[ -s "$HOME/.shell.device.sh" ] && source $HOME/.shell.device.sh
# NVM config
export NVM_NODEJS_ORG_MIRROR=https://mirrors.ustc.edu.cn/node/
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
# deno config
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
# editor
export VISUAL=nvim
export EDITOR=nvim
alias v='nvim'
alias s="kitten ssh"
alias lg='lazygit'
alias t='tmux'
# fzf config
if [ -n "$ZSH_VERSION" ]; then
# assume Zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
elif [ -n "$BASH_VERSION" ]; then
# assume Bash
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
else
# assume something else
[ -z 0]
fi
_zsh_ifdo() {
if [ -n "$ZSH_VERSION" ]; then
$*
fi
}
# iterm2 config load
[ -n "$ZSH_VERSION" ] &&
[ -s "${HOME}/.iterm2_shell_integration.zsh" ] &&
source "${HOME}/.iterm2_shell_integration.zsh"
# Global functions (aka complex aliases) {{{
function f {
find . -type f | grep -v .svn | grep -v .git | grep -i $1
}
function fzfo() {
file=$(fzf)
dirname=$(dirname $file)
cd $dirname
}
function config-github-user-global() {
git config --global user.name kyle.tk
git config --global user.email 62560852@qq.com
git config --global core.quotePath false
}
function config-github-user-local() {
git config --local user.name kyle.tk
git config --local user.email 62560852@qq.com
}
# }}}
# see http://github.com/durdn/cfg/
# durdn/cfg related commands {{{
alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
alias lazyconfig='lazygit --git-dir=$HOME/.cfg/ --work-tree=$HOME'
# zsh completion for config command. Treat 'config' as git
_zsh_ifdo compdef config=git
function _dur {
case $1 in
create | cr)
echo "disabled"
;;
list | li)
curl --user $2:$3 https://api.bitbucket.org/1.0/user/repositories 2>/dev/null | grep "name" | sed -e 's/\"//g' | col 2 | sort | uniq | column
;;
clone | cl)
git clone git@bitbucket.org:durdn/$2.git
;;
move | mv)
git remote add bitbucket git@bitbucket.org:durdn/$(basename $(pwd)).git
git push --all bitbucket
;;
trackall | tr)
#track all remote branches of a project
for remote in $(git branch -r | grep -v master); do git checkout --track $remote; done
;;
key | k)
#track all remote branches of a project
ssh $2 'mkdir -p .ssh && cat >> .ssh/authorized_keys' <~/.ssh/id_rsa.pub
;;
fun | f)
#list all custom bash functions defined
typeset -F | col 3 | grep -v _ | xargs | fold -sw 60
;;
def | d)
#show definition of function $1
typeset -f $2
;;
help | h | *)
echo "[dur]dn shell automation tools - (c) 2011 Nicola Paolucci nick@durdn.com"
echo "commands available:"
echo " [cr]eate, [li]st, [cl]one"
echo " [i]nstall,[m]o[v]e, [re]install"
echo " [f]fun lists all bash functions defined in .bashrc"
echo " [def] <fun> lists definition of function defined in .bashrc"
echo " [k]ey <host> copies ssh key to target host"
echo " [tr]ackall], [h]elp"
;;
esac
}
# }}}
# OSX specific config {{{
if [ $(uname) = "Darwin" ]; then
#aliases {{{
# }}}
#open macvim
function gvim {
if [ -e $1 ]; then
open -a MacVim $@
else
touch $@ && open -a MacVim $@
fi
}
#open visual studio code
function vsc {
if [ -e $1 ]; then
open -a Visual\ Studio\ Code $@
else
touch $@ && -a Visual\ Studio\ Code $@
fi
}
#homebrew git autocompletions {{{
if [ -f $(brew --prefix)/etc/bash_completion.d/git-completion.bash ] && [ -n "$BASH_VERSION" ]; then
. $(brew --prefix)/etc/bash_completion.d/git-completion.bash
fi
#}}}
eval "$(/opt/homebrew/bin/brew shellenv)"
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
fi
# }}}