>I quite often type git then go away and come back, then type a full git status after it.<p>Does anyone else actually do this besides OP. I've never heard of this problem until now.
I want a terminal that highlights things it thinks are off. Like when I type cd cd or git git. But I don't want it to auto fix nor wait until the command is issued to complain.<p>This is because I want to be the sole controller of what command is actually issued. Call me an old curmudgeon but I just don't trust the auto fix solutions.<p>Edit: had no idea about Fish. Thank you, all.
Why type out `git status`? I use `gst`, and lots of other great aliases provided by the [oh-my-zsh git plugin](<a href="https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh" rel="nofollow">https://github.com/robbyrussell/oh-my-zsh/blob/master/plugin...</a>)
The mathematical term for a function that is the same when applied multiple times giving you the same results is called "idempotent" which translates to "same power". f^n(x)=f(x) for some positive natural number n and any x.<p><a href="https://en.wikipedia.org/wiki/Idempotence" rel="nofollow">https://en.wikipedia.org/wiki/Idempotence</a>
You can also just use 'fuck' for this:<p><pre><code> > git git pull
git: 'git' is not a git command. See 'git --help'.
The most similar command is
init
> fuck
git pull [enter/↑/↓/ctrl+c]</code></pre>
Author missed an opportunity to title this "Git git Git git git git Git git."<p><a href="https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo" rel="nofollow">https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal...</a>
Quite often, I accidentally press the space bar eagerly when typing git commands:<p><pre><code> $ gi tstatus
</code></pre>
To fix this, I've added the following to my .bashrc:<p><pre><code> gi() {
args=("$@")
args[0]=${args[0]/t/}
git "${args[@]}"
}
</code></pre>
It also works if you drop the "t" altogether.
> git config --global alias.git '!exec git'<p>Is the exec really required?<p><pre><code> git config --global alias.git '!git'
</code></pre>
Will also work. Am I missing something?<p>EDIT:
From git doc,
"If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command"<p>So exec is not required then.
erm, "git git foo"; in most shells can be fixed with "!*" as your next command. Repeat until lameness subsides.<p>Seriously though, I don't understand why people want to hide obvious errors like this - I'd much rather have the tool fail to execute than potentially perform some action I wasn't expecting.
I never had the problem mentioned in the article, but for misspelled commands I trust git autocorrect:<p>git config --global help.autocorrect 1<p>It will run the correct misspelled command after 100ms.
For example git stauts will be corrected automatically to git status
<a href="http://schacon.github.io/git/git-config.html" rel="nofollow">http://schacon.github.io/git/git-config.html</a>
While the cleverness is admirable, there comes a point in your life when you realize you really do always want your own errors to fail loudly and immediately.
Here are a number of great aliases that people might find helpful:<p><a href="http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/" rel="nofollow">http://durdn.com/blog/2012/11/22/must-have-git-aliases-advan...</a>
`!exec git` caused my shell to exit. I have a lot of stuff wrapping git in my shell though (including a bash function wrapping git itself!). The author himself only pushed up the change to his own gitconfig a few hours ago. It was previously `!$SHELL -c \"git $*\"`.<p>My version that works for my setup is `"!f() { git \"$@\"; }; f"`.<p>Hope this helps anyone who ran into the same issue, although I'm not 100% confident about the quoting.<p>EDIT: fixed the quoting, as per cryptonector's suggestion<p>EDIT2: need to quote the quotes for gitconfig to use it correctly
Well... If you have this problem (I really don't), then you probably have it with more than just git, and the proposed workaround would be "a local solution to a global problem".
Reminds me of this Python line:<p><pre><code> decorator = decorator(decorator)(decorator)
</code></pre>
<a href="https://github.com/darius/sketchbook/blob/master/misc/decorator.py" rel="nofollow">https://github.com/darius/sketchbook/blob/master/misc/decora...</a><p>There was a subtle bug when leaving out the last (decorator). I know, it's very silly.
I have homegrown aliases
like 'tags' 'rdel' (git push origin --delete) 'ldel' (git branch --delete) and many more combined with Zsh's (Oh my Zsh)'s several aliases (e.g ggpull, glog, gp, gc) etc.<p>I also find "thefuck" is interesting but I love to control my fate :) (<a href="https://github.com/nvbn/thefuck" rel="nofollow">https://github.com/nvbn/thefuck</a>)
Why type the singular, "git", so many times? We all know that you mean the plural "gits"!<p><pre><code> alias gits='git status'</code></pre>
This reminds me of something I read long ago that was along the lines of "make the computer change for you, don't change for the computer". As such, I have a small list of common typo's that I make that alias themselves to their correct forms.<p>Since then, I've found that these aliases have been the best workflow improvement I've ever made.
This is nice specifically because of the way the author uses `exec`. Without meaning to be patronizing, there must be lots of people reading the thread who don't know what `exec` does, and why it's a neat solution to this problem (or non-problem, whatever your view is); I'd say do look it up if you're interested in programming.
I sometimes have this problem but I hate solutions like this because I figure if I make this kind of mistake, I'm not paying sufficient enough attention to what I'm doing at the moment.<p>I take a minute, clear out distractions and then come back to what I'm working on.
The danger of this is if you accidentally write 'git git something' into a shell script and it works on your machine, then you commit the script to a repo and it doesn't work for anyone else.<p>I suppose this is a problem with any alias.
It would be cool if you could generalize this for anything (e.g. ls ls -al). That being said, I wonder if there's any actual command-line utilities that actually use a similar syntax to perform something useful.
great minds think alike? I've had this exact system for a long time: <a href="https://github.com/jes5199/git-git" rel="nofollow">https://github.com/jes5199/git-git</a>
There is a GitHub repository full of neat tricks like this: <a href="https://github.com/GitAlias/gitalias" rel="nofollow">https://github.com/GitAlias/gitalias</a>
I often type "git stats" but I've never felt the need to go through all of this just because I'm lazy. Then again maybe that's an ironic example of laziness.
Why is this a problem? Is the author blind? If this happens with git then surely it happens with every command. What about "rm"? What if I type "rm -Rf", leave, then come back and type something else? Maybe a better solution is to change behaviour, or if there really is some reason for this behaviour, have something delete the currently entered command after it's been idle for some seconds.
At first I thought this title was pointing to the quirky symptom of Clojure's default value for the "get" function that allows this statement:<p>(get get get get)<p>to be equivalent to this one:<p>get<p>as in:<p>((get get get get) {:a 1} :a)<p>I was very excited about an article on this topic.