效率

工欲善其事,必先利其器

前言

该博文用于记录一些非常实用插件以及工具,以及一些程序或者配置文件的示范样例。

theFuck

theFuck是一款用于纠正前一个命令行命令。

1
2
3
4
5
6
➜  ~ mkdir no-exist/no-exist
mkdir: no-exist: No such file or directory
➜ ~ fuck
mkdir -p no-exist/no-exist [enter/↑/↓/ctrl+c]
➜ ~ cd no-exist/no-exist
➜ no-exist

安装

OS X

1
brew install thefuck

Ubuntu

theFuck需要安装Python3.4+作为前置依赖,[参见]

1
sudo pip3.6 install thefuck

使用

  1. 安装好之后务必将下面的命令添加至.zshrc文件

    1
    2
    3
    eval $(thefuck --alias)
    # 或者设置其他别名
    eval $(thefuck --alias FUCK)
  2. 新打开一个终端会话

  3. fuck

oh-my-zsh插件

zsh-autosuggestions

zsh-autosuggestions是一款根据历史记录里的命令自动补全建议

  1. 克隆该项目到oh-my-zsh的plugins文件夹

    1
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  2. 将该插件写入.zshrc文件:
    plugins=(zsh-autosuggestions)

  3. 新打开一个终端会话

git

git插件设置了一些常用git命令的缩写,以及常用git相关函数,详细参见wiki

git bisect命令帮助快速定位BUG所在改动,详细用法

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
alias g='git'
alias ga='git add' # 添加文件到暂存区
alias gaa='git add --all' # 添加所有文件到暂存区
alias gb='git branch' # 列出所有本地分支
alias gba='git branch -a' # 列出所有本地以及远程分支
alias gbd='git branch -d' # 删除分支
alias gbl='git blame -b -w' # 查看文件具体改动以及对应的改动者,忽略空格。
alias gbnm='git branch --no-merged' # 打印未被合并的分支
alias gbr='git branch --remote' # 只列出远端分支
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcam='git commit -a -m'
alias gcsm='git commit -s -m'
alias gcb='git checkout -b'
alias gcf='git config --list'
alias gcl='git clone --recursive'
alias gclean='git clean -fd'
alias gpristine='git reset --hard && git clean -dfx'
alias gcm='git checkout master'
alias gcd='git checkout develop'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit -S'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff'
alias gf='git fetch'
alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'

Redis

单独安装安装Redis-client

1
sudo apt-get install redis-tools

Ubuntu 删除服务

1
sudo update-rc.d ServiceName remove

永久添加环境变量

1
sudo echo env=\"test\" >> /etc/environment

Supervisor

生成Supervisor conf

1
echo_supervisord_conf > supervisord.conf

Supervisor flask+Gunicon 模板

1
vim Pipfile

[scripts]
server = “gunicorn -w 1 -b 127.0.0.1:8000 your_server:app”

1
vim supervisord.conf

[program:flask]
command=pipenv run server
directory=your_project
startsecs=0
stopwaitsecs=0
autostart=false
autorestart=false
stdout_logfile=your_project/gunicorn.log
stderr_logfile=your_project/gunicorn.err

1
2
3
supervisord -c supervisor.conf
supervisorctl -c supervisor.conf reload
supervisorctl -c supervisor.conf start flask

0%