You are not logged in.

#1 2010-08-29 12:24:38

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

autojump - the cd command that learns - new version

I've just uploaded a new release of autojump, the cd command that learns.

Autojump is a little tool I wrote that allows you to "jump" around your filesystem by maintaining a list of the directories you use the most. To put it simply, if you wanted to go to a directory called "/home/john/documents/projects/DADVSI/legal", you could type "j leg" or "j legal" or "j gal" or even "j VSI/leg", and it would jump to the right directory.

The new release brings a couple new features and several bug fixes. One new feature is the support for multiple patterns: sometimes it is easier to refer to a path by several patterns instead of one. Furthermore, all but the last pattern can refer to the full path, which can be handy when you have several directories with the same name. Say you have

~/src/project1/bin
~/src/project2/bin

If you want to make sure autojump jumps to the bin directory for project2, you can enter:

j 2 bi

Another new feature is improved support for removable media: instead of immediately purging non-existent directories, autojump now keeps them in the hope that they may one day be available again.

As usual, autojump is available for both bash and zsh. The new version hasn't reached the arch repos yet, but if you can't wait, you can always get the autojump-git package.

Enjoy!


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#2 2010-08-29 17:00:14

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: autojump - the cd command that learns - new version

I love autojump, but I don't get what's new about this release... I'm doing the "j 2 bin" thing with the current version already.

Or more exactly:

$ j ld
/home/olivier/builds
$ j jeu ld
/mnt/data/Jeux/LD18

Offline

#3 2010-08-29 19:17:47

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

Actually you're right, multiple patterns have been there for a while. But since I hadn't described them here (it's been a while since I haven't posted anything about autojump), I thought I'd take the occasion to explain the idea.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#4 2010-08-29 19:35:57

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: autojump - the cd command that learns - new version

This is a real timesaver. great app! I already had some aliases in my bash profile to use history, but not as nice as this.

I did find a little bug though. After installing on my headless server:

