tmux: open terminal failed: missing or unsuitable terminal: xterm-256color

Trying to upgrade my Pi-hole host from Raspbian Stretch to Buster, during the upgrade process, I detached the tmux session and left for a while, when I came back, I can’t create or attach my tmux session anymore, got error message as below:

pi@pi-hole ~ $ tmux a
open terminal failed: missing or unsuitable terminal: xterm-256color

pi@pi-hole ~ $ tmux
open terminal failed: missing or unsuitable terminal: xterm-256color

Workaround:

export TERM=xterm

This will make tmux work again.

Some instructions will tell you to kill the tmux server and start a new one:

tmux kill-server

This will lose the current session which is not preferred, especially during the system upgrade process.

vim 視窗分割

雖說 tmux 很好用,不過 vim 本身內建視窗切割功能了,好像沒必要因此開多個 shell 跟 vim 浪費記憶體,還是記一下 vim 常用的分割視窗指令:

開新水平視窗:
:new
開新垂直視窗:
:vnew

水平切割後開起現有或指定檔案:
:sp (split)
垂直切割後開起現有或指定檔案:
:vsp (vsplit)
這兩個命令後面接檔名(記得前面要一個空格)會直接打開對應的檔案~

另外 vim 的分割視窗操作預設 hot key 是 Ctrl + w, 也可以用熱鍵來操作:

水平切割視窗:
<Hot key> s
垂直切割視窗:
<Hot key> v

在分割視窗之間切換/移動焦點(游標):
<Hot key> k  或  <Hot key> ↑
<Hot key> j  或  <Hot key> ↓
<Hot key> h  或  <Hot key> ←
<Hot key> l  或  <Hot key> →
(把英文字母改成大寫則可移動到最上最下最左最右)

把目前的分割視窗加大:
<Hot key> +
把目前的分割視窗縮小:
<Hot key> –
把目前同一行/列的分割視窗高/寬平均:
<Hot key> =
把目前的分割視窗放到最大(寬or高):
<Hot key> _
<Hot key> |
把目前的分割視窗用一個新的分頁(tab)開啟:
<Hot key> T

要強迫自己習慣一下~