实用工具

该工具箱, 用于存放博主工作生活中用到的软件工具, 不定期更新.

一、 hexdum 安装

有时需要将 bin 文件转换为十六进制数组, cscode 中的 hexdum 插件提供了快捷转换工具非常好用, 然而官方不在推荐该插件, 因此无法直接安装. 收录两篇有用的博客提供安装教程.

1
2
https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-hexdump
https://blog.csdn.net/u012814856/article/details/80684376

二、谷歌浏览器插件推荐

  • 谷歌上网助手: 如果仅仅用器来看视频, google 搜索东西也还是可以接受的. 每个月 15 块. 如果是需要全局模式就不行了, 完全没法使用.
  • Checker Plus for Gmail: 无需打开 Gmail 或 Inbox,即可收到桌面邮件通知,方便地查看、收听或删除邮件,并且支持多账户。搞了半天 outlook 始终无法登录, 使用这个插件完美解决问题.
  • Infinity 云端高清壁纸, 自由添加网站图标这个功能个人非常喜欢. 可以很方便的使用常用的软件工具.
  • AdBlock 在YouTube、Facebook、Twitch和其他你喜爱的网站上拦截广告和弹窗。
  • Click&Clean 当浏览器关闭时,这款应用程序删除你的浏览历史,防止他人跟踪你的网上活动。
  • 划词翻译 : 最近学习英语, 该工具非常好用

三、vim

更新到新版的 vim

1
2
3
4
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
vim --version

安装 vimplus

1
2
3
git clone https://github.com/chxuan/vimplus.git ~/.vimplus
cd ~/.vimplus
./install.sh

需要注意的事 ycm 的安装需要根据自己环境的 phthon 环境做选择

1
2
3
Resolving deltas: 100% (1123/1123), done.
Please choose to compile ycm with python2 or python3, if there is a problem with the current selection, please choose another one. [2/3]
Compile ycm with python3.

clone 卡主在 ‘/etc/host’ 加入

1
2
3
4
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com

1. 解决 ycm 的报错

报错如下

1
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 0. Type ':YcmToggleLogs ycmd_45521_stderr_iiwbx058.log' to check the logs.

解决方案

1
2
sudo apt install vim-youcompleteme
vim-addon-manager install youcompleteme

2. gd 高亮但是不跳转

安装好之后会安装一些默认的插件在 ~/.vimrc, 可以根据自己的需要进行调整, 这里面默认的 vim-slash 会导致无法进行跳转.

  1. 注释掉 vim-slash 插件
  2. 在 ~/.vimrc 最后面添加:
1
nnoremap gd :let @/ = '\V\<'.expand('<cword>').'\>'<CR>:set hlsearch<CR>

3. 客制化自己的插件

~/.vimrc.custom.plugins 中添加自己的插件, 我自己就增加了两个

1
2
Plug 'morhetz/gruvbox' "配色插件
Plug 'kien/rainbow_parentheses.vim' "括号插件

然后在 ~/.vimrc.custom.config 中添加配置

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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 用户自定义配置(该文件放一般性配置,可覆盖~/.vimrc里的配置,若要增加、卸载插件,请放入~/.vimrc.custom.plugins)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 设置帮助语言为中文
set helplang=cn
" 语法高亮
syntax enable
syntax on

set hlsearch " 搜索高亮设置
set nu " 显示行号
set ts=4 " table 缩进 4 个空格
set sw=4 " 自动缩进的时候缩进 4 个空格
set noexpandtab " 让 table 还原成 table 而非空格
"set mouse=a " 支持鼠标

"字符编码相关设置
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set backspace=2
set shortmess+=I " 禁用gd的默认行为

set autoindent " 自动缩进
set incsearch " 逐步搜索模式,对当前键入的字符进行搜索而不必等待键入完成


nnoremap t= :resize +5<CR> " 垂直
nnoremap t- :resize -5<CR>
nnoremap t, :vertical resize +5<CR>
nnoremap t. :vertical resize -5<CR> " 水平
nnoremap tj :resize +5<CR>

"窗口上下左右选择键
nnoremap fh <C-W>h
nnoremap fj <C-W>j
nnoremap fk <C-W>k
nnoremap fl <C-W>l

" -------------------------------------------------------- cscope
if filereadable("cscope.out")
cs add cscope.out
endif

nmap <F2>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <F2>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <F2>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <F2>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <F2>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <F2>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <F2>i :cs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <F2>d :cs find d <C-R>=expand("<cword>")<CR><CR>
map <F2> :NERDTreeToggle<CR>
map <F3> :TagbarToggle<CR>
map <F4> :CtrlPMixed<CR>
nnoremap <silent> <C-k> <Plug>(coc-diagnostic-prev)
nnoremap <silent> <C-j> <Plug>(coc-diagnostic-next)

" ------------------------------------------------------- cscope end


" ------------------------------------------------------- 配色插件 gruvbox 配置
autocmd vimenter * nested colorscheme gruvbox
set t_Co=256
set bg=dark

