Why? I use the terminal but i have no idea how cli commands would get so distracting you have to parental lock yourself out of them like its entertainment or social media
I have a small post command hook in fish that looks at arg0 and prints out any associated reminder for the program I just used. I use it to remind myself that I'm testing an alternative (e.g I used grep today, and it printed out a reminder that I have rg installed). I guess it could be used as a harsher version of that.
Woah thanks for all the comments everyone! To answer a recurring question: this is to prevent things from being called from bemenu (and its ilk) - definitely could have made that clearer in the README. Hopefully that clears up a lot of things.
Why have a dependency on Zenity instead of displaying the message in the terminal? Seems weirdly limiting to have a GUI dependency for a terminal application thus making this unusable on headless systems. I think you could make it optional and use STDERR if Zenity's not around.
Yeah I’ve used this strategy simply to avoid accidents. If not for me, but also for others. On an old source control server, backed up of course, avoiding an errant “rm” or something else stupid can still save me hours of restore work, the outage and the RCA.
So, I love that the README is nearly as long as the code itself.
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! :-)
I think it's more an example of a "why did I just cd ls cd ls cd ls that directory tree instead of leveraging tab completion" type thing than "man, I gotta get over my ls addiction or I won't be able to provide for my family".
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.
> why did I just cd ls cd ls cd ls that directory tree instead of leveraging tab completion
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.
This is why I like GUIs. Seeing the files that are modified in my git gui reminds me of what Im doing instead of running git status. And seeing all the available things I could do is more stimulating than having to keep coming up with the text
commands to type.
This popped up on HN last week: https://github.com/mieubrisse/cmdk I don't really get it but apparently some people really have issues with ls and cd and feel they use them too much.
> 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.
I wrote a similar piece of software but it just limits time spent on certain web sites per day.
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.
Frog put the cookies in a box. “There,” he said. “Now we will not any more cookies.”
“But we can open the box,” said Toad.
“That is true,” said Frog.
Yes. It's still helpful.
The same arguments apply to, for example, leading-underscore names in Python code.
"That is true," replied a commenter. "But it has successfully worked for breaking my bad habits in the past."
Why? I use the terminal but i have no idea how cli commands would get so distracting you have to parental lock yourself out of them like its entertainment or social media
On window managers like i3 or sway, you launch programs (including GUI applications) via their shell command in an autocompleting micro-menu.
I have a small post command hook in fish that looks at arg0 and prints out any associated reminder for the program I just used. I use it to remind myself that I'm testing an alternative (e.g I used grep today, and it printed out a reminder that I have rg installed). I guess it could be used as a harsher version of that.
Ban yourself from vim so you don't get stuck in it for hours?
Some people get distracted by work and not social media during their down time
Lvoe
Woah thanks for all the comments everyone! To answer a recurring question: this is to prevent things from being called from bemenu (and its ilk) - definitely could have made that clearer in the README. Hopefully that clears up a lot of things.
Why have a dependency on Zenity instead of displaying the message in the terminal? Seems weirdly limiting to have a GUI dependency for a terminal application thus making this unusable on headless systems. I think you could make it optional and use STDERR if Zenity's not around.
I assume it's meant to work for programs that aren't being launched from the terminal
My question exactly, minus the optional part. If it's a command-line tool, it should not require any GUI elements at all.
Yeah I’ve used this strategy simply to avoid accidents. If not for me, but also for others. On an old source control server, backed up of course, avoiding an errant “rm” or something else stupid can still save me hours of restore work, the outage and the RCA.
So, I love that the README is nearly as long as the code itself.
Shorthand:
...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! :-)
> "Hey, maybe I do run `ls` too much..."
This cant be a though someone has ever had. Your telling me people are getting addicted to the ls command?
I think it's more an example of a "why did I just cd ls cd ls cd ls that directory tree instead of leveraging tab completion" type thing than "man, I gotta get over my ls addiction or I won't be able to provide for my family".
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.
> why did I just cd ls cd ls cd ls that directory tree instead of leveraging tab completion
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.
This is why I like GUIs. Seeing the files that are modified in my git gui reminds me of what Im doing instead of running git status. And seeing all the available things I could do is more stimulating than having to keep coming up with the text commands to type.
For that I use Git Cola[1], it is quite nice.
[1] https://git-cola.github.io/
Come to think of it, I would probably benefit from rate-limiting myself on `git status`.
I am. Every time I cd I ls even though I know what's in there.
This popped up on HN last week: https://github.com/mieubrisse/cmdk I don't really get it but apparently some people really have issues with ls and cd and feel they use them too much.
Bad habits do happen. I forced myself out of `sudo su` and into `sudo -i` by configuring my sudo rule to allow any command except `su`.
I'm addicted to sl. I love those trains.
wish the README showed an example of what trying to use a banned command looked like.
rather than this being useful to stop "distracting" commands i see this being useful in stopping agents from calling `rm` for example
> 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.
oh i see, it installs a bash script in a PATH thats a higher priority than the real one.
> ban ban
Haha, this is fun
What if I ban ban
kind of cool. like "App/Time Limits" in Apple
I wrote a similar piece of software but it just limits time spent on certain web sites per day.
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.
What if I ban rm too?
You will not be able to use the command. I am not sure if other scripts could, however. I have not checked the implementation.