You are not logged in.

#1 2009-02-20 04:46:01

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

Autojump - the cd command that learns -, now has smart autocompletion!

You might remember my last week's post announcing autojump, a tool for faster filesystem navigation. Well, due to popular demand, I've now added autocompletion!

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.

Of course sometimes you might want to know where you're jumping before you do the jump. That's why I added autocompletion, which makes the tool more convenient.

More details on the autojump on the wiki: http://wiki.github.com/joelthelion/autojump

And as always, installation is only a

yaourt -S autojump

away!


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

Offline

#2 2009-02-20 05:31:51

evr
Arch Linux f@h Team Member
Registered: 2009-01-23
Posts: 554

Re: Autojump - the cd command that learns -, now has smart autocompletion!

very nice, i like the autocompletion

Offline

#3 2009-02-21 04:57:24

Vyazovoi
Member
From: Russia
Registered: 2007-07-31
Posts: 14
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

zsh version:

*** /home/vyazovoi/autojump    2009-02-21 09:52:55.000000000 +0500
--- /usr/bin/autojump    2009-02-20 15:08:27.000000000 +0500
***************
*** 113,118 ****
          if userchoice!=-1:
              if len(results) > userchoice-1 : print results[userchoice-1]
          elif len(results) > 1 and completion:
!             print "\n".join(("%s__%d__%s" % (pattern,n+1,r) for n,r in enumerate(results[:8])))
          else: 
              if results : print results[0]
--- 113,119 ----
          if userchoice!=-1:
              if len(results) > userchoice-1 : print results[userchoice-1]
          elif len(results) > 1 and completion:
!             # print "\n".join(("%s__%d__%s" % (pattern,n+1,r) for n,r in enumerate(results[:8])))
!             print "\n".join(("%s" % (r) for n,r in enumerate(results[:8])))
          else: 
              if results : print results[0]
if [ -n "$PS1" ]; then
    function _autojump_completer
    {
    read -Ac line
    reply=($(autojump --completion $line[2]))
    }
    compctl -K _autojump_completer j
    function precmd { autojump -a "$(pwd -P)" }
    alias jumpstat="autojump --stat"
    function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; echo; cd "$new_path";fi }
fi

P.S. autocompletion is not good currently, I fix this later.

Last edited by Vyazovoi (2009-02-21 04:59:35)

Offline

#4 2009-02-23 08:14:55

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Vyazovoi wrote:

zsh version:

snip code

P.S. autocompletion is not good currently, I fix this later.

Don't hesitate to contact me if you get it to work well.


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

Offline

#5 2009-03-05 16:12:35

LeoSolaris
Member
From: South Carolina
Registered: 2008-03-30
Posts: 354

Re: Autojump - the cd command that learns -, now has smart autocompletion!

sweet little app!

I just started trying it out after seeing it mentioned in the newsletter. Ya know, if you add an alias to make 'cd' run autojump, this becomes even more useful, then it almost seems like a new feature of cd.

I wonder if it could become robust enough to actually replace cd entirely in the future.


I keep getting distracted from my webserver project...

huh? oooh...  shiny!

Offline

#6 2009-03-05 17:47:29

abesto
Member
From: Hungary
Registered: 2009-03-05
Posts: 49
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

This is beautiful. Thank you.

LeoSolaris: autojump needs to echo the dir it switched to - that's unavoidable. I don't like this echo when doing a simple 'cd ..'  that might be just me, though.

Off: Also, hi all. I just registered to the forums after using Arch for a half year or so.


Linux user #476135 || Dotfiles hosted by GitHub

Offline

#7 2009-03-05 18:17:10

CoolGenie
Member
Registered: 2008-04-06
Posts: 56

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Beautiful!
Thanks!

Offline

#8 2009-03-05 18:19:03

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Thanks to both of you for your nice comments smile

absesto I agree with you, I think autojump and cd should better stay separate. cd is still useful for relative path navigation, such as cd .. .

One improvement I am currently thinking about is performance. I wonder if implementing autojump as a daemon could improve performance?

As a side note you might have noticed that autojump is now in community. Thanks a lot to gcarrier for promoting it!


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

Offline

#9 2009-03-05 18:47:44

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: Autojump - the cd command that learns -, now has smart autocompletion!

this package is, in all honesty, just incredible.

brilliant.

thank you immeasurably

Offline

#10 2009-03-06 16:59:00

face
Member
From: Cologne, Germany
Registered: 2008-08-17
Posts: 7

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Just WHAO, its fantastic. big_smile

Offline

#11 2009-03-07 02:58:40

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

I was skeptical that anything could instantly improve on cd, but your little program is great. Thank you!

Offline

#12 2009-03-08 07:33:01

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: Autojump - the cd command that learns -, now has smart autocompletion!

is the package in the repo broken or am im just completely oblivious on how to use this? man jumpstat gives me the man page yet 'j [directory]' and 'jumpstat' both return with command not found

