

Teleportation on the command line - liquidwax
http://thecakeisalie.in/blog/2014/01/11/teleportation-on-the-commandline/

======
euank
It looks like no one has posted what, in my opinion, is the most powerful of
the "jump" programs: fasd.

My workflow for getting around is just to type "z <fragment of directory
name>" and I almost always end up where I want. If I just want to edit a file,
not a project, I do vim `f <filename fragment>` and likewise get the file I
want typically.

The readme makes it pretty clear how awesome it is and I've stuck with it
after using autojump, z, and others.

[https://github.com/clvv/fasd](https://github.com/clvv/fasd)

~~~
a3_nm
Second this recommendation. fasd works extremely well, and better than z and
autojump for my usage. I use it all the time.

------
res0nat0r
Just use auto jump

[https://github.com/joelthelion/autojump](https://github.com/joelthelion/autojump)

~~~
gaving
lighter (non python) alternative to autojump
[https://github.com/rupa/z](https://github.com/rupa/z)

~~~
mtrn
Since I discovered `z` I haven't typed in cd, except for changing into $HOME
quickly.

------
shurcooL
> Nobody types an entire URL like [https://example.com/example-
> page?input=sample&another-input=...](https://example.com/example-
> page?input=sample&another-input=2). We bookmark it and give it a keyword
> like ex or something. From then, we just type ex and hit return to access
> the website.

I don't wanna sound negative, but just being realistic.

I don't rely on bookmarks primarily. I rely on "most frequently visited gets
auto-completed first" and fuzzy search of Chrome Omnibox. If I do bookmark
something, it's to indicate to the algorithm "I care about this, make it
easier to fuzzy find it later".

But it's a good step in the right direction, good job!

Edit: From the description, it sounds like autojump does something close.

~~~
JelteF
You should try out fish[1], one of the features that makes it great is that it
does exactly what the chrome omnibox does, just with commands. It shows what
it will complete after you press ^F and it is a lot of times correct.

It also has lots of other features, like tab completion that tells you what
the options of commands do. So reading the manpages or typing -h is generally
not needed.

If you do try it, also try one of the themes of oh-my-fish[2], most of them
have a git thing that lets you know if you have uncommitted stuff and on what
branch you are.

[1] [http://fishshell.com/](http://fishshell.com/)

[2] [https://github.com/bpinto/oh-my-fish](https://github.com/bpinto/oh-my-
fish)

------
Webster
Why not just use the CDPATH variable in your shell? If the directory is one
you go to frequently, add it to CDPATH, then just cd to it.

------
scribu
I'm quite happy with
[https://github.com/huyng/bashmarks](https://github.com/huyng/bashmarks)

Also, the built-in pushd and popd commands are enough sometimes.

~~~
vezzy-fnord
_Also, the built-in pushd and popd commands are enough sometimes._

I came here to say this. A small wrapper around these commands would make for
a sufficient script.

------
Morgawr
Interesting scripts are being posted in the comments, really neat tricks guys.

One thing I'd like to add, if you're like me and don't want to install too
much "extra" stuff on your machines: Bash has native commands called pushd and
popd[0]. They work as a stack, pushd will push the current directory onto the
stack and jump to the new target, then you're free to move around, do whatever
you want and then call popd to pop the latest directory from the stack.

I find these very useful, especially if I'm on a machine without additional
installed software and just want to do my thing effortlessly.

[0]
[http://en.wikipedia.org/wiki/Pushd_and_popd](http://en.wikipedia.org/wiki/Pushd_and_popd)

~~~
anon4
For a one-level undo there's always

    
    
      cd -
    

Passing a single dash as a parameter to cd takes you back to $OLDPWD and each
invocation of cd sets OLDPWD to the directory you were in.

------
akerl_
I use a similar method, which I based on a previous HN post:

[https://github.com/akerl/dotfiles/blob/master/.bundles/marks](https://github.com/akerl/dotfiles/blob/master/.bundles/marks)

I'm addicted to one/two-letter aliases, and between that and ZSH completion
([https://github.com/akerl/dotfiles/blob/master/.completions/_...](https://github.com/akerl/dotfiles/blob/master/.completions/_marks)),
the mark functions get me super-simple bookmarks

I also wish people would stop providing "curl this into .bashrc" as the
primarily installation method. That's a really bad habit to get into,
especially with a file like .bashrc. It's a bit less risky than piping the
curl into bash, but still not a great plan.

------
ehm_may
I don't get it. Why not just use aliases?

alias <name>='cd path/to/<name>'

Then you can just type: $ <name>

You can even set up an alias to add a new alias -> alias ea='vim ~/bash/alias'

------
bnegreve
Nice. This quick and dirty trick has been in my .bashrc forever and I still
use it:

    
    
        function md(){
            pwd > /tmp/md_tmp
    
        function gomd(){
            cd `cat /tmp/md_tmp`
    

so `md` marks the current directory and `gomd`go to the marked directory.
Unlike bash builtins like pushd and popd, it uses the file system to store the
marked directory so you can pop up a new terminal and just do gomd. (you can't
with pushd/popd since the bash processes of the old and the new terminal are
not related)

Edit: I see that your script uses links, I'll check this out.

------
MattFlower
Some time ago I put my directory changing tools up on GitHub at
[https://github.com/mattflower/bashcd](https://github.com/mattflower/bashcd)

In addition to the bookmarking style capabilities other people have already
mentioned it also includes integration with the locate database, the mac
spotlight/mds database, and the plain old find command. It can switch to a sub
directory containing a particular file. It also supports bash completion.

------
jck
With zsh, you could just do w/c/p/w/s<TAB>

------
coley
I made a tool a year ago to do the same thing, Metis:
[https://github.com/srcoley/metis](https://github.com/srcoley/metis)

I like a solution that goes where ever your dotfiles go, instead of having to
install a fuzzy search on each system.

Metis will list all of your currently saved Metis aliases as well, just by
typing "metis". You can also tell Metis which dotfile you want to save your
aliases.

------
csense
Why not just use a symlink?

    
    
        ln -s ~/super/long/nested/directory/name ~/short
    

If you don't want to dump them in your home directory, just make a directory
with a single-letter name for your links:

    
    
        ln -s ~/super/long/nested/directory/name ~/l/short

~~~
biscarch
Personally I do something similar. I set up an alias in .zshrc from project
names to commands. This allows me to do things like source environments as
well.

    
    
        alias proj="cd /this/that/foo/projects/myproject/ && source .hsenv/bin/activate"

------
damaru
Well I though it was nice, but the script if quite buggy! works well when
cleaned up

------
sgs1370
Thanks - all of the alternatives look interesting but this one seems to be the
shortest of them, and since "mark" installed after a simple cut & paste into
my profile, I'll try it out for a while.

------
ClayFerguson
This is sort of why I always just put everything in a shell script. Creating a
text file with .sh extension is not that difficult, and I almost never use the
command line interactively. Plus I use a GUI and just mount folders I need to
browse. It boggles the mind how so many people still equate "Linux==Command
Line Hacking". I actually had a boss once who said to me: "If you don't use
the command line that much why do you use Linux instead of Windows?" You see,
in his mind Linux was all about the command line. Yeah maybe in 1990 it was,
but nowadays it's a normal OS like any other.

------
rasengan0
I enjoy posts like this because it brings out timtowtdi: pushd, cdpath, ln and
aliases

------
ses4j
Does any flavor of this functionality exist for Windows command prompt?

~~~
elarkin
Windows makes this a little easier than bash does.

batch scripts in windows behave like scripts on unix do when you source them.
That means that you can write a batch script called "foo.bat" with the
contents of "cd \whatever\directory\you\please" and it will change your
current directory when run.

From there, it would not be difficult to write a batch script that in turn
wrote batch scripts like "foo.bat" above.

With bash, you would have to create functions or aliases to get the same
effect.

------
sreejithr
Did anybody try the script in ZSH?

~~~
a-b
[https://github.com/robbyrussell/oh-my-
zsh/blob/master/plugin...](https://github.com/robbyrussell/oh-my-
zsh/blob/master/plugins/fasd/fasd.plugin.zsh)

------
dmourati
Tab works for me.

