112 points · by BerislavLopac · 8y ago · 61 comments
https://github.com/Detry322/git-psuh
Why make errors do the thing you want, when you can make them do things you don't want? ¯\_(ツ)_/¯
Carpenters have "measure twice, cut once", since there's risk involved with a mistake. Let's make mistakes risky.
Ir ordered 42 m and got a parcel with 18 m in the mail, apparently the person who processed the order mistook the order sequence number - 18 - for the ordered amount. I notified the supplier about this mistake, added some photo's of the cable - which is helpfully marked in meter-increments - and told them to send a new cable as I ordered 42 m.
The supplier sent 24 m of cable.
That said, if mistyping ‘git push’ is a common occurrence, why not just define an alias?
git config --global help.autocorrect 1
Although I also alias gti—>git...so it's not just me then? I feel better now, thanks :)
$ echoo "hi"
-bash: echoo: command not found
$ fc # this will open your editor to fix the command.
echo "hi"
hi some_long_commnd^C
some_long_command --wthi^C
some_long_command --with these --optoin^C
some_long_command --with these --options
It might be that I just type fast - I do - or it might be that the cognitive load imposed by using 'helpful' tools like these is higher than the simple act of machine-gun-typing out a corrected version of the command.Repeatedly typing out a command also has a bit of a satisfying "now you listen to _me_ you frickin' pile of silicon" to it, maybe that plays a role as well. On the other side it could be viewed as a form of self-flagellation, doing penance for the sin of not typing out the correct version in the first place. Whatever its virtues, it seems to work for me.
Example:
?clantopplayers
aliases=["clanplayerscharts","clanplayers","calntopplayers","calnplayerscharts","calnplayers", "clantoplayers"]
>aptget install oops
ERROR!!
>^t^t-
>apt-get install oops
WIN
but thefuck saves me 2 precious keystrokes (even more when I change the command from "fuck" to "f!").That blew my mind and cut a lot of mistakes!
Perhaps it work better inside zsh/fish autocorrection, extended it to another level :-)
Obviously such corrections should be used judiciously.
Don't get me wrong, I love the command line because there isn't a more powerful interface, but I'm appalled to see that there aren't any attempts to make it better. 70 years isn't enough to come up with something better?
For me, this is the single biggest use case for thefuck:
$ git push
fatal: The current branch my-branch-name has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin my-branch-name
$ fuck
git push --set-upstream origin my-branch-name [enter/↑/↓/ctrl+c]
(enter)
I'm pretty unrepentant about that one - I _could_ waste brain cells on keeping track of whether my branch already exists upstream, and I _could_ waste keystrokes typing out the more verbose command myself. But I'm not gonna. Life's too short. git config --global push.default currentYou must be kidding here. CLI is like speech only if imagine you are in a completely dark room full of people, and you can't talk to anyone unless you know their name and their job description, and although you can get a list of names, you need to figure out the job descriptions yourself.
On top of all that, everyone speaks a slightly different dialects, the adjectives and verbs are slightly out of order. And although that's not hard to memorize, you have to speak flawlessly in order to be understood.
Because the human is not friendly and has near 0 margin for error.
> The way we've dealt with speaking is just learning to speak clearer,
No, the way we've dealt with that is also to understand less clear speech.
Doo u undrstnd mi? None of those words were even actually correct yet I imagine most people had a good guess at what I said.
An unfriendly human interface that acts like many CLIs:
Hello I'd like a burger
NOT UNDERSTOOD I'D
Hello, can I have a burger?
NOT UNDERSTOOD CAN
Hello, burger?
ERROR ITEM BURGER NOT FOUND
Hello, cheese burger please
Good evening sir, thank you for placing your order.
As an Emacs (EXWM) user I agree that pure CLI is limited and pure text-based interfaces without terminal emulators limits are far superior but... Well, today outside Emacs we only have CLIs, the rest is so limited and limiting that can be used only for desktop end-user stuff. Even Microsoft Windows mandate CLI for serious system use/management...
Is your TAB key broken?
Do the letters `ls` and `grep` not work on your keyboard?
anyway, for accidental files operation protection nilfs2 is a very effective protection, despite super-slow development and actual limited features, it's rock-solid, mainline, live resizable (both grow and shrink) and in years does not loose a bit of information for me :-)
The `git publish` alias eliminated the vast majority of my thefuck usage.