2020年5月27日 星期三

terminal 文字顏色設定

\e[01;31m 表示配色開始。綠色部分為格式設定,有 [1,3,4]。黃色部分為顏色設定。m 表控制碼結束。
\e[00m 表示配色 reset


作法 1:
# -e enable interpretation of backslash escapes
$ echo -e "\e[95mHello \e[00m\e[92mWorld!\e[0m"

做法 2:
# 這種方式會影響接下來的所有輸出,無法在一列內輸出多種顏色。1~7 為 basic colors
$ tput setaf [1-7] $ echo "hello world"



tmux pane 間 copy/paste 的設定

tmux pane 之間的複製貼上因 copy mode 開始複製的 hotkey 跟輸入法切換器的 hotkey 衝突,
故改為 v 開始選擇,y 複製到 buffer。


以下貼到 ~/.tmux.conf
# Use v to trigger selection 
bind-key -T copy-mode v send-keys -X begin-selection

# Use y to yank current selection
bind-key -T copy-mode y send-keys -X copy-selection-and-cancel


------------------------------------
  1. <PREFIX> + [ 進入 copy mode。
  2. v 開始選擇。以方向鍵移動,會反白。
  3. y 複製到 buffer。
  4. <PREFIX> + ] 貼上 buffer 內的內容。


ps. <PREFIX> default 為 Ctrl-b
pps. $ tmux list-keys 可以列出 bind 的 keys