"""""""""""""""""""""light"""""""""""""""""
set nu cursorline
set nocompatible wildmenu wrap laststatus=2
syntax on
filetype indent on
hi Normal ctermbg=0
hi CursorLine cterm=NONE ctermbg=254
hi CursorLineNr cterm=standout ctermfg=251 ctermbg=233
hi WildMenu cterm=NONE ctermfg=231 ctermbg=243
" gruvbox ---------------------------------------------- end

" ------------------------------------------------------ 括号颜色插件 rainbow_parentheses 以及配置
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]

let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0

" ---------------- rainbow_parentheses 自动启用 ----------------
augroup RainbowParen
autocmd!
" 用 ++nested 确保插件命令已经定义
autocmd VimEnter * ++nested silent! RainbowParenthesesToggle
autocmd Syntax * RainbowParenthesesLoadRound
autocmd Syntax * RainbowParenthesesLoadSquare
autocmd Syntax * RainbowParenthesesLoadBraces
augroup END

" 通过 :RainbowParenthesesToggle 命令启动插件 ---------- rainbow_parentheses 完成配置

4. 安装 cscope 和 ctags

1
2
sudo apt-get install cscope
sudo apt-get install ctags

最后用下面命令创建索引

1
find ./ -name "*.c" -o -name "*.h" > cscope.files && cscope -Rbq -i cscope.files && ctags -L cscope.files

二、shell 美化

1. oh-my-zsh

oh-my-posh 是 windows 用的, ubuntu 下则使用 oh-my-zsh 配置主题, zhs 是一个 shell 工具, 和 bash 具有相同功能. 安装很简单运行 sudo apt install zsh 之后运行 zsh --version 查看版本号.

运行chsh -s $(which zsh)切换 bash 到 zsh , 运行之后重新打开一个终端后如下所示, 输入 2, zsh 已经切换完成并为我们创建 .zshrc 文件.

需要注意的是 zsh oh-my-zsh 并不是同一个东西. 接下来在 zsh 的基础上安装 oh-my-zsh.

1
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

2. 安装 powerlevel10k

zsh 默认支持的主题, 可以在这里挑选默认的主题. 我使用的是 powerlevel10k 不是默认的主题需要下载.

1
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

安装完成之后 vim ~/.zshrc 配置 ZSH_THEME="powerlevel10k/powerlevel10k"

source 之后进入配置界面

这里随便配, 配完之后会在 ~ 目录生成 ~/.p10k.zsh 配置文件接下来更进一步配置我们的主题, 我使用 Powerlevel10k config with Tony Lambiris’s style 这个配置.首先运行下面命令下载配置文件

1
curl -fsSL https://gist.githubusercontent.com/romkatv/3e1c685ec83170ecb33267d5c7d3fe3f/raw/p10k-tony-lambiris.zsh -o ~/.p10k-tony-lambiris.zsh

然后运行下面命令将配置文件写入 ~/.zshrc

1
echo 'source ~/.p10k-tony-lambiris.zsh' >>! ~/.zshrc

最后运行 . ~/.zshrc 更新配置文件

到此就算是使用 windows terminal 的配置就算完成了.

3. 配置一些常用功能

    在 Zsh 中,按下两次Tab键会触发自动补全功能。第一次按下Tab键时,它会尝试根据您输入的内容匹配可能的命令、文件名或其他内容。如果有多个匹配项,再次按下Tab键将显示所有可能的匹配项列表。这种模式被称为"双击Tab键补全",它是Z sh 中非常常见的一种操作,用于快速查找和选择文件名、命令、参数等.

    对于新手来说这个功能算是比较友好的, 但是博主习惯了 bash 的那种方式, 所以去掉了这个功能. 去掉的方式很简单在 ~/.zshrc 中添加 setopt noautomenu 就可以了. 以下是博主根据自己的习惯配的一些常用命令.各位可以按需选择

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
# 设置一些常用命令命令
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias gs='git status'
alias gl='git log --pretty=oneline'
#alias gf='git --no-pager diff'
alias gf='git diff'
alias gc='git checkout'
alias gr='grep -r --include="*.c" '
alias hs='history | grep '
alias cls='clear'
alias cstag='find ./ -name "*.c" -o -name "*.h" > cscope.files && cscope -Rbq -i cscope.files && ctags -L cscope.files'

# 配置历史记录
export HISTSIZE=1000 # 定义zsh 保存的历史命令数量上限为1000
export SAVEHIST=1000 # 定义退出 zsh 时保存的历史命令数量为1000
export HISTCONTROL=ignoredups # 使历史记录忽略连续的重复命令
export HISTFILE=~/.zsh_history # 定义历史命令的保存文件
setopt HIST_IGNORE_ALL_DUPS # 使历史记录忽略所有重复条目

# 安卓编译配置, 设置 cache
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_DIR=~/work/.ccache ccache -M 250G -F 0

# 即时提示(instant prompt)为静默模式
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet

# 去掉 双击Tab键补全 功能
setopt noautomenu
0%