「インストール - ターミナル」の版間の差分
| 95行目: | 95行目: | ||
libXcursor-devel libXrandr-devel Mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libX11-devel \ | libXcursor-devel libXrandr-devel Mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libX11-devel \ | ||
libxcb-devel fontconfig-devel liblcms2-devel libcanberra-devel ImageMagick-devel \ | libxcb-devel fontconfig-devel liblcms2-devel libcanberra-devel ImageMagick-devel \ | ||
python311-devel python3-Pygments sphinx libsphinxclient-devel python3-Sphinx \ | |||
go1.21 \ | go1.21 \ | ||
libb2-devel librsync-devel wayland-devel wayland-protocols-devel | libb2-devel librsync-devel wayland-devel wayland-protocols-devel | ||
2023年9月8日 (金) 18:01時点における版
概要
全てのLinuxディストリビューションには、ターミナルが既にプレインストールされている。
ここでは、多くのLinuxディストリビューションで使用することができるターミナルについて記載する。
Gnome Terminal
シェルの変更
方法 1
- Gnome Terminalを右クリックまたは[≡]ボタンを押下して、環境設定を開く。
- 設定プロファイルを開くまたは作成する。
- [Command]タブを選択する。
- [Run a custom command instead of my shell.]チェックボックスにチェックを入力する。
- [Custom command]項目に、Zsh等のシェルの実行ファイルのフルパスを入力する。
方法 2
他の方法として、.bashrcファイルの1行目に、以下の設定を追記する。
[ -n "$GNOME_TERMINAL_SCREEN" ] && [ -x "$(command -v zsh)" ] && exec zsh "$@"
上記の設定の説明を、以下に示す。
まず、[ -n "$GNOME_TERMINAL_SCREEN" ]コマンドを実行して、Gnome Terminalを確認する。
次に、[ -x "$(command -v zsh)" ]コマンドを実行して、Zshのパスが存在するかどうかを確認する。
最後に、exec zsh "$@"コマンドを実行して、Bashと同じ引数でZshを起動する。
これにより、Gnome Terminalを起動する時、Zsh等のシェルが使用できる。
メニューバーの表示
初期設定では、GNOME Terminalはメニューバーを表示しない。
GNOME Terminalの画面を右クリックして、コンテキストメニューから一時的にメニューバーを表示することができる。
しかし、次回のGNOME Terminalの起動ではメニューバーが非表示に戻ってしまう。
これは、GNOME Terminalにある[編集]メニューバー - [環境設定]で表示される[環境設定]ダイアログボックスに、必要なチェックボックスがないことが原因である。
この問題を解決するには、以下に示す2通りの方法がある。
- 方法 1 : コマンドから実行する方法
- ターミナルセッションで次のコマンドを実行する。
gsettings set org.gnome.Terminal.Legacy.Settings headerbar false
- GNOME Shellを再起動することにより、メニューバーを恒久的に追加するだけでなく、欠落していたチェックボックスも追加される。
- GNOME Terminalの画面を右クリックして、[Preferences] - [General]を選択して、[Show menubar by default in new terminals]チェックボックスにチェックを入力する。
- ターミナルセッションで次のコマンドを実行する。
- 方法2 : dconfから設定する方法
- まず、dconf-editorを起動した後、
org.gnome.Terminal.Legacy.Settings:headerbarに移動して、値をfalseに設定する。 - GNOME Shellを再起動することにより、メニューバーを恒久的に追加するだけでなく、欠落していたチェックボックスも追加される。
- GNOME Terminalの画面を右クリックして、[Preferences] - [General]を選択して、[Show menubar by default in new terminals]チェックボックスにチェックを入力する。
- まず、dconf-editorを起動した後、
Drop Down Terminal
Drop Down Terminalは、Gnome Shellのデスクトップ環境にインストールできるターミナルの拡張機能である。
カスタムスクロールバーの設定、カラースキーム、起動時にカスタムコマンドを起動する機能等、便利な機能が搭載されている。
また、カスタマイズ性にも優れており、透明度、アニメーション、スクロールバーの表示、ウィンドウのサイズ、ホットキーボタンをカスタマイズすることができる。
さらに、コマンド機能により、ユーザのデフォルトシェルではなく、カスタムのコマンドライン引数を実行することができる。
URL : https://extensions.gnome.org/extension/442/drop-down-terminal/
ST
STのビルドに必要な依存関係のライブラリをインストールする。
# CentOS sudo yum install xrdb libXft-devel libX11-devel harfbuzz-devel libXext-devel libXrender-devel libXinerama-devel # SUSE sudo zypper install xrdb libXft-devel libX11-devel harfbuzz-devel libXext-devel libXrender-devel libXinerama-devel
STの公式Webサイトにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf st-<バージョン>.tar.gz cd st-<バージョン>
または、以下のコマンドを実行して、STのソースコードをダウンロードする。
git clone https://github.com/siduck/st.git ST cd ST
STをビルドおよびインストールする。
make clean install DESTDIR=$HOME/InstallSoftware/ST
Kitty
実行ファイルをダウンロードする場合
KittyのGithubにアクセスして、Kittyの実行ファイルをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf kitty-<バージョン>-x86_64.txz cd kitty-<バージョン>-x86_64
解凍したディレクトリを任意のディレクトリに配置する。
mv kitty-<バージョン>-x86_64 <Kittyのインストールディレクトリ>
ソースコードからインストールする場合
Kittyのビルドに必要な依存関係のライブラリをダウンロードする。
ただし、最新のKittyでは、Python 3.7以降とGo 1.20以降が必要となることに注意する。
sudo zypper install gcc pkg-config dbus-1-devel libXcursor-devel libXrandr-devel libXi-devel libXinerama-devel \
libXcursor-devel libXrandr-devel Mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libX11-devel \
libxcb-devel fontconfig-devel liblcms2-devel libcanberra-devel ImageMagick-devel \
python311-devel python3-Pygments sphinx libsphinxclient-devel python3-Sphinx \
go1.21 \
libb2-devel librsync-devel wayland-devel wayland-protocols-devel
もし、パッケージ管理システムが提供しているlibRsyncライブラリが古い場合、libRsyncライブラリを手動でインストールする必要がある。
libRsyncのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf librsync-<バージョン>.tar.gz cd librsync-<バージョン>.tar.gz
libRsyncをビルドおよびインストールする。
mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=<libRsyncのインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release .. make -j $(nproc) make install
KittyのGithubにアクセスして、Kittyのソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf kitty-<バージョン>-x86_64.txz cd kitty-<バージョン>-x86_64
Kittyをビルドおよびインストールする。
export LD_LIBRARY_PATH="/<libRsyncのインストールディレクトリ>/lib64:$LD_LIBRARY_PATH" && \ export CFLAGS="-I/<libRsyncのインストールディレクトリ>/include $CFLAGS" && \ ./setup.py linux-package --prefix=<Kittyのインストールディレクトリ> # または export LD_LIBRARY_PATH="/<libRsyncのインストールディレクトリ>/lib64:$LD_LIBRARY_PATH" && \ export CFLAGS="-I/<libRsyncのインストールディレクトリ>/include $CFLAGS" && \ make -j $(nproc)
makeコマンドを実行してビルドした場合、Kittyの実行ファイルは以下に示すパスに存在する。
/<Kittyのソースコードディレクトリ>/kitty/launcher/kitty
共通
Kittyのデスクトップエントリファイルを作成する。
vi ~/.local/share/applications/Kitty.desktop
# ~/.local/share/applications/Kitty.desktopファイル [Desktop Entry] Version=1.0 Type=Application Name=kitty GenericName=Terminal emulator Comment=Fast, feature-rich, GPU based terminal TryExec=/<Kittyのインストールディレクトリ>/bin/kitty Exec=/<Kittyのインストールディレクトリ>/bin/kitty Icon=/<Kittyのインストールディレクトリ>/share/icons/hicolor/scalable/apps/kitty Categories=System;TerminalEmulator;
Kittyを使用したURLランチャーのデスクトップエントリファイルを作成する。
vi ~/.local/share/applications/Kitty-Open.desktop
# ~/.local/share/applications/Kitty-Open.desktopファイル [Desktop Entry] Version=1.0 Type=Application Name=kitty URL Launcher GenericName=Terminal emulator Comment=Open URLs with kitty TryExec=/<Kittyのインストールディレクトリ>/bin/kitty Exec=/<Kittyのインストールディレクトリ>/bin/kitty +open %U Icon=/<Kittyのインストールディレクトリ>/share/icons/hicolor/scalable/apps/kitty Categories=System;TerminalEmulator; NoDisplay=true MimeType=image/*;application/x-sh;application/x-shellscript;inode/directory;text/*;x-scheme-handler/kitty;
エラー
変数term
変数termは、様々なソフトウェアがターミナルの機能や動作に関する情報を取得するために使用される。
実行するソフトウェアやターミナルの違いにより、キーの操作、色、その他機能まで、不具合を起こす可能性がある。
Kittyの初期設定では、変数termの値はxterm-kittyとなっている。
もし、なんらかのソフトウェアのコマンドを実行する場合、以下に示すようなエラーメッセージが表示されることがある。
'xterm-kitty': unknown terminal type.
この時、Kittyの設定ファイルに変数termの値を、xtermまたはxterm-256colorに設定する。
vi ~/.config/kitty/kitty.conf
# ~/.config/kitty/kitty.confファイル term xterm-256color # または term xterm
SSH接続
kittyを使用して、terminfoを持たないリモートにSSH接続する場合、矢印キー、Backspace、Delete、Home / End等のキーが効かない場合がある。
これを修正するには、以下に示す手順に従う。
- まず、リモート先のPCに接続する。
- 次に、リモート先のPCにおいて、~/.terminfo/xディレクトリ(Linuxの場合)、または、~/.terminfo/78ディレクトリ(Macの場合)を作成する。
mkdir -p ~/.terminfo/{78,x}
- 最後に、Kittyのインストールディレクトリにあるshare/terminfo/x/xterm-kittyファイルを、上記で作成したディレクトリへコピーする。
scp /<Kittyのインストールディレクトリ>/share/terminfo/x/xterm-kitty <リモート先PCのユーザ名>@<リモート先PCのホスト名またはIPアドレス>:~/.terminfo/x
または、上記の設定を自動化するためのkitty +kittenオプションを付加して、SSH接続を行う。
ただし、kitty +kittenオプションとSSHPassソフトウェアは同時に使用できないことに注意する。
kitty +kitten ssh <ユーザ名>@<ホスト名またはIPアドレス> -p <ポート番号>
Alacritty
Alacrittyのインストール
ビルドに必要な依存関係のライブラリをインストールする。
# CentOS sudo yum install cmake cargo freetype-devel fontconfig-devel libxcb-devel libxkbcommon-devel xcb-util-devel sudo yum group install "Development Tools" # SUSE sudo zypper install cmake cargo freetype-devel fontconfig-devel libxcb-devel libxkbcommon-devel
AlacrittyのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf alacritty-<バージョン>.tar.gz cd alacritty-<バージョン>
または、以下のコマンドを実行して、Alacrittyのソースコードをダウンロードする。
git clone https://github.com/alacritty/alacritty.git Alacritty cd Alacritty
Alacrittyをビルドする。
# X11環境の場合 cargo build --release --features=x11 # Wayland環境の場合 cargo build --release --features=wayland
ビルドが正常に終了した場合、プロジェクトディレクトリにtarget/release/alacrittyファイルが生成される。
生成されたAlacrittyファイルを任意のディレクトリに配置する。
mv target/release/alacritty <任意のディレクトリ>
タブ機能の有効化
Alacrittyはタブ機能が存在しない。
そのため、タブ機能を有効化するには、tmuxを使用する必要がある。
tmuxのビルドに必要な依存関係のライブラリをインストールする。
sudo zypper install make pkg-config bison ncurses-devel libevent-devel
まず、tmuxのGithubにアクセスして、ソースコードをダウンロードする。
https://github.com/tmux/tmux/releases/
ダウンロードしたファイルを解凍する。
tar xf tmux-<バージョン>.tar gz cd tmux-<バージョン>
ビルド用ディレクトリを作成する。
mkdir build && cd build
tmuxをビルドおよびインストールする。
../configure --prefix=<tmuxのインストールディレクトリ> make -j $(nproc) make install
tmuxの設定ファイル(~/.tmux.confファイル)を作成する。
vi ~/.tmux.conf
# ~/.tmux.confファイル
# Set prefix key to c-f instead of default c-b
unbind C-b
set -g prefix C-f
bind C-f send-prefix
set-option -g default-shell <シェルの実行ファイルのパス 例. /usr/bin/zsh>
# toogle last window by hitting again C-f
bind-key C-f last-window
# if multiple clients are attached to the same window, maximize it to the bigger one
set-window-option -g aggressive-resize
# Start windows and pane numbering with index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# re-number windows when one is closed
set -g renumber-windows on
# word separators for automatic word selection
setw -g word-separators ' @"=()[]_-:,.'
setw -ag word-separators "'"
# Show times longer than supposed
set -g display-panes-time 2000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# {n}vim compability
set-option -ga terminal-overrides ",xterm-256color:Tc"
set -g default-terminal "screen-256color"
# Split horiziontal and vertical splits, instead of % and ". We also open them in the same directory.
# Because we use widescreens nowadays, opening a vertical split that takes half of the screen is not worth. For vertical we only open 100 lines width, for horizontal it's 20 columns.
bind-key v split-window -h -l 100 -c '#{pane_current_path}'
bind-key s split-window -v -l 30 -c '#{pane_current_path}'
# Pressing Ctrl+Shift+Left (will move the current window to the left. Similarly right. No need to use the modifier (C-b).
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# Source file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` and `Space to also use copy-pipe
unbind -T copy-mode-vi Enter
unbind -T copy-mode-vi Space
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
# setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# copy text with `y` in copy mode
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# copy text with mouse selection without pressing any key
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel
# emacs key bindings in tmux command prompt (prefix + :) are better than vi keys, even for vim users
set -g status-keys emacs
# focus events enabled for terminals that support them
set -g focus-events on
# Sync panes (Send input to all panes in the window). When enabled, pane borders become red as an indication.
bind C-s if -F '#{pane_synchronized}' \
'setw synchronize-panes off; \
setw pane-active-border-style fg=colour63,bg=default; \
setw pane-border-format " #P "' \
'setw synchronize-panes on; \
setw pane-active-border-style fg=red; \
setw pane-border-format " #P - Pane Synchronization ON "'
# Faster command sequence
set -s escape-time 0
# Have a very large history
set -g history-limit 1000000
# Mouse mode on
set -g mouse on
# Set title
set -g set-titles on
set -g set-titles-string "#T"
# Equally resize all panes
bind-key = select-layout even-horizontal
bind-key | select-layout even-vertical
# Resize panes
bind-key J resize-pane -D 10
bind-key K resize-pane -U 10
bind-key H resize-pane -L 10
bind-key L resize-pane -R 10
# Select panes
# NOTE(arslan): See to prevent cycling https://github.com/tmux/tmux/issues/1158
bind-key j select-pane -D
bind-key k select-pane -U
bind-key h select-pane -L
bind-key l select-pane -R
# Disable confirm before killing
bind-key x kill-pane
# List of plugins
# see this https://github.com/tmux-plugins/tpm to installation
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
tmuxでタブ機能を有効化して、Alacrittyを起動する。
/<Alacrittyのインストールディレクトリ>/alacritty -e /<tmuxのインストールディレクトリ>/bin/tmux