[~user/]$ rm -rf /
rm: it is dangerous to operate recursively on `/'
rm: use --no-preserve-root to override this failsafe
[~user/]$ fuck
sudo rm -rf --no-preserve-root /
I like how you named and styled the command after how many terminal users actually approach these situations.
1. Hurriedly type something to solve a pressing problem. It doesn't work but tells you enough the fix should be obvious to a machine.
2. Mutter or shout "Fuck!" in head depending on how obvious problem was, how often it repeats, or just how long it takes to redo it.
3. Perform the correct action.
Your model is like the Underwear Gnomes model for problem-solving applied to terminals. They always missing step 2. Except, on step 2, you just "fuck" to get profit... err, you get to finish at Step 2 with one word. Finish faster with this technique to move on to next job in workflow.
Of course, the drawback is that the machine doesn't really know what you intended without more context than a single command line. Often it can make a good guess, but not always and sometimes it'll guess wrong, perhaps disastrously so.
Well, it's guessing the intent of a user on command line and trying to fix their problem automatically. I don't expect perfection so much as it working well enough in common situations.
But it asks for confirmation and almost always suggests more than one option. Although it isn't smart enough to remember what you chose and suggest this variant in future.
I use this regularly, for everything ranging from the forgotten sudo (instead of running "sudo !!") to typos across the board.
But it does get me into interesting situations! Just the other day I was demo-ing something to my team + Director of Engg on the projector, and I ran an incorrect command, followed by "fuck" to fix it, leading to so many stares :P
Just as an FYI, you can change the prompt from fuck to something else by changing your .bashrc eg.:
Since https://news.ycombinator.com/item?id=14144814 got locked (which, to provide context for anyone else reading, is why this reply is here in this thread) maybe you could repost it now.
FWIW, this idea in and of itself is worth spending a bit of time on. The page itself is very... basic right now, and I wouldn't discount that this may be one major reason why nobody is taking the concept seriously.
Which makes sense: nobody knows what your areas of specialty and experience are, what you're capable of, and all they've got is this very barebones page. Noone knows what to suggest for you to do!!
Spending some time on the page design and specifying the kinds of things you're capable of - and, most importantly, the things you're most interested in - might just turn things around a fair bit.
Thanks for the ping :) and hopefully you see this.
I note you have not yet put any contact info on that page :P (Gmail happily forwards, and Outlook (which forwards too) also has aliases)
My email is in my profile FWIW. You could also drop your username on the page and tell people to "find your email on HN". That could be a good filter.
It's an interesting proposition. A highly abstracted, very high level, very modal multi-user system where users actually interact instead of being sandboxed.
Keep in mind that "anti-X" stuff tends to resemble the original "X", thus despite the antagonistic name, this is probably not as revolutionary as we will get.
More or less helping move from 'direct manipulation' to delegation. It's not so much that this is moving away from any particular Mac principle so much as towards the sort of system outlined in that essay.
Would be nice to have some form of autocorrect directly in the shell, especially if it was aware of common programs and so could also autocorrect options. Obviously we could think of a few cases with destructive outcomes--but that doesn't make it a bad feature.
git stauts
I mean, git knows enough to ask me "Did you mean this? status".
The Linux kernel seems to have a centisecond obsession too. Probably from way back when HZ was 100 and your computer woke up once every centiseecond to make sure it still had nothing to do.
I once set up a schedule where I would open the gitconfig manpage and read at least one section of the settings. My gitconfig file growed to over 200 lines then.
Quite a lot of stuff isn't very helpful in there though.
A real autocorrect should probably know about all the systems I use, instead of just the one I'm actively using, and help me translate commands from syntax I "expect" to syntax that works for that system. (e.g. translating my zsh pipelines to bash pipelines; suggestion combinations of commands that can substitute for missing builtins; translating between old GNU tar/ps syntax and old BSD tar/ps syntax...)
I added that as an alias in my git config. Even though I usually just type git st (another alias I added), sometimes my fingers type all the letters out and still fuck it up.
Of course, as I'm sure many of you do, too, I've also got a bunch of even shorter bash aliases like gpp (git pull --rebase && git push)
You have the problem too? Everyone comes to me when the get a conflict because they don't read the part that says when you're done, do `git rebase --continue`
An oldie that has been passed around in various incarnations since the 2000s is an alias also called fuck which repeats the last command with sudo. Either coincidence or perhaps it could be where the inspiration for this project came from.
Love it, have thought about it, but my one concern always is that it'll lead to a decrease in my typing skills instead of reinforcing good keying. But fuck, I just need to get stuff done sometimes.
Personally my typo rate has held pretty steady over the last decade, I don't think something like this would have any measurable effect on how well one types.
My concern would be that the extra keystroke to confirm would ingrain the skip confirm (fuck -y, or even just hitting enter before I'm prompted again) into my muscle memory, with potentially disastrous consequences (hence I've never installed this tool).
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> test
$ fuck
git branch --set-upstream-to=origin/test test && git pull [enter/↑/↓/ctrl+c]
Lets see in order to use "fuck" I need to first install it and its dependencies. The caret substitution natively exists in the Bash shell.
Also I know that no matter what system I am on be it OS X or Linux the caret syntax is guaranteed to work.
I don't understand how you think anything can be easier than using the functionality that has existed in the Bash shell shell(or even C shell variants)since forever.
If that were how things worked, we'd never use any new technology. Obviously it is easier to pay a one-time up-front cost than to slog away inefficiently forever.
>"If that were how things worked, we'd never use any new technology"
Nice try. That's a straw man. This isn't new technology. Its simply replicating existing functionality.
>"Obviously it is easier to pay a one-time up-front cost than to slog away inefficiently forever"
Whats the average typo 1 character as in most of the demos for "Fuck"? So I can either type 2 carets and 4 letters for a total of 6 characters or I can type the 4 characters in the word "fuck", how is the former inefficient? Wow, what a slog. I can't imagine what I will do with all the time I will have left over after installing this"
Speaking of straw men, this program does more than simple typo substitution. The listed examples include prepending sudo and using git-suggested commands.
Well, yes it is, because again, I was just giving examples. Look at the list under "how it works" in the readme, and there's plenty of items there that aren't simple substitution. It'd be a lot easier to just 'fuck' for most of those than have to mentally parse what you need to do to 'fix it'.
Yes for some use cases. On my keyboard setup it is significantly faster to type four common characters than to think about and type two ^ between substitutions.
^ substitution is more precise and I think it is an under appreciated tool, but I don't think that negates the usefulness of thefuck.
For those who don't know, you can make git pish have the same effect as git push by creating an alias between pish and push. Useful to do for any misspellings you make more than once.
I've actually done this for a couple commands I screw up often enough -- I have this in my bashrc:
alias dumbtypo="echo 'LEARN TO TYPE, MORON'"
alias sl="dumbtypo; ls"
alias rbuy="dumbtypo; ruby"
alias pytohn="dumbtypo; python"
alias brwe="dumbtypo; brew"
alias arhcey="dumbtypo; archey"
You have a giant list of common typos, making you a worse and worse typer as years go on, until you are mashing your head on the keyboard to type anything.
I dunno, I don't think that would really happen. I'm always trying to type the same word (I don't say "pish" in my head, after all, I think "push"), so it doesn't seem to be a random walk away from correctness, just some wavering around it. And it's not like I have that many commands I need to type commonly enough to make an alias for-- maybe a couple dozen? And for most of them, I don't make typos so I don't feel the need to make an alias.
My bashrc has so many of these, and they're probably among the most common commands I use daily!:
alias gs="git status"
alias gb="git branch"
alias grh="git reset --hard"
alias gcdf="git clean -df"
alias gf="git fetch"
alias gp="git pull"
alias gdom="git diff origin/master"
alias gdomn="git diff --name-status origin/master"
alias gd="git diff"
alias gl="git log"
alias glm="git log --author <my_name>"
alias gc="git checkout"
alias gcm="git checkout master"
Am I a bad person for creating SVN-style aliases for git?
From my .gitconfig:
[alias]
st = status
ci = "!git add -u && git commit"
di = diff
I come from an SVN background, I've since switched to Mercurial for my personal projects, and intensely dislike git, but have to use git at work, so I finally said "enough is enough" and made aliases so I can use git like svn/hg.
Oh dear. That reminds me of a story I saw here on HN at some point (might have been in the comments) about a dev team that didn't insist on any commit messages in their VCS, so everyone just put in a '.' to meet the requirement that a commit had to have a message for whatever source control system they were using.
My team doesn't have a strict commit message style guide, but good god it better be at least mildly descriptive of what's in the commit.
(I know you're joking, the thought of a 3 character alias to commit with a dummy message just sent shivers down my spine :)
Git even has a wonderful autocorrect feature that you can enable with
"git config --global help.autocorrect 1"
This fixes commands like git pish or git ermote