Offline

#13 2009-03-08 07:47:00

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Autojump - the cd command that learns -, now has smart autocompletion!

brando56894 wrote:

is the package in the repo broken or am im just completely oblivious on how to use this? man jumpstat gives me the man page yet 'j [directory]' and 'jumpstat' both return with command not found

Sounds like you didn't source /etc/profile in ~/.bashrc as described in the post-install message.

EDIT: Or you could just copy the content of /etc/profile.d/autojump.bash into your ~/.bashrc.

Last edited by Runiq (2009-03-08 08:34:37)

Offline

#14 2009-03-08 07:50:14

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: Autojump - the cd command that learns -, now has smart autocompletion!

I didnt see that since I installed it via shaman :-/

Offline

#15 2009-03-08 08:51:19

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Runiq wrote:

Sounds like you didn't source /etc/profile in ~/.bashrc as described in the post-install message.
EDIT: Or you could just copy the content of /etc/profile.d/autojump.bash into your ~/.bashrc.

Yep, that's the crucial part. I don't want to do it automatically since a .bashrc file is very personal, so autojump won't work if the user doesn't read the post_install message :-/


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

Offline

#16 2009-03-08 09:08:58

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Autojump - the cd command that learns -, now has smart autocompletion!

lardon wrote:
Runiq wrote:

Sounds like you didn't source /etc/profile in ~/.bashrc as described in the post-install message.
EDIT: Or you could just copy the content of /etc/profile.d/autojump.bash into your ~/.bashrc.

Yep, that's the crucial part. I don't want to do it automatically since a .bashrc file is very personal, so autojump won't work if the user doesn't read the post_install message :-/

Well, I don't actually use /etc/profile (unless it's sourced in some rc.* script), so I sourced it once and was put off by a non-colored prompt. tongue

Offline

#17 2009-03-08 09:30:46

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Well, I don't actually use /etc/profile (unless it's sourced in some rc.* script), so I sourced it once and was put off by a non-colored prompt. tongue

If you don't want to source /etc/profile (which i understand), you can source /etc/profile.d/autojump.bash directly. Maybe this is what I should recommend in the install file.


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

Offline

#18 2009-03-08 12:02:13

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Autojump - the cd command that learns -, now has smart autocompletion!

lardon wrote:

Well, I don't actually use /etc/profile (unless it's sourced in some rc.* script), so I sourced it once and was put off by a non-colored prompt. tongue

If you don't want to source /etc/profile (which i understand), you can source /etc/profile.d/autojump.bash directly. Maybe this is what I should recommend in the install file.

...d'oh! Of course. Thank you. roll

Offline

#19 2009-03-08 12:46:47

Ink-Jet
Member
From: London
Registered: 2008-03-27
Posts: 64
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

I have

 source /etc/profile.d/autojump.bash

in my ~/.bashrc, but autocompletion isn't working.

Is there anything else I need to do?

Offline

#20 2009-03-08 12:59:08

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Ink-Jet wrote:

I have

 source /etc/profile.d/autojump.bash

in my ~/.bashrc, but autocompletion isn't working.

Is there anything else I need to do?

Do you have bash-completion installed? I guess it should at least be in the optional dependencies of the package.


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

Offline

#21 2009-03-08 13:10:57

Ink-Jet
Member
From: London
Registered: 2008-03-27
Posts: 64
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Yeah, and I have

source /etc/bash_completion

in my ~/.bashrc as well.

Offline

#22 2009-03-08 13:18:39

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Did you just install autojump? what is the output of "jumpstat"? Autojump's autocompletion is quite peculiar, don't expect it to work like completion for cd for example.


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

Offline

#23 2009-03-08 13:29:23

Ink-Jet
Member
From: London
Registered: 2008-03-27
Posts: 64
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Yeah, I just hadn't grasped how the autocompletion works, i was expecting it to work like cd, when navigating to a directory.
Would be nice if it worked like cd, haha, would make a pretty much total replacement.

However, as a feature request, if autojump didn't print a spare newline after showing what directory is jumped too, I'd be very happy
For example:

joe@joanna:~ > j Tech
/home/joe/Tech

joe@joanna:~/Tech >

Where there's an unnecessary newline.

Offline

#24 2009-03-08 14:38:12

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

Re: Autojump - the cd command that learns -, now has smart autocompletion!

I'm glad it finally worked for you smile You can remove the newline quite easily, there's an extra "echo" that does just that in the "j" function in autojump.bash. I've also removed it in the dev branch smile Thanks for the report!


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

Offline

#25 2009-03-08 15:16:19

Ink-Jet
Member
From: London
Registered: 2008-03-27
Posts: 64
Website

Re: Autojump - the cd command that learns -, now has smart autocompletion!

Works even better now big_smile

Offline

Board footer

Powered by FluxBB