• Stars
    star
    240
  • Rank 163,023 (Top 4 %)
  • Language
    Python
  • Created almost 15 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

python version of z, for experimentation

CAVEAT

Unless you have reasons not to, you should probably use https://github.com/rupa/z/ - which is actually maintained, used, and lovingly cared for.

OVERVIEW

Spend a lot of time cd-ing around a complex directory tree?

j keeps track of where youโ€™ve been and how much time you spend there, and provides a convenient way to jump to the directories you actually use. We use the term "frecency" to refer to how frequent and recent visits to a directory are.

This is a complete rethink of original j. See CHANGES for differences.

NOTE:

I've been using this for ease of experimentation, but prefer a pure shell version. for portability and ease of use.

INSTALLATION

  • put something like this in your .bashrc:

      export JPY=/path/to/j.py # tells j.sh where the python script is
      . /path/to/j.sh          # provides the j() function
    
  • make sure j.py is executable

  • cd around for a while to build up the db

  • PROFIT!!

TROUBLESHOOTING

  • tested with python 2.6

  • if you are using python 2.5 you will need to add a line to j.py above the import statement:

      from __future__ import with_statement
    
  • python < 2.5 may require further alteration

USE

  • j by itself (or j -l) displays the current list of directories being remembered.

  • j foo jumps to the highest weighted directory that has the substring foo in it, j foo bar for the weighted directory that has both foo and bar, etc...

  • j supports tab completion.

  • if you often prefer one of the non-default match type, use aliases:

      alias jl='j -l'
      alias jt='j -t recent'
      alias jr='j -t rank'
    

MATCHING ALGORITHM

Look for case sensitive match first, then fall back to case insensitive.

If all matches have a common prefix, and the prefix is one of the matches, and all args are matched in the prefix, go there unconditionally. This attempts to follow the principle of least surprise.

Frecency: alter rank by time of last access. * If access within last hour, multiply rank by 10. * If access within last day, multiply rank by 2. * If access within last week, divide rank by 2. * If access is more than a week, divide rank by 10.

I'm interested in improving/refining this algorithm, but it's a decent start.

AGING

Rank is recalculated as 0.9*rank when sum of ranks > 1000. When the rank of a directory falls below 1, it will fall off the list.

FAQ

Q) How come j doesnโ€™t work likecd?

A) j is not intended as a substitute for the cd command. You should still cd everywhere as you normally would. When you want to jump somewhere you have been, then type j <args> to jump to a directory in your often used list.

Q) How do i 'source' something? Why?

A) Short answer: instead of running the script as j.sh you type source j.sh or . j.sh in a shell, or to make it available all the time, put a command in your .bashrc that sources it, or just paste the contents of j.sh directly into your .bashrc.

Long answer: sourcing is like importing. When you run a script in a shell, it creates a subshell, runs your script, and returns to your current shell. If you cd in that subshell, it wonโ€™t matter to your current shell, because when your script is done running, it exits, and comes back to where you (still) are in your current shell. What we want in this case is to have the function and commands in our script defined in our current shell. Sourcing โ€“ rather than executing โ€“ the file does exactly that.

CHANGES FROM ORIGINAL j

  • Uses python to do the heavy lifting.

  • Uses 2 separate files, so install is a bit more complicated.

  • Default ordering is 'frecent': rank weighted by time since last access. Match by 'rank' and 'recent' still available.

  • If all matches have a common prefix, and the prefix is one of the matches, and all args are matched in the prefix, go there unconditionally. This attempts to follow the principle of least surprise and replaces the 'short' ordering.

CREDITS

  • Joel Schaerer aka joelthelion for autojump
  • Daniel Drucker aka dmd for finding bugs and making me late for lunch

More Repositories

1

z

z - jump around
Shell
16,064
star
2

sprunge

command line pastebin for google appengine
Python
723
star
3

v

z for vim
Roff
446
star
4

epub

python/curses cli epub reader
Python
379
star
5

j

semi clone of autojump (http://github.com/joelthelion/autojump) in shell/awk
Shell
157
star
6

YOU_ARE_DEAD

AN EXPERIMENTAL INDIE 1D ROGUELIKE. YOU ARE DEAD
Shell
73
star
7

cuecat

concatenate WAV files, with cue points or even spacing
JavaScript
38
star
8

octoeuclid

Up to 8 Euclidean Rhythms at once, on your BeatStep Pro
Python
22
star
9

password-store

Simple password manager using gpg and ordinary unix directories.
Shell
18
star
10

isNaan

Easily test if javascript things are delicious Indian bread
JavaScript
15
star
11

applescript

some utilities written in applescript
Shell
15
star
12

rvn

revision control for single files, written in bash :)
13
star
13

irssi

some scripts for irssi
Perl
11
star
14

el

mnemonic wrapper for $EDITOR
C
11
star
15

xmonad

my xmonad.hs (darcs/gnome/karmic)
Haskell
10
star
16

p

A couple of python/virtualenv utilities.
Shell
10
star
17

cfdns

Dynamic DNS with Cloudflare
Python
8
star
18

mkdn

markdown previewer (python, gtk, webkit)
Python
8
star
19

cnv

ebook manager using mod_python and calibre cli tools
Python
6
star
20

birc

An IRC bot written in shell
6
star
21

s

sed for $PWD
Shell
5
star
22

yts

make youtube into a nice jukebox
5
star
23

ansiimg

Images in B/W, Greyscale, 16 and 256 ANSI colors, delivered to STDOUT
Python
5
star
24

rupa.github.com

userpage
4
star
25

automeme

A cheeky random nonsense generator.
Python
4
star
26

dodns

Dynamic DNS with Digital Ocean
Shell
4
star
27

.vim

.vim
Python
3
star
28

horse_dev

/dev/horse horse device
C
3
star
29

marko

bog simple markov
Python
3
star
30

gnauriqs

Minimum dynamically modifiable IRC bot.
Python
3
star
31

lmp

python wrapper for mplayer to submit to lastfm
3
star
32

euclid

Euclidean Rhythm Sequencer stuff
Python
2
star
33

node-basicauth

http basic auth for node as simple as I can make it
JavaScript
2
star
34

wsgi_skeleton

My WSGI skeleton
Python
1
star
35

gxl

shell interface to google translate
Python
1
star