この分野では、fzfやpecoが有名ですが、もっと粒度の低い(?)再利用をしたい場合のメモ
1. 直前の最後の引数を再利用(!$)
| 12
 3
 4
 
 | $ diff .ssh/config /home/username/.ssh/config
 $ chmod 600 !$
 chmod 600 /home/username/.ssh/config
 
 | 
2. 直前の全ての引数を再利用(!*)
| 12
 3
 4
 
 | $ diff .ssh/config /home/username/.ssh/config
 $ cp !*
 cp .ssh/config /home/username/.ssh/config
 
 | 
3. 1と2の合わせ技
| 12
 3
 4
 5
 6
 7
 
 | $ diff .ssh/config /home/username/.ssh/config
 $ cp !*
 cp .ssh/config /home/username/.ssh/config
 
 $ chmod 600 !$
 chmod 600 /home/username/.ssh/config
 
 | 
4. 直前のコマンド全てを再利用(!!)
| 12
 3
 4
 5
 6
 7
 
 | $ ls -l /rootls: ディレクトリ '/root' を開くことが出来ません: 許可がありません
 
 $ sudo !!
 sudo ls -l /root
 合計 0
 $
 
 | 
5. historyから再利用
| 12
 3
 4
 5
 6
 7
 8
 
 | $ history | tail -n 3423  ls -l /root
 424  sudo ls -l /root
 425  history | tail -n 3
 
 $ !423
 ls -l /root
 ls: ディレクトリ '/root' を開くことが出来ません: 許可がありません
 
 | 
;や&で通常のコマンド実行と同じ扱いでも実行出来ます
| 12
 3
 4
 5
 
 | $ !423;!424ls -l /root
 ls: ディレクトリ '/root' を開くことが出来ません: 許可がありません
 sudo ls -l /root
 合計 0
 
 |