1. 58
  1.  

  2. 32

    This is one of those articles that rescues itself by going to the absurd.

    1. 14

      Another issue about typing git is that sometimes I type gti, so I have installed this beautiful application http://r-wos.org/hacks/gti

      1. 3

        I just type g, because alias g=git. Since it’s one of the most common commands, it deserves to be just one letter.

        1. 4

          I do that as well. Also, l=ls, m=make. Then there are shortcuts like gl for git log, gd for git diff, st for git status, gup for git pull --rebase, etc.

          1. 3

            Ohh… my git aliases are actually “vim-like”: https://github.com/myfreeweb/dotfiles/blob/master/dev-base/gitconfig

          2. 1

            Seriously. Why bother with ls when you have git? Counting command frequency, my alias gs has over 20 times the usage of ls.

            alias gs='g status -sb'
            
            1. 3
              alias l="tree --dirsfirst -ChFL 1"
              alias l2="tree --dirsfirst -ChFL 2"
              

              etc.

              1. 2

                That would blow up my terminal. I have a very… flat… organization strategy. Really even using ls in my home dir is useless without a glob. ?

                And my home dir is a git repo anyway.

          3. 2

            ROFL, that’s hilarious. I wish there was an equivalent thing I could install so whenever I press “Esc” on my keyboard I get an annoying animation (I’m trying to teach myself to use Caps-Lock as an Esc key, seeing as I’ll probably be doomed to buy one of the new Macbook Pros with the stupid touchbar soon.)

            1. 4

              Why bother with an animation? If you really want to stop hitting Escape, buy that Macbook :-P

              More seriously, and in case Escape is important because you use Vim: I have grown very fond of :inoremap jk <Esc>. Perhaps that’s of use to you, too?

              1. 1

                As someone who uses jk repeatedly to find where they are on screen when i get lost, that might just kill me. But ctrl+c will exit you from insert mode in vim. As will ctrl+[. Both of which have been really nice when using a touchbar mac.

                1. 1

                  In truth, jk doesn’t work for me, either, because I type a lot of Dutch. I use nj, instead. It rolls nicely off the fingertips. I have also heard people recommend jj.

              2. 3

                it doesn’t have to be a burden, I swap esc and caps lock for better ergonomics.

              3. 1

                There’s also sl: https://github.com/mtoyoda/sl

                1. 2

                  Of which I’m a huge fan. Also contains criticism of gti, debian and systemd.

                  Sorry for linking to a comment on a different platform, but in this instance, I don’t want to waste vertical space here.

              4. 12

                Another favorite:

                $ sudo sh -c 'echo "192.30.255.112 gitgit.git" >> /etc/hosts'
                $ git config --global alias.git clone
                $ git git git://gitgit.git/git/git.git
                
                1. 7

                  This is only somewhat relevant, but I just discovered that newer versions of git now support your XDG CONFIG dir, so you can move your global gitconfig to $XDG_CONFIG_HOME/git/config (usually ~/.config/git/config)

                  1. 0

                    Sounds awful, why would I made it harder to get to it? I hate dotfiles, but I’d rather make the file visible where it is, or in some easy to get directory like ~/lib instead of hiding it even more.

                    1. 5

                      But if everyone hides their stuff in the same pattern then config is easy to find.

                      1. 2

                        Then you can change XDG_CONFIG_HOME to point to ~/lib

                        1. 0

                          Oh yeah, that’s what I need, even more state and configuration. No thanks.

                          Not that I said ~/lib/file, not ~/lib/foo/config. At least without this XDG nonsense (.local? .config? .cache? .run? Fuck you XDG!), even if my files have stupid dotnames, they are all in one single directory, $HOME…

                          I’ll stick to this scheme, thanks.

                          1. 1

                            could set XDG_CONFIG_HOME=$HOME ;)

                            1. 1

                              Chill. I don’t like excess configuration also.

                              XDG is indeed overt. However I at least appreciate .cache a bit, because it’s one directory that I can safely remove to reclaim some bytes.

                      2. 7

                        I did this too, except I pipe it through cowsay instead: git = !exec cowsay git

                        1. 6

                          I like the strace output…

                          $ strace  -f -e execve git git git git git git git git status 2>&1 | grep bin\/sh
                          [pid 27778] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "git", "git", "git", "git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27780] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "git", "git", "git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27782] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "git", "git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27784] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27786] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27788] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "git", "status"], [/* 55 vars */]) = 0
                          [pid 27790] execve("/bin/sh", ["/bin/sh", "-c", "exec git \"$@\"", "exec git", "status"], [/* 55 vars */]) = 0
                          
                          1. 1

                            I’m glad someone else had the same thought, it pleased me no end to see it laid out in system calls!

                          2. 2

                            I have never had this problem but thanks for the solution.

                            1. 2

                              It happens to me when I may type something like “git !!” or “git !$” while on the wrong terminal. Nice.

                              1. 2

                                The one I always mess up is that github just gives you the clone repo location but bitbucket gives you the whole clone command, so I write git clone git clone git@bitbucket.org:.... I wonder whether I can alias the clone command to correct for that.

                                1. 1

                                  From the git-config manpage:

                                  To avoid confusion and troubles with script usage, aliases that hide existing Git commands are ignored.

                                  1. 3

                                    Months later the programmer was reading git –help config for a different reason and found enlightenment.

                                    From http://stevelosh.com/blog/2013/04/git-koans/#silence

                                    1. 2

                                      However, a binary named git-command overrides the built in command. So you could stick a git-clone binary in your path that does what you want and it’ll be invoked rather than the built in command.

                                      I use this to override git clear to run /usr/bin/clear instead of removing all my local changes.

                                    1. 2

                                      I use gitsh instead, and don’t have to type git at all. Tab-complete of branch names is nice too.

                                      1. 2

                                        Thanks for the tip! This and qgit are my 2 most common git typos.

                                        qgit happens after doing a git diff and expecting a long diff opening in less, but I get a short diff instead, which does a cat to the terminal.

                                        So I added alias qgit='git' to ~/.bash_aliases.

                                        1. 2

                                          I have NEVER had this issue. Great solution though!

                                          1. 1

                                            This has to be a joke. Is this a joke? I can’t tell.