tmux 3.2에서 마우스를 이용한 copy&paste 관련 부분을 깔끔하게 설정할 수 있게 되었다.

 

tmux 소스를 빌드한 이후에 tmux 파일을 ~/bin 에 복사하였다. ( https://github.com/tmux/tmux/wiki/Installing#installing-tmux )

 

git clone https://github.com/tmux/tmux.git
cd tmux
git checkout 3.2
sh autogen.sh
./configure
make

 

tmux 3.2에서는 copy&paste를 위한 copy-command 'xsel -i' 이 지원되었는데,

이전 버전까지 사용하던 copy&paste 관련 지저분한 설정을 set -g copy-command 'xsel -i' 한 줄로 명료하게 정리할 수 있다.

 

다음과 같이 .tmux.conf를 업데이트한다.

# Use symbolic link for version control
# ln -s settings/.tmux.conf .tmux.conf

# restart :
#': source-file ~/.tmux.conf'

# References
# - https://gist.github.com/spicycode/1229612
# - https://blog.outsider.ne.kr/699#footnote_link_699_1
# - https://unix.stackexchange.com/questions/1045/getting-256-colors-to-work-in-tmux

# set -g default-terminal "screen-256color"
# it should be added in .bashrc
#if [ "$TERM" != "xterm-256color" ]; then
#  export TERM=xterm-256color
#fi


# Set scrollback history
set -g history-limit 50000

# Set mouse on : windows, panes, scroll, copy & paste
set -g mouse on

# Set clipboard
set -g copy-command 'xsel -i'

# Set rebinding the action key
set -g prefix C-j
unbind C-b
bind C-j send-prefix

# Use Alt-arrow keys without prefix key to switch panes
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
bind -n M-q     display-panes

# Use Alt-number keys to switch windows
bind -n M-0 select-window -t 0
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9

# Use Shift-arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# Use | and - to split panes
bind | split-window -h
bind - split-window -v

#-------------------------------------------------------#
#Pane colours
#-------------------------------------------------------#
# set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'

#pane border
set -g pane-border-style bg=colour235
set -g pane-border-style fg=colour238
set -g pane-active-border-style bg=colour236
set -g pane-active-border-style fg=colour51
#-------------------------------------------------------#

# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left '#[fg=green](#S) #(whoami)'
set -g status-left-length 20
#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'

# Set highlight active window
setw -g window-status-current-style fg=black,bg=white

# tmux logging : over tmux 1.9
#run-shell ~/clone/path/logging.tmux

'Linux' 카테고리의 다른 글

tmux 사용법  (0) 2014.03.13
makefile의 phony  (0) 2013.05.07

tmux 사용법

reference

tmux는 좀 더 개선된 screen이라 생각하면 된다.

용어
  • session : tmux 실행시 생성
  • window : 하나의 session에 여러개의 window 생성 가능
  • pane : 하나의 window안에 여러개의 pane으로 분할 가능
사용법

다음은 실행과 종료 방법이다.

$ tmux
$ exit  # 종료  또는 ctrl + d

session 명령

$ tumx new -s 세션이름 # 세션이름으로 생성 

ctrl + b + d  # 셔션을 유지한채로 나오기

$ tmus ls  # 세션 목록 보이기
$ tmux attach -t 세션명 # 세션으로 다시 들어가기

window 명령

ctrl + b + c # 새 window 생성
ctrl + b + & # window 삭제
ctrl + b + , # window 이름 변경
ctrl + b + window 번호 # window 이동
ctrl + b + n # window 이동, next
ctrl + b + p # window 이동, previous
ctrl + b + l # window 이동, last

pane 명령

ctrl + b + % # 가로 나누기
ctrl + b + " # 세로 나누기
ctrl + b + q # 특정 pane 이동

ctrl + b + o # pane 이동
ctrl + b + 방향기 # pane 이동

$ exit # 삭제 또는 ctrl + d
ctrl + b + x # pane 삭제

ctrl + b + [Alt] + 방향키 # 크기 조절

copy mode
처음 실행시에 copy mode의 키가 제대로 동작하지 않았다. 기본으로 emacs style로 되어 있어서 그런것이었다. vi style로 변경하면 잘 된다.
vi style을 적용하면, copy mode에서 이동하는 방향키도 i,j,k,l, ctrl-f, ctrl-b 를 사용할 수 있다.

# ~/.tmux.conf
# set-window-option -g mode-keys vi

ctrl + b + [ # copy mode 진입
space # copy 시작
Enter # copy 완료
ctrl + b + ] # paste

'Linux' 카테고리의 다른 글

tmux 3.2 설치 및 설정파일  (0) 2022.01.06
makefile의 phony  (0) 2013.05.07

참고문헌 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/C/Documents/minzkn_make#s-7


makefile에서 target이 있는 경우에는 해당 명령이 실행되지 않는다. 이 부분이 문제가 일으킬 수 있는데, 예를 들어 make clean 을 실행할때 실제로 clean이라는 파일이 존재하는 경우이다. 이 때문에 clean이라는 파일의 유무에 상관없이 make clean이 항상 실행되도록 할 필요가 있으며, 명시적으로 .PHONY: 를 통해 해당 target은 존재유무에 상관없이 항상 만들도록 한다.

즉, 해당 target은 실제 파일이 아님을 명시적으로 알려주는 것이다.

/* filename : hello.c */

#include 

int main(void)
{
    printf("Hello, world!\n");
  
    return 0;
}
#filename : makefile
.PHONY: clean

all: hello
    gcc hello.c -o hello

clean:
    rm hello



'Linux' 카테고리의 다른 글

tmux 3.2 설치 및 설정파일  (0) 2022.01.06
tmux 사용법  (0) 2014.03.13

+ Recent posts