iTerm配置

命令行工具

  • tldr :  man 的简易命令平替

   三种安装方式:

npm install -g tldr

pip3 install tldr

brew install tlrc
  • ydict
  • rsync

brew安装

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Protobuf安装

brew install protobuf

安装完之后,关于编译protobuf文件的工具: protoc就可以正常使用了。

Git配置 

Git相关

git config --global alias.cm commit
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.br branch
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global core.excludesfile ~/.gitignore_global
git config --global core.editor vim
git config --global help.autocorrect 50
git config --global core.autocrlf input
git config --global alias.pl pull
git config --global alias.rb rebase
git config --global alias.ad add
git config --global alias.ps push
git config --global pull.rebase true
git config --global core.editor vim 
git config --global user.name "my name"
git config --global user.email "my email"

运行之后生产对应的git配置文件: ~/.gitconfig 如下:

[user]

name = Jerry

email = xxx @gmail.com

[push]

default = current

[core]

excludesfile = /Users/user/.gitignore_global

editor = vim

autocrlf = input

[help]

autocorrect = 50

[url "git@git.xxxx、.com:"]

insteadOf = https://git.xxx.com

终端配置

下载并使用oh my zsh

oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

或者

wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh && sh install.sh

配置zshrc

vim ~/.zshrc

安装autosuggestions

git clone git@github.com:zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

编辑 ~/.zshrc文件, 修改plugins 新增一些插件

这样可以通过快捷键:Ctrl + R , 打开快捷模糊搜索🔍功能,选择历史命令执行。

plugins=(git z zsh-autosuggestions)

然后,新增 ~/.myzshrc 文件,添加以下内容: 

# set proxy

function proxy_off(){

unset http_proxy

unset https_proxy

echo -e "已关闭代理"

}

function proxy_on() {

export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

export http_proxy="http://127.0.0.1:7890"

export https_proxy=$http_proxy

echo -e "已开启代理"

}

# set config

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

set termencoding=utf-8

set encoding=utf-8

# alias 别名

## tmmux
alias t='tmux'
alias ta='tmux attach -t '

## k8s
alias kubectx='change_kube_config'

change_kube_config() {

para=$1

cp ~/.kube/config_$para ~/.kube/config

}

alias k8s='kubectl'

alias blb='bazel build -c opt'

alias blt='bazel test -c opt --test_output=errors --keep_going'

alias blr='bazel run -c opt'

alias gt='git'

alias zsh='source ~/.zshrc'

# git clone可以从外部传参数
# eg: gclf git.llsapp.com/codelab/tensorflow


alias gclf='clone_f'

