キーボードショートカット

提供: ArchWiki
2015年8月9日 (日) 16:34時点におけるKusakata (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

この記事では (あまり有名でない) デフォルトのキーボードショートカットのリストとユーザーカスタマイズの情報を提供します。

標準のショートカット

カーネル

カーネルにはローレベルなショートカットが複数実装されており、システムが反応しなくなったときに復旧させたりデバッグするのに用いることができます。いつでも使うことができますが、特に、電源ボタンを長押しして無理やりシステムの電源を切るよりかはショートカットを使うほうが推奨されます。

カーネルショートカットを使うには、最初に sysctl kernel.sysrq=1 または echo "1" > /proc/sys/kernel/sysrq でショートカットを有効にしておく必要があります。起動時に有効化されるようにするには、/etc/sysctl.d/99-sysctl.conf を編集して kernel.sysrq = 1 と設定してください。

覚え方は "Reboot Even If System Utterly Broken" です ("REISUB" とも呼ばれます)。もしくは "BUSIER" の反対として覚えましょう。

キーボードショートカット 説明
Alt+SysRq+r Unraw キーボードの制御を X から取り戻す。
Alt+SysRq+e Terminate 全てのプロセスに SIGTERM を送り、丁寧にプロセスを終了させる。
Alt+SysRq+i Kill 全てのプロセスに SIGKILL を送り、即座にプロセスを強制終了させる。
Alt+SysRq+s Sync データをディスクに書き込む。
Alt+SysRq+u Unmount 全てのファイルシステムをアンマウントして読み取り専用で再マウント。
Alt+SysRq+b Reboot 再起動
ヒント:
  • ディスプレイマネージャを使っていて Alt+SysRq+e でログイン画面が表示される場合 (もしくは自動ログインが有効になっていてデスクトップが表示される場合)、サービスファイルRestart=always ディレクティブが原因です。必要ならば、ユニットを編集してください。ただし "REISUB" シーケンスを止めることはできません。
  • 上記の組み合わせで Alt+SysRq+b だけ動作しない場合、反対側の Alt キーを使ってみて下さい。
  • On laptops that use Fn key to differentiate SysRq from PrtScrn, it may not actually be necessary to use the Fn key (i.e., Alt+PrtSc+letter could work).

詳しくは Wikipedia のマジック SysRq キーを見て下さい。

ターミナル

仮想端末

キーボードショートカット 説明
Ctrl+Alt+Del コンピュータを再起動 (specified by the symlink /usr/lib/systemd/system/ctrl-alt-del.target)
Alt+F1, F2, F3, ... n 番目の仮想端末にスイッチ
Alt+ ← 前の仮想端末にスイッチ
Alt+ → 次の仮想端末にスイッチ
Scroll Lock Scroll Lock が有効になっているとき、入出力がロックされます
Shift+PgUp/PgDown コンソールバッファを上下にスクロール
Ctrl+c 現在のタスクを終了
Ctrl+d EOF を挿入
Ctrl+z 現在のタスクを停止

Readline

GNU readline is a commonly used library for line-editing; it is used for example by Bash, FTP, and many more (see the details of readline package under "Required By" for more examples). readline is also customizable (see man page for details).

キーボードショートカット 説明
Ctrl+l 画面をクリア
カーソルの移動
Ctrl+b Move cursor one character to the left
Ctrl+f Move cursor one character to the right
Alt+b Move cursor one word to the left
Alt+f Move cursor one word to the right
Ctrl+a Move cursor to start of the line
Ctrl+e Move cursor to end of the line
コピー & ペースト
Ctrl+u Cut everything from line start to cursor
Ctrl+k Cut everything from the cursor to end of the line
Alt+d Cut the current word after the cursor
Ctrl+w Cut the current word before the cursor
Ctrl+y Paste the previous cut text
Alt+y Paste the second latest cut text
Alt+Ctrl+y Paste the first argument of the previous command
Alt+./_ Paste the last argument of the previous command
履歴
Ctrl+p Move to the previous line
Alt+n Move to the next line
Ctrl+s Search
Ctrl+r Reverse search
Ctrl+j End search
Ctrl+g Abort search (restores original line)
Alt+r Restores all changes made to line
補完
Tab Auto-complete a name
Alt+? List all possible completions
Alt+* Insert all possible completions

X11

キーボードショートカット 説明
Ctrl+Alt+F1, F2, F3, ... n 番目の仮想端末にスイッチ
Shift+Insert
Mouse Button 2
選択されたテキストをクリップボードにコピー、もしくはクリップボードから貼り付け

ユーザーカスタマイズ

Readline

This example adds keys that allow (in vi-mode) to search backward through the history for the string of characters between the start of the current line and the point. This is a non-incremental search.

.inputrc
set editing-mode vi
set keymap vi-insert
"\C-r": history-search-backward
"\C-e": history-search-forward

X11

一般的なショートカットや、デフォルトで無効になっているショートカットは Xorg でのキーボード設定#よく使われる XKB オプションを見て下さい。

Firefox

customizable-shortcuts アドオンを使ってください。

X-selection-paste のキーバインディング

マウスよりもキーボードを好んで使用する場合、マウスの中ボタンでペーストを行うキーバインドが役に立つかもしれません。特にキーボードを集中的に使う環境では有用です。ワークフローを以下のようになります:

  1. In Firefox, select a string you want to google for (with the mouse).
  2. Hit Ctrl+k to enter the "Google search" field.
  3. Hit F12 to paste the buffer, instead of moving the mouse pointer to the field and center-click to paste.
ノート: Shift+Insert has a similar yet different functionality, see #X11: Shift+Insert inserts the clipboard buffer, not the x-selection-paste buffer. In some applications, these two buffers are mirrored.

ここでは公式リポジトリにある3つのパッケージを使います:

  • xsel to give access to the x-selection-buffer content.
  • Xbindkeys to bind a key-stroke to an action.
  • xvkbd to pass the buffer string to the application by emulating keyboard input.

This example binds the x-selection-paste operation to the F12 key:

.xbindkeysrc
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
    F12

The "\D1" code prefixes a 100 ms pause to inserting the selection buffer (see the xvkbd home page).

ノート: Depending on your X configuration, you may need to drop the -xsendevent argument to xvkbd.

The key codes for keys other than F12 can be determined using xbindkeys -k.

References:

XMonad Window Manager

In the xmonad window manager there is a built-in function to paste the x-selection-buffer content. In order to bind that function to a key-stroke (here Insert key) the following configuration can be used:

xmonad.hs
import XMonad.Util.Paste
...
  -- X-selection-paste buffer
  , ((0,                     xK_Insert), pasteSelection) ]

Using xdotool - command-line X11 automation tool

With the xdotool it is possible to create a short cut which actually paste the content of the X-Selection buffer via triggering the middle mouse button. Instead of hit the text as separate key strokes. The command for the short cut is:

xdotool getwindowfocus key --window %1 click 2

The command get the window which has focus from the xserver and triggers a click of button 2 which is the middle mouse button.

Tips and tricks

参照