From 88c21b27d67a796d991e2dbe6fa48f17a5e79604 Mon Sep 17 00:00:00 2001 From: Bonnie I-Man Ng Date: Fri, 18 Oct 2019 18:22:19 +0800 Subject: [PATCH] add commands for 'others' section bash auto-complete, fc --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index b0d7aeb..e44203e 100644 --- a/README.md +++ b/README.md @@ -2189,6 +2189,15 @@ hostnamectl set-hostname "mynode" ## Others [[back to top](#handy-bash-one-liners)] +##### Bash auto-complete (e.g. show options "now tomorrow never" when you press'tab' after typing "dothis") +[Detailed tutoral](https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial.html) +```bash +complete -W "now tomorrow never" dothis +# ~$ dothis +# never now tomorrow +# press 'tab' again to auto-complete after typing 'n' or 't' +``` + ##### Repeat printing string n times (e.g. print 'hello world' five times) ```bash printf 'hello world\n%.0s' {1..5} @@ -2360,6 +2369,12 @@ speaker-test -t sine -f 1000 -l1 history -d [line_number] ``` +##### Interacting with history +```bash +# list 5 previous command (similar to `history |tail -n 5` but wont print the history command itself) +fc -l -5 +``` + ##### Get last history/record filename ```bash head !$