Tmux Autocompletion with Alias

Joon·2022년 2월 28일
0

When you're developing remotely, you may want to make the code (or terminal) run continuously even after the connection is closed. Then, the simplest way you can find is using tmux.

Basic Tmux Command

tmux new -s {session-name} # create new session
tmux ls # list tmux sessions
tmux attach-session -t {session-name} # attach to session
tmux kill-session -t {session-name} # kill session

# command inside tmux session 
<C-b> d # or Ctrl+b then d / detach current session 
<C-b> [ # enter scroll mode / exit with <C-c>

Tmux commands are intuitive enough, but which developer would hesitate using faster way?

Add Alias for Tmux

# ~/.bashrc
alias tn='tmux new -s'
alias tl='tmux ls'
alias ta='tmux attach-session -t'
alias tk='tmux kill-session -t'

Add the above code to proper bashrc.

Add Auto Complete

The bash-completion package doesn't account tmux into its boundary. So you need to add custom auto-complete shell script.
This is done by https://russellparker.me/post/2018/02/16/tmux-bash-autocomplete/.
The author made ~/.bash_completion script. I made little modification to this script, which can be donwloaded with the following command.

curl https://raw.githubusercontent.com/ohjoonhee/tmux-autocomplete/master/bash_completion > ~/.bash_completion


References

https://russellparker.me/post/2018/02/16/tmux-bash-autocomplete/

0개의 댓글