The Fuck – An app which corrects your previous console command
github.com
github.com
[~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 /
fuck! alias just=sudo
just fuck -me -up1. 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.
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.:
eval "$(thefuck-alias fixit)"
I'm not changing my alias though! ;) >$ make me a sandwich
permission denied
>$ fucking make me a sandwich
[or]
>$ fucking !! # Because sometimes you gotta be harsh.
alias fucking="sudo"
# And sometimes you gotta be nice.
alias please="sudo"My brain nearly double faulted from learning new things too fast. Great thread.
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.
> fsck
ERROR: volume / is mounted with write access. Re-run with (-l) to freeze volume.
> fuck
No fucks givenKeep 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.
git stauts
I mean, git knows enough to ask me "Did you mean this? status".
The value is in 0.1s (centiseconds) of seconds. So 20 means 2 seconds.
[help]
autocorrect = 20
OR run git config --global help.autocorrect 20
1. Conventional units.
2. Don't follow the XDG basedir spec for config files.
3. Make inconsistent command line flags.
4. Don't allow control of color output using a flag thinking they are smarter than me.
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)
alias fuck='sudo $(history -p \!\!)'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).
^bar^baz
Although I think the name might be more descriptive. $ 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]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.
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"
Which you can get by typing:
sudo !!
and git completion is in contrib:https://github.com/git/git/tree/master/contrib/completion
Not really a strawman is it?
^ substitution is more precise and I think it is an under appreciated tool, but I don't think that negates the usefulness of thefuck.
$ git pish
$ fuck
$ git config --global alias.pish push
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"I can't not-type it.
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" alias b='/usr/local/bin/git checkout -b'
alias a='/usr/local/bin/git add
alias d='/usr/local/bin/git diff HEAD'
alias c='git commit -m'
alias i='/usr/local/bin/git pull origin'
alias o='/usr/local/bin/git branch -avv | grep "\*" | cut -d\ -f 2 | xargs -n 1 /usr/local/bin/git push -u origin'
plus: alias g='/usr/local/bin/git log --graph --oneline --decorate
alias v='/usr/local/bin/git branch -avv'--all'
alias h='/usr/local/bin/git log -p'
can be useful.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.I only use a few git aliases, most things I'd rather type out.
It's just so much quicker to recall stuff: [g]it [s]tatus :)
alias goto='git checkout'
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 :)
$ cat << EOF > ~/.commit_reasons; strfile ~/.commit_reasons
Testing...
%
Testify...
%
Testarossa...
%
Does it work yet?
%
How bout now?
%
Oops.
%
Fixed a thing.
%
EOF
$ fortune ~/.commit_reasons | cowsay | git -F -$ git poop
git pull upsteam dev
Create an issue about that in https://github.com/nvbn/thefuck/issues