add commands for 'others' section

bash auto-complete, fc
This commit is contained in:
Bonnie I-Man Ng 2019-10-18 18:22:19 +08:00 committed by GitHub
parent 895c9dab1f
commit 88c21b27d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2189,6 +2189,15 @@ hostnamectl set-hostname "mynode"
## Others ## Others
[[back to top](#handy-bash-one-liners)] [[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) ##### Repeat printing string n times (e.g. print 'hello world' five times)
```bash ```bash
printf 'hello world\n%.0s' {1..5} printf 'hello world\n%.0s' {1..5}
@ -2360,6 +2369,12 @@ speaker-test -t sine -f 1000 -l1
history -d [line_number] 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 ##### Get last history/record filename
```bash ```bash
head !$ head !$