Live data from Hacker News

Quickly navigate your filesystem from the command line

jeroenjanssens.com

81–90 of 148 posts

Re: Quickly navigate your filesystem from the command line

#81
post #7

You might want to check out z: https://github.com/rupa/z

https://github.com/clvv/fasd I used to use z, but I've since switched to fasd. It's much like z, but also so much better. In addition to being able to do "z " you can do "f ". So, for example, if I've got a rails project I've worked on a lot recently I know its config.ru is high on frecency, so I'll just do "vim `f config`" to edit that file. If I want a file that's not so recent I can always do "vim `f -i config`" t…

If you alias `v` to `f -e vim` then you can `v config` and `v -i config`.

Re: Quickly navigate your filesystem from the command line

#83
This is great, but I don't see why this is better than autojump.

* Autojump automatically saves marks,

~~~ cd Downloads # And you are done. ~~~

* You don't have to think about mark names,

~~~ cd Projects/Python # It will be called `python`. ~~~

* You don't need to remember mark names,

~~~ j haskell # If you want `Projects/Haskell`, odds are the mark is auto-named `haskell`. ~~~

* You can specify only some part of mark name;

~~~ j bar # And you are in `Stuff/foobar`. ~~~

Other than that, this is, as I said before, great! Looking forward to go through the source code to learn more about Bash.

Re: Quickly navigate your filesystem from the command line

#84
post #10

I also do something similar but slightly different: https://github.com/roobert/dotfiles/blob/master/.zsh/robs/fu... my method involves storing the bookmarks in a file but loading them into zshs directory hash. This means the directories are tab completable and if you have AUTO_CD set then you can change directory with simply: ~dir_name, otherwise: cd ~dir_name.

And with CDABLE_VARS set, you can simply do: dir_name In fact, you don't even have to use the directory hash for this, you just do, e.g.: MY_DIR=/path/to/dir; MY_DIR Frankly, this is far superior to the linked method.

Except tab completion is annoying since zsh will include commands and environment variables in its guesses. The linked method simply provides a way to store the directory hash across sessions.

Re: Quickly navigate your filesystem from the command line

#85

I set my version up with a -f on the unmark rm so that I don't need to be prompted to remove it. Also added some basic completion for both jump and unmark export MARKPATH=$HOME/.marks function jump { cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1" } function mark { mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1 } function unmark { rm -if $MARKPATH/$1 } function marks { ls -l $MARKPATH | sed 's/ / /g' | cut -…

The purpose of the -i flag is to prompt the user before deleting. Mixing the -i and -f flags is a little moot.

Try removing the -i option to obtain what you want.

Re: Quickly navigate your filesystem from the command line

#86

I had to modify Jeroen's code to get the `marks` shortcut working under Mac OS 10.8: export MARKPATH=$HOME/.marks function jump { cd -P $MARKPATH/$1 2> /dev/null || echo "No such mark: $1" } function mark { mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1 } function unmark { rm -i $MARKPATH/$1 } function marks { ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- && echo }

Thanks! Also, since alot of OSX paths contain whitespaces, I had to modify the mark function like so:

  function mark {
      mkdir -p $MARKPATH; ln -s "$(pwd)" $MARKPATH/$1
    }
Disclaimer: I'm not very good at bash, perhaps there is a nicer solution to this problem?

Re: Quickly navigate your filesystem from the command line

#87
post #56
post #51

Reminds me of z, which I use all the time. Anyone else use z? If you have not heard of it, get it now https://github.com/rupa/z . z is a wonderful complement to cd. After cd into a folders with z set up, a file stores all folders navigated to sorted by frecency, then simply jump to a folder with z [foldernameregex].

z is absolutely wonderful. Even my boss has become a convert, and he's been hacking unix since the 1970s, when he worked at AT&T, and is very set in his ways. [Disclaimer: rupa's a good friend of mine]

I've converted a few people to the z side. And yes, it is wonderful.

[Disclaimer: rupa is a good friend of mine, as well]

Re: Quickly navigate your filesystem from the command line

#88
I noticed that 'mark' doesn't work if you have spaces in a directory name which you can't avoid on the Mac (I tried to mark an interior folder inside the iPhone Simulator which is inside "~/Library/Application Support/iPhone Simulator/". Wrapping in quotes seems to do the trick:

  function mark { 
       mkdir -p $MARKPATH; ln -s "$(pwd)" $MARKPATH/$1
  }

Re: Quickly navigate your filesystem from the command line

#89
I just do this (in zsh):

    setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
Which automatically pushes (unique) directories I've visted into $dirstack.

Then I have an alias:

    d () {
            local dir
            select dir in $dirstack
                    echo $dir
                    break
            done
            test "x$dir" != x && cd $dir
    }
That gives me a list of directories to jump to in my history:

    ~/src/git/emacs-prelude $ d
    1) /home/kelvie/tmp/typhoon          3) /home/kelvie/src/git              
    2) /home/kelvie/tmp                  4) /home/kelvie                      
    ?#
So I just type 1-4 to go back to a directory I've previously been in.

Re: Quickly navigate your filesystem from the command line

#90
post #53

Here is a fully functional (albeit minimal) Windows version: http://appleseedhq.net/stuff/marks-v1.zip . Tested on Windows 7 (does not require PowerShell). GitHub: https://github.com/dictoon/marks Edit: to install, unzip anywhere and add to your path. Then: C:\Windows> mark win C:\Windows> marks win => C:\Windows C:\Windows> cd .. C:\> jump win C:\Windows> Marks will be stored in a marks\ subdirectory (relatively to…

Great! It's a smart idea just to store locations in simple text files. Thank you.
Post reply on HN