1. 56
  1. 18

    if you feel like you are repeating yourself:

    • !! – complete last command (!-2 recalls the second to last command)
    • !$ – last argument -”-
    • !^ – first argument -”-
    • !* – all aguments -”-
    • !:1-2 – 1st and 2nd argument -”- (!-2:2 recalls the 2nd argument of the 2nd-to-last command)
    • ^old^new – replace the first occurrence of old with new
    1. 40

      Whenever I read tech articles about reducing keystrokes I tend to roll my eyes. cd‘ing directories already takes up a very small portion of my time—optimization will never be worth it. Now if you can tell me how to make roadmap estimations that don’t put my team in peril, now that’s going to help me to not waste my time!

      Edit: It’s a cool tool, just maybe the article is touting it as more of a life saver than it actually is.

      1. 12

        I mean, I do too, but people do actually take this kind of thing seriously. I’ve had several people say they wouldn’t use ripgrep because the command was too long to type, but upon hearing that the actual command was rg, were much more satisfied. Maybe I missed their facetiousness, but they didn’t appear to be joking…

        1. 5

          Could they not have just alias’d the command if it was “too long”?

          1. 4

            The people in question don’t sound clever enough for that.

            1. 1

              Are you asking me? Or them? ;-)

            2. 4

              I wonder if these are different people than the ones who complain about short unix command names and C function names…

            3. 9

              For those of us with RSI, these little savings add up, and can make for a pretty big difference in comfort while typing.

              1. 8

                Oh please. If you’re really worried about a couple of words and keystroke saving, you’d setup directories and make aliases that will take you specifically where you want to go. Assuming it was even a GUI you were using with a mouse, you’d still have to click through all the folders.

                Overall, paying close attention to your workspace setting and ergonomics can go a long way in helping improve your RSI situation than this little jumper will ever do

              2. 4

                My thoughts exactly. I have often wasted time trying to optimize something which took so little time to begin with, even if I reduced the time to nothing it would have no significant impact on overall performance. And the less-obvious trap is optimizations like this add additional complexity which leads to more time spent down the road.

                1. 9

                  All right, buddy. Cool.

                  Did I say it a “life saver”? Nope. Did I say it could save you a lot time? Yup. If cd'ing into directories doesn’t waste your time, cool. Move along, read the next blog post on the list.

                  I’m sorry about your roadmap estimations. Sounds like you’ve got a lot on your chest there.

                  1. 31

                    Let me just take a step back and apologize—nobody likes negative comments on their work and I chose my words poorly and was insensitive. I’m rather burnt out and, in turn, that makes me appear more gruff online. I’m positive that someone will find this useful, especially if they’re managing multiple projects or similar use cases.

                    1. 23

                      I really appreciate you saying that. The whole point of this piece was to share something that literally makes me whistle to myself with joy every time I use it. I hope you find some time to take care of your burn out. It’s no joke and I’ve suffered from it quite a bit in the past three years myself. <3

                      I know it’s easy to look at everything as “this is just like X but not quite the way I like it” and I don’t blame you for having that reaction (like many here). AutoJump is to me the epitome of simple, delightful software that does something very simple in a humble way. I wish I had spent more time extolling the virtues of the simple weighted list of directories AutoJump stores in a text file and that ridiculously simple Bash implementation.

                      The focus on characters saved was a last minute addition to quantity the claim in the title. Which I still think will be beneficial to anyone who remotely has frustrations about using cd often and may suspect there is a better way.

                    2. 6

                      If only there was a way to optimize crank posting. So many keystrokes to complain!

                    3. 2

                      the parent tool is probably overkill but a simple zsh function to jump to marked projects with tab completion is pretty awesome to have.

                      alias j="jump "
                      export MARKPATH=$HOME/.marks
                      function jump {
                      cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
                      function mark {
                      echo "mark name_of_mark"
                      mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
                      function unmark {
                      rm -i "$MARKPATH/$1"
                      #if you need it on another os.
                      #function marks {
                      #ls -l "$MARKPATH" | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
                      # fix for the above function for osx.
                      function marks {
                      \ls -l "$MARKPATH" | tail -n +2 | sed 's/  / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}'
                      function _completemarks {
                      reply=($(ls $MARKPATH))
                      compctl -K _completemarks jump
                      compctl -K _completemarks unmark
                      1. 1

                        I’ve tried this, but I keep end up making shortcuts and forgetting about them because I never train myself well enough to use them until they’re muscle memory.

                        I think I’ll just stick to ‘cd’ and also extensive use of ctrl-r (preferably with fzf)

                        1. 1

                          And then you go to a work mates computer, or su/sudo/SSH and it’s unusable :)

                          1. 1

                            well this is one of the most useful shortcuts in my arsenal. type j <tab> or jump <tab> and it completes all the marked directories. If you get over the initial forget to use it curve it’s amazing and simple (just a folder in your home dir with a bunch of symlinks. and a few helpers to create those.)

                      2. 8

                        I never could get into these jump tools. zsh with auto_cd and cdpath is good enough for me. I just type dotf<Tab><Enter>, it completes to dotfiles/ and cds into ~/src/github.com/myfreeweb/dotfiles (because that …myfreeweb/ directory is on the cdpath).

                        1. 4

                          Another really useful thing about zsh autocompletion is that it matches on any portion of the directory name. So, for example, when I had multiple projects like project-server, project-hq, and project-mobile, I only needed to type eg -mob<Tab> and it would autocomplete to project-mobile. It was very convenient because I switched between these three directories all the time.

                          1. 4

                            My favorite is the deep path expansion, e.g. ~/s/g/m/dot to ~/src/github.com/myfreeweb/dotfiles. I really miss that in other applications (e.g. neovim)

                            1. 2

                              I use that a fair bit as well, it’s a helpful feature.

                            2. 1

                              Autojump utilities, such as fasd and pazi (mine), do that as well. Some of them (fasd, not pazi) even have shell autocomplete too so z hq would go to project-hq if that were frecent.

                              One other cool feature they have which tab-completion sorta mimics is picking from items in a list. With those, z -i project would give an interactive menu of all items with “project”, while with tab completion, double-mashing tab does a similar thing.

                              If auto_cd is good enough for you, that’s totally fine, I just want to also explain that autojump utilities also do have tab completion and partial matching of path partial parts too.

                            3. 3

                              One of my favorite features is auto_pushd. It combines nicely with auto_cd. Zsh is remarkably well polished.

                            4. 8

                              I just use a new tmux window for every directory I need to be in (which is never more than a few per project). So I switch windows instead of switching directories!

                              1. 7

                                This is like z, which I’ve been using for years. Great tool.


                                1. 2

                                  +1 I like z better as it’s implemented in all shell - works anywhere with no dependencies

                                  1. 1

                                    +1 for exactly the same reasons. z is life.

                                2. 10

                                  This might be worth it, if all I did was cd’ing between directories, and I really had to do it fast and often, but generally saying that using the universally accepted way of moving around the file system, which works on Linux, Mac OS, BSD, Plan9 and even Windows (if I am not mistaken), is a “waste of ones time” seems to be a bit of an exaggeration, especially if most shells have “tricks” like:

                                  cd ~/Development/project/
                                  mkdir ../new_project
                                  cd $_ 
                                  cd -

                                  to do the same as the example mention in the article.

                                  one could also have a shell function chat creates and changes the working directory at once.

                                  So before one starts worrying about the number of characters one types, and starts installing, non standard, external tools (especially if it starts python every time it’s executed), I think it would be wiser to learn how to use one’s shells properly, or at the very least to type more efficiently, if one is in fact convinced that changing directories is the bottleneck in ones workflow.

                                  1. 4

                                    Important point: shells already have a lot of optimization for ‘cd’. (Not to mention pushd & friends, even!)

                                    I worry about tools like the one mentioned in OP, which have fuzzy optimizations based on use, & therefore optimize specifically for well-worn paths. Our entire nervous system already optimizes our responses for well-worn paths; I feel like we ought to compensate for it, and avoid tools that try to keep us in a rut.

                                    Since having two directories with similar names that are accessed almost equivalently often will produce far more typing with this tool (vs tab completion, which – at least in many shells – will only complete up to a divergence point on groups of files with shared prefixes, and therefore eliminates only unambiguously-wasted keystrokes, while working with every command), the rut-grade here is higher: not only do we use the same directories, but it becomes too much effort to have similarly named directories even when they are descriptive, and we must keep a mental tally of how often we visit particular directories with particular prefixes in order to estimate how many letters we should be using to cd! Every time we go into the wrong directory accidentally, we compound the error, and if we switch from one project (with associated directory) to another (with a similarly-named associated directory) we must spend time avoiding using this tool in order to re-train it.

                                    1. 4

                                      No it’s not an exaggeration, because that’s not what I said. If you somehow miraculously move into a completely different set of directories every day while you work, I’m honestly impressed. You must do a lot of greenfield work.

                                      I spend a lot of time in similar directories and sub-directories for the same projects. So this in fact, without exaggeration, saving me a lot of time. And cd'ing into these same directories and sub-directories is in fact a gigantic waste of my time.

                                      It’s kind of amazing how you and some other commenters are focusing so hard on the number of characters I’ve used to demonstrate how much more efficient AutoJump is.

                                      Did you use the tool? You spent about three times the amount of time it would take to install it to opine on the potential slowness it may have because it’s written in Python. It has a Bash version.

                                      But yeah, we could count beans and figure out all the other potential bottlenecks in your workflow before we address this one. The thing is, this is my blog post about my workflow, and a bottleneck I’ve encountered a lot through the last ten years. I’m sure (from the reception) that it’s going to help a lot of people with similar problems.

                                      But thank you for suggesting I’m not using my shell properly, that’s really helpful. :-)

                                      1. 3

                                        First off, I missed that this was an authored article, so I was a bit more critical than I would have been otherwise. I want to apologize if you were insulted or offended by my article.

                                        But to be fair, you did say that cd is a “Wasting Your Time”, it’s the first thing I read… And I have to admit that this isn’t quite my use case, since I tend to work within emacs more than a classical shell environment, and my servers don’t necessary have python or bash installed. But I did miss the bash version, I’ll try it out, but I took your article to give a good overview, all I wanted to say was that I really didn’t belive that “cd” was the real bottleneck – for most people – which is implied by the way you address the reader.

                                        It’s kind of amazing how you and some other commenters are focusing so hard on the number of characters I’ve used to demonstrate how much more efficient AutoJump is.

                                        It seemed that this was your argument, that AutoJump saves characters, and that for that reason, it’s worth using. My reaction was just that it seemed like a wierd metric to measure “efficiency”.

                                        But thank you for suggesting I’m not using my shell properly, that’s really helpful. :-)

                                        Ok, instead of “properly”, one could also say to it’s fullest given potential. I know what one can already do with what one has, or as some people say “comes out of the box”, instead of installing addition software. But it doesn’t have to mean anything, since I only have an experience of just over 5 years with all these things.

                                      2. 2

                                        I tend to agree. I spend much of my time switching between different systems that I don’t own, and every few months I get handed a brand new system with none of my previous customizations. Because of this I’ve taken the time to get comfortable with the defaults. I don’t have a bashrc, I don’t have a vimrc, I use screen instead of tmux because my machines don’t have tmux. And as it turns out, you can get a lot done with the defaults.

                                        Then again these days I’m the kind of person who prefers default settings anyway… I had an Android phone that I would heavily customize and as soon as I got it how I wanted it, the developer would stop supporting a plugin for my launcher and now I have to do it all over again. I’d customize my Linux shell and then there’d be some new best thing (stop using screen, switch to tmux, stop using bash, switch to zsh) that I just had to install and switch my workflow to. I even switched to dvorak instead of qwerty because it’s better. But then I found I couldn’t use someone else’s machine, and they couldn’t use mine. And when I got a new one, it would take ages to get it set up again unless I learned even more tooling to save my configurations. Instead of doing work, I was fiddling with the tooling. All the time saved by the better tools cost even more time in configuration and learning a new workflow.

                                        Over the years I’ve decided that it’s not worth it to me, and now I feel a zen-like calm knowing that I can log into any machine and all of my favorite tools will already be there.

                                        That being said, I love the idea of this project, and past-me would have been all over it. Though the headline is a little hyperbolic I think there’s a target audience for it, even if I’m not part of that audience.

                                      3. 5

                                        yah, i’ve always noticed the tedium involved with cd. when i started learning go it seemed to be a bit worse which drove me crazy enough to write this little shell utility that allows for “shortcuts”: https://gist.github.com/nkcmr/6d4e5c21d73c433d79547de7ba188815

                                        allows for stuff like this:

                                        ~ > goto --define farawayfolder $HOME/go/src/github.com/nkcmr/goproj/internal/package/that/is/important
                                        ~ > goto farawayfolder
                                        ~/go/src/github.com/nkcmr/goproj/internal/package/that/is/important > cd ~
                                        ~ > goto --list
                                        farawayfolder -> /Users/nkcmr/go/src/github.com/nkcmr/goproj/internal/package/that/is/important
                                        ~ > goto --rm farawayfolder
                                        1. 5

                                          Bash supports CDPATH. It’s not as smart of autojump but it’s everywhere out of the box. Mine:

                                          export CDPATH=".:~:~/src:~/src/github.com/mperham:~/src/github.com/contribsys"
                                          1. 4

                                            I know this thread is already filled with alternative workflows for this particular task, but this is one of the things I love the most about elvish. With ctrl-l you can bring up an fzf-like ‘location’ menu that contains the directories you’ve been to, sorted by score (similar to firefox’s frecency, which I love). The best part is that it’s essentially ‘zero-conf’, since you just have to use the shell to build the results, and in my experience it works very well.

                                            Some will say that this is outside the scope of a shell, but it’s hard to reach this level of integration by combining external tools.

                                            1. 2

                                              Elvish is my favorite shell at the moment, and its surprisingly efficient directory navigation is only one of the reasons. A weighted-directory-history is kept automatically by the shell, so over time, your most-used directories float to the top, and are easily accessible in location mode. In this sense it’s not too different from AutoJump, but because it’s visual, you can see your selection live as you type. These days, it doesn’t take more than Alt-L (I have remapped from the default Ctrl-L that @nomto mentions) and a couple of keystrokes to select the directory I want. It works great.

                                            2. 3

                                              I’ve been using one or another autojumper for the better part of 8 years, and at this point I’ve come to rely on them as part of my workflow.

                                              Unfortunately, a lot of them have a lot of problems. Autojump is in python and fairly slow. In addition, it’s less featureful than fasd (really, fasd has tons of cool features).

                                              Despite fasd being the most featureful, it is some truly terrifying shell and has had some unsafe eval issues in the past.

                                              Which brings me to what I’m actually commenting about: I wrote my own autojumper called pazi and switched to it a few months back. It still has a ways to go before it’s as featureful as fasd, but it’s already faster than all the others, and it’s in rust so there’s no chance of an accidental “eval” blowing up in my face.

                                              If you want an autojumper, my biased recommendation is to try pazi :)

                                              1. 3

                                                I’ve been using auto_cd with tcsh and zsh for nearly 20 years now, having used it as the default behaviour on AmigaOS for a good half-dozen more. Who’s still typing cd? :P

                                                1. 3

                                                  Cool article, I’m often amazed by how ppl accept unoptimal procedures as normal, I’ve been using http://wcd.sourceforge.net with great success for some years now, it’s quite similiar to j, http://javier.io/blog/en/2011/04/05/dont-let-cd-slow-you-down-wcd-commacd.html

                                                  1. 3

                                                    Just to make sure: Everybody knows about pushd/popd?

                                                    I tried stuff like CDPATH, but removed it. It can break crappy Makefiles.

                                                    1. 1

                                                      my favorite part about pushd/popd is using dirs -v to see the stack, and cd ~# where # is the directory’s place in the stack…

                                                    2. 2

                                                      I do find cd tedious, that’s why I prefer a graphical file browser.

                                                      1. 2

                                                        The other relatively easy thing to do is that if you find yourself jumping to a given location more than once an hour, set up a shell alias to take you there.

                                                        1. 2

                                                          Why not just use Helm?

                                                          1. 2

                                                            While cd may be wasting some of my time it certainly isn’t the biggest culprit. I’m sure this is a horrific antipattern but I just use aliases for directories I commonly cd to, such as

                                                            alias proj="cd /path/to/project/root"

                                                            and so on

                                                            1. 2

                                                              you’re not alone, I do this too.

                                                            2. 2

                                                              Someone just forgot about pushd and popd so he tries to reinvent the wheel.

                                                              1. 1

                                                                This is an example of “low level” vs “high level” abstractions. One can climb around the path tree picking through files, or aggregate into directory path “bushel’s” , or poke away at a project’s components via an IDL.

                                                                These choices seem to be set by how the particular activity was set-up. Perhaps there are better ways to setup activities than optimizing default ways of working them?

                                                                Maybe the effort should be spent in asking / answering the question - is there a better way to do this? Rather than just “doing this”?

                                                                1. 1

                                                                  With zsh, there is builtin support to name directory (static named directories). It’s also possible to let an entire function decide how to translate a name to a directory (dynamic named directories). Moreover, it’s possible to change to a directory without cd. It doesn’t have the fuzzy matching stuff, so some work is still needed to get the same results. I am only using the first feature, but I have described both of them in this blog post: https://vincent.bernat.im/en/blog/2015-zsh-directory-bookmarks. What’s great with such features is that it works everywhere a filename works. You can use “cd”, but you can also directly call your editor on a file and you get completion.

                                                                  1. 1

                                                                    Sounds like a lot more cding than I do. I tend to cd only once per shell session to a project directory and then run my editor, build tool, git and whatever else from there. I’m sure I spend a lot more time typing make and git than cd.

                                                                    1. 1

                                                                      I have been using autojump for several years now, and it has definitely accelerated my directory movements, and reduced frustration of having to continuously CD up and down trees. Highly recommended!

                                                                      1. 1

                                                                        This is the single greatest English sentence I’ve ever read: “My made up estimate is that Autojump has saved me from at least a whole year of typing. At least that’s how it feels.”

                                                                        If you’re not sold after reading that…