clone_f() {

para=$1

prefix=${para%/*}

url=${prefix%/*}

group=${prefix##*/}

echo "prefix:${prefix},url:${url}"

repo=${GOPATH}/src/${prefix}

cd ${repo}

file=${para##*/}

echo "file:$file"

mkdir -p ${repo}

cd ${repo}

gitUrl=git@${url}:${group}/${file}.git

dest=${GOPATH}/src/${url}/${group}/${file}

echo "clone:${gitUrl}, into:${dest}"

git clone ${gitUrl} ${dest}

}

# 通过http的方式下载github源码
# eg: git_download github.com/bigchange/go-practice b796ca84b7186ae6d570706cd36cf7b1cf6f1d2e


alias gdld='git_download'

git_download() {

para=$1

commit=$2

prefix=${para%/*}

url=${prefix%/*}

group=${prefix##*/}

echo "prefix:${prefix},url:${url}"

repo=${GOPATH}/src/${prefix}

cd ${repo}

file=${para##*/}

echo "file:$file"

dest=${GOPATH}/src/${url}/${group}

mkdir -p $dest

cd ${dest}

wget "https://github.com/${group}/${file}/archive/${commit}.tar.gz"

tar -xzvf *.tar.gz

rm *.tar.gz

mv ${file}-${commit} ${file}

}

# generate pb.go with protoc tool

# supposed import protos are based on project root dir

# eg: eg: pcf git.llsapp.com/common/protos liulishuo/algorithm/bot/dm/schema

alias pcf='protoc_pb_generate'

protoc_pb_generate() {

echo "repo subdir..."

repo=$1

cd ${GOPATH}/src/$1

para=$2

prefix=${para%/*}

echo "prefix:$prefix"

file=${para##*/}

echo "file:$file"

temp_dir=${file}_go_proto

target=${GOPATH}/src/${repo}/${prefix}/${temp_dir}

mkdir $target

protoc --go_out=plugins=grpc:. -I . ${prefix}/${file}.proto

mv ${GOPATH}/src/${repo}/${prefix}/${file}.pb.go ${target}

cd -

}

# alias define end

最后, 在source $ZSH/oh-my-zsh.sh之前,添加:

source ~/.myzshrc

Vim配置

cp /etc/vim/vimrc ~/.vimrc

 修改并打开文件中已有的配置, 请去除每行前面的单引号

当然,也可以新增一些其他特性相关的配置,参考设置如下:

setlocal noswapfile " 不要生成swap文件
set bufhidden=hide " 当buffer被丢弃的时候隐藏它
colorscheme evening " 设定配色方案
set number " 显示行号
set cursorline " 突出显示当前行
set ruler " 打开状态栏标尺
set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
set tabstop=4 " 设定 tab 长度为 4
set nobackup " 覆盖文件时不备份
set autochdir " 自动切换当前目录为当前文件所在的目录
set backupcopy=yes " 设置备份时的行为为覆盖
set hlsearch " 搜索时高亮显示被找到的文本
set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码
set matchtime=2 " 短暂跳转到匹配括号的时间
set magic " 设置魔术
set smartindent " 开启新行时使用智能自动缩进
set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符
set cmdheight=1 " 设定命令行的行数为 1
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ Ln\ %l,\ Col\ %c/%L%) " 设置在状态行显示的信息
set foldenable " 开始折叠
set foldmethod=syntax " 设置语法折叠
set foldcolumn=0 " 设置折叠区域的宽度
setlocal foldlevel=1 " 设置折叠层数为 1
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠

tmux安装

使用教程:A Quick and Easy Guide to tmux &CenterDot; Ham Vocke

apt-get install tmux

如何使用tmux, 不懂就 man 一下

man tmux

常用快捷键:

  • C-b ,: Rename the current window
  • C-b z: make a pane go full screen,Hit C-b z again to shrink it back to its previous size
  • C-b c: Creating new windows
  • C-b d/D:  To detach your current session
  • C-b p/n: To switch to the previous/next window
  • C-b <number>:  to switch window, where <number> is the number in front of the window’s name
  • C-b %: to split panes into a left and a right pane
  • C-b ": To split a pane into top and bottom panes
  • C-b <arrow key>:  switching to a different pane

注意: C-b <command>: means Ctrl and b at the same time, release both, and then type the <command> key

~/.tmux.conf

关于: ~/.tmux.conf 文件的配置:

1. 将prefix key的配置由 C-b 变成 C-a

2.  将创建分屏的command key重新绑定

# 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 %

# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf


# switch panes using Alt-arrow without prefix
# remember: M is for Meta, which is usually your Alt key
# With this modification I can simply press Alt-left to go to the left pane
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D


# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on

# don't rename windows automatically
set-option -g allow-rename off


# DESIGN TWEAKS

# don't do anything when a 'bell' rings
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none

# clock mode
setw -g clock-mode-colour colour1

# copy mode
setw -g mode-style 'fg=colour1 bg=colour18 bold'

# pane borders
set -g pane-border-style 'fg=colour1'
set -g pane-active-border-style 'fg=colour3'

# statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'fg=colour1'
set -g status-left ''
set -g status-right '%Y-%m-%d %H:%M '
set -g status-right-length 50
set -g status-left-length 10

setw -g window-status-current-style 'fg=colour0 bg=colour1 bold'
setw -g window-status-current-format ' #I #W #F '

setw -g window-status-style 'fg=colour1 dim'
setw -g window-status-format ' #I #[fg=colour7]#W #[fg=colour1]#F '

setw -g window-status-bell-style 'fg=colour2 bg=colour1 bold'

# messages
set -g message-style 'fg=colour2 bg=colour0 bold'

SSH配置

关于使用 ~/.ssh/config

Host vm
    User foobar
    HostName 172.16.174.141
    Port 2222
    IdentityFile ~/.ssh/id_rsa
    # 端口转发: 本地9999 转发到远程 8888
    LocalForward 9999 localhost:8888 

# 在配置文件中也可以使用通配符
Host *.mit.edu
    User foobaz

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JYCJ_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值