Autojump: display the most frequently visited directory but not run `cd`

Created on 10 Jun 2013  ·  3Comments  ·  Source: wting/autojump

Usually, j something switches the working directory. But it doesn't have to. In some cases, we simply need to have the directory printed to stdout. e.g.

open `j --no-cd something`

This could launch the Finder on OS X for the destination directory.

I don't know whether it is hard to hack out this feature, but thanks any way for the great tool!

Most helpful comment

I prefer fasd, and I wrote this to give me a :j command. You could probably
adapt it to autojump.

Put this in .config/ranger/commands.py:

from ranger.api.commands import *
import subprocess

class j(Command):
    """:j

    Uses fasd to set the current directory.
    """

    def execute(self):
        directory = subprocess.check_output(["fasd", "-dl1", self.arg(1)])
        directory = directory.decode("utf-8", "ignore")
        directory = directory.rstrip('\n')
        self.fm.execute_console("cd " + directory)

All 3 comments

Hmm, feels like exactly what I was thinking for https://github.com/hut/ranger/issues/91.

jo <dir> opens OS specific file browser.

autojump <dir> prints the first match. If not passed any arguments, autojump prints the most frequently used directory.

If you need more information, use autojump --stats and any combination of awk / sed / tr / etc.

I prefer fasd, and I wrote this to give me a :j command. You could probably
adapt it to autojump.

Put this in .config/ranger/commands.py:

from ranger.api.commands import *
import subprocess

class j(Command):
    """:j

    Uses fasd to set the current directory.
    """

    def execute(self):
        directory = subprocess.check_output(["fasd", "-dl1", self.arg(1)])
        directory = directory.decode("utf-8", "ignore")
        directory = directory.rstrip('\n')
        self.fm.execute_console("cd " + directory)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

pgrm picture pgrm  ·  4Comments

hcsaustrup picture hcsaustrup  ·  9Comments

loveencounterflow picture loveencounterflow  ·  6Comments

juanrgon picture juanrgon  ·  4Comments

mbigras picture mbigras  ·  3Comments