sh: Add clear and rerun function

Added simple function to clear the screen but additionally re-run the
last executed command.

Mirroring my clear screen alias `cl`, this one is executed with `cll`
(clear-and-last) currently.

It comes in useful for me every now and again because I sometimes just
need a quick way to get rid of 'clutter' on my terminal (e.g. running
multiple rg invocations after each other, or diffs, or anything that
spews a bunch of stuff on screen and I want to find specific things
afterwards).
I am very used to running `cl` and then the second to last history item.
This makes those additional keystrokes unnecessary.
This commit is contained in:
Marty Oehme 2024-06-05 12:10:26 +02:00
parent b8cbc8bc5d
commit 7eeeb9e85d
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -43,6 +43,14 @@ alias md="mkdir -p"
# clear my screen
alias cl="clear"
# clear screen AND re-run last command
# Is presumably not fully portable, see
# https://overflow.hostux.net/questions/24223811/getting-last-executed-command-from-script#
cll() {
lastfun="$(fc -n -l -1 -1)"
clear
eval "$lastfun"
}
# Display current external ip address
alias myip="curl -s icanhazip.com"