Shorthand:
PATH=$HOME/.bans:$PATH # (prefix path with "banned" cmd-dir)
printf "echo 'bad!'" > "$HOME/bans/some-cmd" # (make `some-cmd` run `echo 'bad!'`)
...and then some goodies around tracking, reasons, etc... some niftiness around "auto-expiring" the banned command (self-deletes the "bad" shell script that's shadowing the actual command usage).As to the sibling "why?" ... it's trivial to circumvent: `ban ls "I run it too much..."`, `/bin/ls` is still unaffected, `rm ~/.bans/ls`, etc... but I _do_ like the pause to allow a return to rationality, eg: "Hey, maybe I do run `ls` too much..." and then deciding how to proceed.
It'd probably be nicer if it did something like `(Bad) Chrome.app/*` on OSX, but as an exercise in shell gymnastics, I'm kindof all here for it! :-)
This cant be a though someone has ever had. Your telling me people are getting addicted to the ls command?
I've found myself doing similar hints to nudge more efficient-but-less-exercised things into my day to day usage. E.g. making /etc/crontab a comment to get more used to creating systemd timers instead. Otherwise I'd just do it without thinking.
Sometimes I find myself repeatedly ls'ing even though I'm making good use of tab completion. There's something about seeing the names that helps with remembering what I was going to do.
cd /etc/c<tab><tab>...
can list the names similar to cd /etc/<enter>ls c*<enter>cd c...
but there will always end up being times an actual ls is the right call, just not necessarily as ones default method.It's amazing how much something so simple can change your life if you have a problem with that. I'd highly recommend everyone enable it. I think iOS has something like that built in too so you don't even need my stuff unless you're on eg Linux.
“But we can open the box,” said Toad.
“That is true,” said Frog.
The same arguments apply to, for example, leading-underscore names in Python code.
rather than this being useful to stop "distracting" commands i see this being useful in stopping agents from calling `rm` for example
I used to do that kind of thing a long time ago. MS-DOS wouldn't ask for confirmation when deleting files, so I'd use a hex editor to rename the del command, then create a batch file named del.bat that would ask if you really wanted to remove the file. Even had something like the recycle bin at one point to prevent accidental deletes.
You could even set up some very weak security by renaming commands like ls/dir and it could keep some casual snoops out of your system or prank/annoy someone else by replacing their commands to make them do funny things.
samrus•6h ago
haiku2077•6h ago
hk1337•5h ago
kjkjadksj•3h ago
ABU_ALLIL_123•2h ago
accoil•2h ago