~/.inputrc 配置

1
2
3
4
5
6
7
# [Tab auto-completion case-insensitive](https://askubuntu.com/a/87066/546909)
set completion-ignore-case On
# [prefix sensitive for previous command searching](http://unix.stackexchange.com/a/96511/205808)
# Press up-arrow for previous matching command
"\e[A":history-search-backward
# Press down-arrow for next matching command
"\e[B":history-search-forward

~/.bashrc配置

, 在`~/.inputrc 中添加以下配置:

1
2
3
4
5
6
7
8
9
10
11
# colorful command line prompt
export PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[33;40m\]@\[\e[32;40m\]\H \[\e[33;40m\]\w\[\e[37;40m \]]\\$ \[\e[37;0m\]"
# colorful ls result
alias ls='ls --color'
# increase command listory to 10000 items
HISTFILESIZE=100000
HISTSIZE=100000
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

参考资料:

  1. Preserve bash history in multiple terminal windows

修改 ssh server timeout 时间

/etc/ssh/sshd_config 中添加:

1
2
3
TCPKeepAlive yes
ClientAliveInterval 120
ClientAliveCountMax 720

The first one configures the server to send null packets to clients each 120 seconds and the second one configures the server to close the connection if the client has been inactive for 720 intervals that is 720*120 = 86400 seconds = 24 hours


或者在客户端的~/.ssh/config中添加配置:

1
2
3
Host *
ServerAliveInterval 60
ServerAliveCountMax 3 # 不设置表示不停重试

ssh client 在不同窗口之间共享 session

~/.ssh/config中添加配置:

1
2
3
4
Host *
ControlMaster auto
ControlPersist 1000m
ControlPath ~/.ssh/master-%r@%h:%p