2. clone session
- 问题
已经登录跳板机了,为啥我新开一个tab,还要再让我输一遍token?
- 攻略
在~/.ssh/config文件(若没有则新建一个)中添加如下配置:
host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
Copy
3. keep alive
- 问题
已经登录了一台日常机做测试,怎么去写了会代码,回来已经断开连接了,特别是打开多个窗口时,你是否会抓狂?
- 攻略
1)在~/.ssh/config文件(若没有则新建一个)中添加如下配置:
#表示每过5分钟发一个数据包到服务器表示“我还活着”
ServerAliveInterval 300
Copy
2)在iterm2配置
4. shortcut key
- 问题
需要开很多窗口,来做监控或者查看不同的内容,一个个窗口切换,我已眼花缭乱。
- 攻略
Command + D:进行窗口横向分割
Command + Shift + D:进行窗口竖向分割
Command + O:打开Profile界面
Command + T:新建tab
Command + W:关闭tabCommand + N 新建窗口
结合横向分割、竖向分割、关闭功能,可以多窗口协作,与多tab告别吧~
5. alias command
-
问题
登录跳板机的命令是啥来着,跳板机的地址多少来着? -
攻略
在~/.bash_profile文件中添加自定义命令吧~
alias eu13='ssh [email protected]'
Copy
DomainPassword + 6characters Token
- 进阶
那些复杂的命令全部让系统帮我记着吧
1)每次需要到某个项目工作目录下
alias cd1='cd ~/Documents/workspaces/himalayas/'
登录服务器,在个人目录下。给路径 命令行起别名
➜ ~ vim ~/.bash_profile
alias cd1='cd /home/admin/xx/logs'
alias tail1='tail -f /home/admin/xx/logs/cost.log |grep utdid'
配置好后
在服务端
隔一段时间后 实时日志会展示^@^@^@^@ 保持连接不断开
Copy
2)Linux下有ll命令,为啥Mac OS么有
alias ll='ls -all'
6. alias shell
- 问题
我打个命令,要执行一段shell脚本?
- 攻略
先在某个目录下新建shell脚本
比如显示隐藏文件的shell脚本:show.sh
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder
Copy
在~/.bash_profile文件中添加自定义命令,记得带上绝对路径
alias show='sh ~/Documents/workspaces/shell/show.sh'
Copy
- 进阶
一切皆有可能
结语
iTerm 使用指南,很实用!关于切换路径,可以试试 autojump。Github 地址: https://github.com/wting/autojump
Linux 日常开发的话,xterm + tmux + oh-my-zsh 也不错。
tmux推荐,比screen好很多。
记住第一个登录的窗口不要关……
不过itrem可以设置哪些进程运行时,提示是否关闭
一段git alias
非常有用的:
[core]
editor = vim
autocrlf = input
[merge]
tool = vimdiff
[alias]
ss = status --short
s = status
co = checkout
a = add
au = add -u
c = commit
cm = commit -m
ll = log --color --graph --stat --all --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ci) %C(bold blue)%Creset'
l = log --color --graph --all --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ci) %C(bold blue)%Creset'
la = log --color --graph --stat --decorate --all
[diff]
color = auto
status = auto
[user]
name = xx
email = [email protected]
放到~/.gitconfig
里,尤其是log,一目了然分支、远程分支、stash、graph关系等等:
$ git l
设置完.bash_profile的alias配置,直接用还不行,还需要运行”source ~/.bash_profile“。此条命令是重新加载配置