|
|
Subscribe / Log in / New account

New features in the fish shell

New features in the fish shell

Posted Sep 30, 2020 20:06 UTC (Wed) by szm (subscriber, #100120)
In reply to: New features in the fish shell by Paf
Parent article: New features in the fish shell

In addition to the sensitive information / password use-case already mentioned, I've picked up the habit of excluding potentially catastrophic and destructive commands like, let's say,

rm -rf ./*

or dropping database tables, etc. from the search history. Before learning about history suppression in my younger years (i.e. back when I tended to be prone to getting nervous during an incident with a critical system or when I sometimes would grow impatient while working over high-latency ssh connections), I've had several jump-scares when, by "typing ahead" not only commands but retrieving items from the history with the arrow keys, found that I accidentially ended up with the "interesting side-effects if run here and now" kind of command. Luckily always before hitting enter, but still.

It's not a fool-proof system, but I find it quite useful in the "better safe than sorry" kind of way.

Cheers,
szm


to post comments

New features in the fish shell

Posted Oct 1, 2020 0:02 UTC (Thu) by Paf (subscriber, #91811) [Link]

Interesting, thanks!

New features in the fish shell

Posted Oct 3, 2020 6:44 UTC (Sat) by marcH (subscriber, #57642) [Link] (1 responses)

> rm -rf ./*

Agreed 200%: I recalled by mistake commands like these from my (crazy long) bash history once or twice and now I'm trying hard to never let them get there in the first place.

Another trick I use (better safe twice than sorry) is this:

rm -rf ../current_directory/*

With completion it takes barely longer to type and it greatly reduces the chances of that command doing anything if recalled by accident.

Finally, there is of course:

mv * ~/Trash/

Only the last one would probably have stopped me from recursively deleting the target of a symbolic link while thinking I was just deleting the link itself...

New features in the fish shell

Posted Oct 3, 2020 17:51 UTC (Sat) by jo42 (subscriber, #59640) [Link]

Zsh has the helpful feature to filter history entries. Defining the function zshaddhistory to stop some commands going into the history file:

zshaddhistory()
{
# Don't save run-help and kill commands and commands run in bad-stuff
[[ $1 != (run-help *|kill *|bg|fg|cd|reboot|halt) && $PWD != $HOME/bad-stuff/* ]]
}


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds