on the way to geek, this is a guideline.
Python
use tinghua mirrors:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
tmux
tmux & vim are fantastic pairs of tools.
.tmux.conf
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# enable mouse support for switching panes/windows
set -g mouse off
#### copy mode : vim ####
# set vi mode for copy mode
setw -g mode-keys vi
# copy mode using 'Esc'
unbind [
bind Escape copy-mode
# paste using 'p'
unbind p
bind p paste-buffer
# Enable mouse mode (tmux 2.1 and above)
bind M set -g mouse on
bind m set -g mouse off
tmux new -s asession
Ctrl-b d
tmux attach -t asession
vim
vim
vim-tiny
neovim
vim-nox
apt install vim-autopep8
apt install vim-ctrlp
apt install vim-youcompleteme
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
.vimrc:
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)
" ...
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'jnurmine/Zenburn'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with the spacebar
nnoremap <space> za
let g:SimpylFold_docstring_preview=1
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2
set shiftwidth=4
highlight BadWhitespace ctermbg=red guibg=darkred
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
set encoding=utf-8
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
let python_highlight_all=1
syntax on
if has('gui_running')
set background=dark
colorscheme solarized
else
colorscheme zenburn
endif
call togglebg#map("<F5>")
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
set nu
vi:
以16进制打开文件
- vim -b file-to-open.dat — 以2进制的形式打开文件
- :%!xxd — 给当前文章执行xxd命令
- :%!xxd -r
- od
- hexdump:以16进制输出文件
- xxd:
- % : 当前文章所有行
- ! : 执行外部命令
查找替换命令:
%s/a_string/b_string/g
%s#a_string#b_string/g — 查找替换含有/的字符串
%s/\n/ /g — 把回车换行替换成空格
# * — 向上向下 查找当前单词
移动命令:
Ctrl+i Ctrl+o — 光标所在的上一个位置,下一个位置
排版:
:10, 100< — 向前缩进排版10到100行
块选中,I,#,Esc ×2
:10,100s/^/#/g — 为10到100行添加#注释
:10,100s/^#//g — 为10到100行去掉#注释
:set noautoindent
:set tabstop=4
issues:
- The ycmd server SHUT DOWN (restart wit…the instructions in the documentation.
cd ~.vim/bundle/YouCompleteMe
python install.py
git
添加远程仓库:
- git remote remove origin
- git remote add origin git@github.com:rainasmoon/online-application.git
- git remote -v
初始化:
- git init
- git status
- git add .
- git checkout afilename.txt
特殊处理:
- git fetch –all
- git reset –hard origin/master
- git commit b -m “new feature, in b”
- git rm a.file
- git rm a.file –cache
- git amend
- git log
对比:
- git diff
- git diff –cache
- git diff –staged
git diff <filename> 命令,命令行窗口不会输出文件的改动信息。
git diff HEAD -- <filename> 命令同样也不会输出文件的改动信息。因为当前工作区未做改动。
git diff HEAD^ -- <filename> 命令则可以查看最近两次提交版本的区别(版本E和版本D的差别——增加数字“5”)
git diff HEAD^^ -- <filename> 命令则可以查看最近一次提交和最近一次提交的上上个版本的区别(版本E和版本C的差别——增加数字“4”和“5”)
git diff HEAD^^^ -- <filename> 命令则可以查看版本E和版本B的差别——增加数字“3”,“4”和“5”。
git diff HEAD~4 -- <filename> 命令则可以查看版本E和版本A的差别——增加数字“2”,“3”,“4”和“5”。等同于HEAD^^^^
.gitignore 文件的例子
# 此为注释 – 将被 Git 忽略
# 忽略所有 .a 结尾的文件
*.a
# 但 lib.a 除外
!lib.a
# 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
/TODO
# 忽略 build/ 目录下的所有文件
build/
# 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
doc/*.txt
# 忽略 doc/ 目录下所有扩展名为 txt 的文件
doc/**/*.txt
Shell
tree
hexedit :
ls -1 /dev/{ashmem,binder}
判断一个文件是否被更改过:
md5sum afile.txt
sha256sum afile.txt
type # 显示命令的类型
通配符: * ? [] [!] #shell可以使用通配符
I/O重定向: < > >>
|
$() # shell可以使用可替代的命令
/proc 虚拟文件系统,存放当前内存的映射
/opt
/var
/dev
– # cd之前的目录
file
stat
head tail more less cat echo
wc
touch
^$.?*+[]()|{n,m} #常用正则表达式
dwm
apt install dwm
apt install brightnessctl acpi
apt-get source dwm # put it to /usr/local/src/dwm/
apt install libxft-dev
make clean install
at /etc/X11 create your own Xsession-dwm:
while true
do
VOL=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
LOCALTIME=$(date +%Z\=%H:%M)
OTHERTIME=$(TZ=Europe/London date +%Z\=%H:%M)
IP=$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1) # can get confused if you use vmware
TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))C"
if acpi -a | grep off-line > /dev/null
then
BAT="Bat. $(acpi -b | awk '{ print $4 " " $5 }' | tr -d ',')"
xsetroot -name "$BAT $VOL $TEMP $LOCALTIME $OTHERTIME"
else
xsetroot -name "$VOL $TEMP $LOCALTIME $OTHERTIME"
fi
sleep 20s
done &
#fcitx &
brightnessctl s 5% &
setxkbmap -layout gb -option ctrl:nocaps
xset s 0
xset dpms 0 0 0
exec dwm
modify /usr/share/xsessions/dwm.descktop
Exec=/etc/X11/Xsession-dwm
/etc/lightdm/lightdm-gtk-greeter.conf # set background
区块链
REF:
- https://realpython.com/vim-and-python-a-match-made-in-heaven/
- https://tmuxguide.readthedocs.io/en/latest/tmux/tmux.html
- https://www.bugsnag.com/blog/tmux-and-vim
- https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
- https://pandas.pydata.org/docs/index.html