-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
executable file
·250 lines (216 loc) · 6.25 KB
/
config.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
fishconfig() {
if [ ! -f ~/.config/fish/config.fish ]; then
mv ~/.config/fish/config.fish{,.bak}
fi
#autojump
echo "正在安装autojump.fish"
git clone https://github.com/wting/autojump.git
cd autojump
./install.py
echo "正在配置fish"
cat > ~/.config/fish/config.fish << 'EOF'
alias sudo "sudo "
alias j "autojump"
alias r "ranger"
alias p "ps aux"
alias cp "cp -i"
alias c "curl -LO"
alias rm "rm -i"
alias grep "egrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}"
alias df "df -h"
alias free "free -hw"
alias v "nvim"
alias w "watch -d -n 2"
alias ifconfig "ifconfig -a"
alias cplast "history | tail -n 1 | cut -c8- | clip"
alias r "ranger"
alias sl "systemctl"
alias sls "systemctl status"
alias slr "systemctl restart"
alias sle "systemctl enbale"
alias sld "systemctl stop"
alias jl "journalctl"
alias error "journalctl -fp err"
# git
alias lg 'lazygit'
alias gc 'git clone'
alias ga 'git add --all'
alias gm 'git commit -m '
alias gp 'git push'
alias gl 'git log'
alias gb 'git branch'
alias gs 'git status'
# alias grhh "git reset --hard $(git log | awk 'NR 1{print $2}')"
# docker
alias dil 'sudo docker image ls'
alias dip 'sudo docker image pull'
alias dir 'sudo docker image rm'
alias dcl 'sudo docker container ls'
alias dcrun 'sudo docker container run'
alias dccp 'sudo docker container cp'
alias dck 'sudo docker container kill'
alias dcs 'sudo docker container stop'
# export
export CDPATH="/home/tz:/home/tz/.config:/etc"
export PATH="/root/.mybin:$PATH"
set -x nvim ~/.config/nvim/init.vim
set -x fish ~/.config/fish/config.fish
source ~/.autojump/share/autojump/autojump.fish
EOF
source ~/.config/fish/config.fish
}
nvimconfig(){
if [ ! -d ~/.config/nvim ]; then
mkdir ~/.config/nvim
else
datetime=$(date +%D)
mv ~/.config/nvim{,.$datetime}
mkdir ~/.config/nvim
fi
if [ vim --version | grep '\-clipboard' ];then
yum install -y vim-X11
fi
echo "正在配置neovim"
cat > ~/.config/nvim/init.vim << 'EOF'
syntax on
filetype plugin on
let g:mapleader = ","
set smartcase "小写包含大写
set lazyredraw "不要在宏和脚本执行期间更新屏幕。
set cursorline "突出显示当前在光标下的行。
set number "显示行号
set relativenumber "相对行号
set cursorline "突出显示当前在光标下的行。
set wrap "自动折行,即太长的行分成几行显示
set showmatch "自动高亮对应的另一个圆括号、方括号和大括号。
set showcmd "显示输入key
set undofile "保留撤销历史。
set autochdir "自动切换工作目录
set autoread "文件发生外部改变就会发出提示
set ignorecase "不区分大小写
set list "开启空格字符
set listchars=tab:»·,trail:· "空格显示为·
set path+=** "find 子目录
set clipboard+=unnamedplus "直接复制剪切板
set autoread "文件发生外部改变就会发出提示
set background=dark "黑背景
" set noswapfile "Disable swap files.
"分屏
nmap <Tab> :wincmd w <cr>
nmap <Leader>sw :only <cr>
nmap <Leader>so :only <cr>
nmap <Leader>sh :vsplit <cr>
nmap <Leader>sk :split <cr>
nmap <Leader>sl :belowright vsplit <cr>
nmap <Leader>sj :belo split <cr>
" incert keymap like emacs
imap <C-h> <BS>
imap <C-d> <Del>
imap <C-w> <C-[>diwa
imap <C-k> <Esc>lDa
imap <C-u> <Esc>d0xi
imap <C-y> <Esc>Pa
imap <C-b> <Left>
imap <C-f> <Right>
imap <C-a> <Home>
imap <C-n> <Down>
imap <C-p> <Up>
imap <C-z> <ESC>ua
imap <C-o> <Esc>o
imap <C-s> <esc>:w<CR>
imap <C-q> <esc>:wq<CR>
imap <expr><C-e> pumvisible() ? "\<C-e>" : "\<End>"
imap <leader>j <Esc>wi
imap <leader>k <Esc>bi
" command keymap like emacs
cmap <C-p> <Up>
cmap <C-k> <Up>
cmap <C-n> <Down>
cmap <C-j> <Down>
cmap <C-b> <Left>
cmap <C-f> <Right>
cmap <C-a> <Home>
cmap <C-e> <End>
cmap <C-d> <Del>
cmap <C-h> <BS>
cmap <C-t> <C-R>=expand("%:p:h") . "/" <CR>
tnoremap <A-[> <C-\><C-n>
nmap q :q <CR>
nmap Q q
nmap j gj
nmap k gk
nmap \ :%s//g<Left><Left>
vmap \ :s//g<Left><Left>
nmap <space> `
nmap ' "
nmap <C-y> "0p
vmap <C-y> "0p
nmap Y y$
nmap yu y0
nmap E v$h
nmap B vb
nmap <leader>w :w<CR>
" Run the current line
nmap <leader>ee :execute getline(line('.'))<cr>
" Run the current line in sh
nmap <leader>il :execute '!'.getline('.')<cr>
nmap <leader>u :<C-U><C-R>=printf("nohlsearch %s", "")<CR><CR>
" file manager
nmap <leader>fr :terminal ranger<CR>
" buffers
nmap <leader>1 :buffer1<cr>
nmap <leader>2 :buffer2<cr>
nmap <leader>3 :buffer3<cr>
nmap <leader>4 :buffer4<cr>
nmap <leader>5 :buffer5<cr>
nmap <leader>6 :buffer6<cr>
nmap <leader>7 :buffer7<cr>
nmap <leader>8 :buffer8<cr>
nmap <leader>9 :buffer9<cr>
nmap <leader>b :buffers<cr>
nmap <leader>n :bnext<cr>
nmap <leader>p :bprevious<cr>
nmap <Leader>x :bw<cr>
nmap <a-1> :buffer1<cr>
nmap <a-2> :buffer2<cr>
nmap <a-3> :buffer3<cr>
nmap <a-4> :buffer4<cr>
nmap <a-5> :buffer5<cr>
nmap <a-6> :buffer6<cr>
nmap <a-7> :buffer7<cr>
nmap <a-8> :buffer8<cr>
nmap <a-9> :buffer9<cr>
nmap <leader>tt :tabnew<cr>
nmap <C-w> :tabclose<cr>
nmap L :tabnext<cr>
nmap H :tabprevious<cr>
" nmap <C-w> :bw<cr>
" nmap L :bnext<cr>
" nmap H :bprevious<cr>
" vmap
vmap ,' <esc>`>a'<esc>`<i'<esc>
vmap ," <esc>`>a"<esc>`<i"<esc>
vmap ,( <esc>`>a)<esc>`<i(<esc>
vmap ,[ <esc>`>a]<esc>`<i[<esc>
vmap ,<space> <esc>`>a<space><esc>`<i<space><esc>
vmap ,d <esc>`>a` <esc>`<i `<esc>
vmap ,c <esc>`>a<enter>```<esc>`<i```<enter><esc>kA
vmap ,i <esc>`>a*<esc>`<i*<esc>
vmap ,b <esc>`>a**<esc>`<i**<esc>
" snap
autocmd Filetype * inoremap <buffer> ,, <Esc>/<++><CR>:nohlsearch<CR>"_c4l
autocmd Filetype * vnoremap ,<space> <esc>`>a<space><esc>`<i<space><esc>
autocmd Filetype * vnoremap s' <esc>`>a'<esc>`<i'<esc>
autocmd Filetype * vnoremap s" <esc>`>a"<esc>`<i"<esc>
autocmd Filetype * vnoremap s) <esc>`>a)<esc>`<i(<esc>
autocmd Filetype * vnoremap s] <esc>`>a]<esc>`<i[<esc>
autocmd Filetype * vnoremap s} <esc>`>a}<esc>`<i{<esc>
autocmd Filetype * vnoremap s/ <esc>`>a/<esc>`<i/<esc>
EOF
}
case $1 in
fishconfig ) fish;;
nvimconfig ) nvim;;
* ) echo "$i还有收录";;
esac