source /etc/profile
mkdir: cannot create directory `/home/user1/.local/share/autojump': No such file or directory

you seem to assume that there is a '~/.local/share'  folder, but in my case it isn't there. How about create it if it doesn;t exist?

Last edited by rwd (2010-08-29 21:57:26)

Offline

#5 2010-08-30 07:11:12

aeosynth
Member
From: California
Registered: 2010-02-06
Posts: 115
Website

Re: autojump - the cd command that learns - new version

If there's no match in the database for the given pattern, could you then check the current directory? I've aliased j to cd for a while now, and it's jarring having to go back to cd-ing when using a program that's supposed to *reduce* keystrokes.

Offline

#6 2010-08-30 07:33:52

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

It's not a good idea to alias cd to autojump! I mean, I could do what you request, but then "cd -" wouldn't work, autocompletion wouldn't work, and there might be ambiguities between the local path and another path. I think it's best to keep both commands, and use j as a complement to cd to jump to far paths.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#7 2010-08-30 22:22:32

aeosynth
Member
From: California
Registered: 2010-02-06
Posts: 115
Website

Re: autojump - the cd command that learns - new version

Sorry, I meant I had j aliased to cd before trying autojump. I think it'd be nice to have autojump work as a wrapper around cd, so that it didn't just fail when trying to enter new directories. Also, could you emit an error message instead of just silently failing, eg, `no match found`?

Anyway, how can I make autojump auto display the directory contents? I can do `k() { j "$@"; ls; }`, but I'd like to keep using j.

Offline

#8 2010-08-31 09:16:44

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

aeosynth wrote:

Sorry, I meant I had j aliased to cd before trying autojump. I think it'd be nice to have autojump work as a wrapper around cd, so that it didn't just fail when trying to enter new directories. Also, could you emit an error message instead of just silently failing, eg, `no match found`?

Ah, I understand better now! I don't want to change the current behavior, since I like it better the current way, but it should be fairly easy to change. For example, to add a "no match found" error message, adding

elif not completion: print >>stderr, "no match found."

at the end of the autojump file should suffice.

Anyway, how can I make autojump auto display the directory contents? I can do `k() { j "$@"; ls; }`, but I'd like to keep using j.

The definition of the bash j function is in autojump.bash, it should be fairly easy to add an ls at the end:

function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";ls;fi }

Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#9 2010-08-31 10:16:32

aeosynth
Member
From: California
Registered: 2010-02-06
Posts: 115
Website

Re: autojump - the cd command that learns - new version

Thanks a bunch.

Offline

#10 2010-08-31 10:52:29

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

Nice util, thanks for sharing.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#11 2010-11-06 16:38:22

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

Anyone else experiencing problems recently?

$ j sh
Problem with autojump database, trying to recover from backup...
Traceback (most recent call last):
  File "/usr/bin/autojump", line 132, in <module>
    path_dict=open_dic(dic_file)
  File "/usr/bin/autojump", line 117, in open_dic
    shutil.copy(dic_file+".bak",dic_file)
  File "/usr/lib/python2.7/shutil.py", line 116, in copy
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/home/user/.local/share/autojump/autojump_py'

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#12 2010-11-06 17:56:08

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

graysky wrote:

Anyone else experiencing problems recently?

This should be solved now. Could you upgrade to the latest git version, unset the PROMPT_COMMAND, source your bashrc (or just reboot :-)), fix the permissions, and tell me if it works for you?

If it is indeed solved, I will make a new release in the next few days. Sorry for the inconvenience.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#13 2010-11-06 18:11:49

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

@lardon - yeah pulling the git now.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#14 2010-11-07 07:39:56

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

@lardon - no errors so far and I've been banging on it pretty hard.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#15 2010-11-08 04:43:42

Hoek
Member
Registered: 2010-08-27
Posts: 7

Re: autojump - the cd command that learns - new version

I've installed it, but it doesn't seem to work sad

How am i supposed to use it? Does it monitor the dirs i cd into, or do i have to use "j directory" to build its cache?

jumpstat prints no directories (Total key weight: 0. Number of stored paths: 0), no matter how i jump around (using cd or autojump)
Also, bash autocompletion doesn't seem to work (j /home/<tab> does nothing)

/etc/profile is sourced by my user's .bashrc.

How to proceed from here?

Offline

#16 2010-11-08 21:43:40

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

@Hoek - did you read the pacman output?

  echo " > You need to source /etc/profile in your ~/.bashrc for this to work"
  echo " > Only guaranteed to work with bash"
  echo " > man autojump for instructions."

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#17 2010-11-09 01:28:01

vanvalium
Member
From: Austria
Registered: 2010-10-09
Posts: 86

Re: autojump - the cd command that learns - new version

neat tool, saves a lot of time
haven't tested it for a long time but works errorfree for me
thanks for making this

Offline

#18 2010-11-12 13:26:35

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

@graysky : thanks for testing! I guess everything is in order to make a new release smile

@Hoek : were you able to solve your problem?

@vanvalium : thanks!


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#19 2010-11-16 18:53:44

ksira
Member
Registered: 2009-10-27
Posts: 31

Re: autojump - the cd command that learns - new version

This is an essential time saver for command line users. Thanks for making this.

Offline

#20 2010-12-05 15:24:06

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: autojump - the cd command that learns - new version

Autojump looks like just the program for an old CLI user like me.

However I'm getting a syntax error when I run it:

  File "/usr/bin/autojump", line 31
    print "Received SIGINT, trying to continue"
                                                                     ^
I've looked at the script but the source of the error isn't jumping out at me.

I installed the program as root.  And it modified my personal .bashrc file:

# Added by autojump install.sh
source /etc/profile.d/autojump.bash

I'm running an up to date version of Arch.

I've sourced /etc/profile.

jumpstat gives me the same error.

Thanks.

Offline

#21 2010-12-05 15:48:28

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

whatshisname wrote:

Autojump looks like just the program for an old CLI user like me.

However I'm getting a syntax error when I run it:

  File "/usr/bin/autojump", line 31
    print "Received SIGINT, trying to continue"
                                                                     ^
I've looked at the script but the source of the error isn't jumping out at me.

Thanks.

Hi,

the problem is almost certainly caused by the fact that Arch's default version of python is Python3.

You can either:

- Upgrade to the latest git version of autojump, which should support both python3 and python2.
- or used the packaged version of autojump which explicitly calls python2.

In any case I'll try to release an updated version of autojump in the next few days.

Don't hesitate to tell me if this doesn't fix your problem, I'll be happy to help.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#22 2010-12-05 17:07:37

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: autojump - the cd command that learns - new version

Hi,

the problem is almost certainly caused by the fact that Arch's default version of python is Python3.

You can either:

- Upgrade to the latest git version of autojump, which should support both python3 and python2.
- or used the packaged version of autojump which explicitly calls python2.

In any case I'll try to release an updated version of autojump in the next few days.

Don't hesitate to tell me if this doesn't fix your problem, I'll be happy to help.

Ah.  I didn't even try to install it via pacman.

I downloaded "autojump_v13.tar.gz" from the git download page and that's the one I had problems with.

I removed the individual components of the previous install and reinstalled via pacman and all is well.

Thanks for the prompt reply.  I'm looking forward to this little program.

Last edited by whatshisname (2010-12-06 02:39:35)

Offline

#23 2011-05-14 13:50:10

farvardin
Member
Registered: 2008-09-03
Posts: 120
Website

Re: autojump - the cd command that learns - new version

I still have a problem with autojump.

With the AUR version (git) or the version from community:

Traceback (most recent call last):
  File "/usr/bin/autojump", line 236, in <module>
    success=shell_utility()
  File "/usr/bin/autojump", line 157, in shell_utility
    path_dict = open_dic(dic_file)
  File "/usr/bin/autojump", line 130, in open_dic
    path_dict = pickle.load(aj_file, encoding="utf-8")
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 23: ordinal not in range(128)


(I do have source /etc/profile in my .bashrc)

Last edited by farvardin (2011-05-14 13:51:00)

Offline

#24 2011-05-16 13:14:16

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: autojump - the cd command that learns - new version

Hi farvadin,

Have you been going back and forth between the two versions? What python interpreter are you using (check the shebang in /usr/bin/autojump)?


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#25 2011-08-16 21:29:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,600
Website

Re: autojump - the cd command that learns - new version

@lardon - what is the safe way to reset my autojump database?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB