You are not logged in.

#26 2009-03-09 14:50:05

Gringo
Member
From: The Netherlands
Registered: 2008-07-31
Posts: 37

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

One of the finest, handiest tools I have discovered in the last few months. It's simple but extremely useful. Thanks a lot!

Offline

#27 2009-03-09 15:35:31

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

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

I haven't tried this yet, but does someone know, in the new bash 4.0, there is the feature to do something with failed commands, if you can use that for autojump?

E.g.

You set `command_not_found()` to autojump (not really sure what the function is called)
Although it would probably be
function command_not_found() { j $1; }

You type 'd' (which fails)

Bash runs `autojump d`

Offline

#28 2009-03-10 08:43:55

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

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

Procyon wrote:

I haven't tried this yet, but does someone know, in the new bash 4.0, there is the feature to do something with failed commands, if you can use that for autojump?

E.g.

You set `command_not_found()` to autojump (not really sure what the function is called)
Although it would probably be
function command_not_found() { j $1; }

You type 'd' (which fails)

Bash runs `autojump d`

I'm not sure I understand your comment. Are sure you understand what autojump is?


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

Offline

#29 2009-03-10 12:45:27

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

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

lardon wrote:
Procyon wrote:

I haven't tried this yet, but does someone know, in the new bash 4.0, there is the feature to do something with failed commands, if you can use that for autojump?

E.g.

You set `command_not_found()` to autojump (not really sure what the function is called)
Although it would probably be
function command_not_found() { j $1; }

You type 'd' (which fails)

Bash runs `autojump d`

I'm not sure I understand your comment. Are sure you understand what autojump is?

He basically wants to use autojump without the "j" in front of the directory. If he types the name of a directory without the "j" in front of it, bash usually reports "command not found". By remapping this "command not found" function(?) to do "j <directory>", it'd be possible to jump to a directory without putting "j" in front of it.

Tbh, this doesn't seem like a practical solution to me. What if you want to browse, say, packages in /var/lib/pacman? Since the command to execute a package is very often the same as its name, you might get yourself into trouble. It probably won't work with spaces either, but that shouldn't be a big deal.

Offline

#30 2009-03-10 15:55:18

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

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

Thanks for explaining! Sounds like a cool idea, but I'm not sure how well it would work in practice. I'm not sure I would appreciate being brought to a random place when I mistype a command smile


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

Offline

#31 2009-03-10 18:58:29

redbeard0531
Member
Registered: 2007-12-28
Posts: 12

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

I added the following to my .bashrc . I think this makes it a better drop-in for cd since I can still use "cd -" and cd to relative paths. Also I like that it uses the normal tab-completion for cd.

better_cd(){
  builtin cd "$@" 2> /dev/null && return 0

  # fallback to autojump if cd fails
  new_path="$(autojump $@)"
  if [ -n "$new_path" ]
    then builtin cd "$new_path"
    else echo cannot cd to "$@"
  fi
}

alias cd="better_cd"

PS- anybody know a good way to do something like "if not builtin cd foo" in bash without spawing a subshell (which defeats the point of cd)?

Offline

#32 2009-03-11 14:15:49

ArchArael
Member
From: Switzerland
Registered: 2005-06-14
Posts: 485

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

Wow!!! This utility is really amazing. Thank you very much, lardon. This improves a lot my bash experience. smile

Keep up the good work !!! wink

Offline

#33 2009-03-29 19:06:23

dandus
Member
Registered: 2008-12-05
Posts: 8

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

I tried disintstalling it but something must have gone incomplete. It is like if it tried to execute autojump every time I press the enter button:

[dandus@democrito ~]$ 
bash: autojump: command not found
[dandus@democrito ~]$

Any ideas?

Last edited by dandus (2009-03-29 20:13:42)

Offline

#34 2009-03-29 19:16:00

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

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

you need to unset the PROMPT_COMMAND environment variable. Thanks for the report, we probably need to do something about it.


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

Offline

#35 2009-03-30 00:15:56

dandus
Member
Registered: 2008-12-05
Posts: 8

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

Thankyou! How do I do that in a permanent manner? I would add

unset PROMPT_COMMAND

to my .bashrc, but I believe there is a way involving good programming too for doing it.

Offline

#36 2009-03-30 16:17:34

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

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

Normaly, the problem should go away if you reboot, or at least log out and log in again. If this is not the case, can you give me the output of

1) cat ~/.bashrc
2) ls /etc/profile.d

?


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

Offline

#37 2009-03-31 14:18:47

IdoMcFly
Member
Registered: 2007-12-18
Posts: 28

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

does it work on zsh ?

Offline

#38 2009-03-31 14:29:33

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

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

uoCuDwag wrote:

How do I completely uninstall? I keep getting various messages (or, the same, but it varies as I remove different pieces) in the terminal every single time I press enter.

Could you be more specific on the error messages? Did you install using the official arch package? This is clearly an area we have to work on, but it's difficult to advance without clear descriptions of the problems.


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

Offline

#39 2009-03-31 14:30:10

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

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

IdoMcFly wrote:

does it work on zsh ?

I'm working on a port, it should be available in a few days. I will keep you updated smile


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

Offline

#40 2009-03-31 18:51:29

dandus
Member
Registered: 2008-12-05
Posts: 8

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

Nevermind, I solved that. Rebooting was just enough, I didn't  notice because I added "unset PROMT_COMMAND" to my ~/.bashrc smile

Thankyou very much for your help.

Last edited by dandus (2009-03-31 18:52:34)

Offline

#41 2009-04-05 10:57:16

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 1,958
Website

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

looks similar to cdargs (http://debaday.debian.net/2009/04/05/cd … er-for-cd/)
Too bad the users prompt command gets overridden.  I would like to keep my personal one.  Maybe there is a cleaner way to "append" logic to the prompt command instead of overriding.
eg instead of:

export PROMPT_COMMAND='autojump -a "$(pwd -P)"'

Something like:

if [[ $foo != *'autojump -a'* ]]
then
    [ -n "$PROMPT_COMMAND" ] && export PROMPT_COMMAND="$PROMPT_COMMAND ; autojump -a \"$(pwd -P)\""
    [ -z "$PROMPT_COMMAND" ] && export PROMPT_COMMAND='autojump -a "$(pwd -P)"'
fi

Also I don't understand why you must source /etc/profile from your .bashrc.
As far as I know /etc/profile contains all base settings and gets sourced on each login, and customisations on top of that get sourced through .bashrc and .bash_profile files in $HOME.  So I think re-sourcing the global /etc/profile is against "how it should work" and could even reset specific customisations a user wants.

Last edited by Dieter@be (2009-04-05 11:21:28)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#42 2009-04-16 08:51:01

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

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

Dieter@be wrote:

looks similar to cdargs (http://debaday.debian.net/2009/04/05/cd … er-for-cd/)
Too bad the users prompt command gets overridden.  I would like to keep my personal one.  Maybe there is a cleaner way to "append" logic to the prompt command instead of overriding.
eg instead of:

export PROMPT_COMMAND='autojump -a "$(pwd -P)"'

Something like:

if [[ $foo != *'autojump -a'* ]]
then
    [ -n "$PROMPT_COMMAND" ] && export PROMPT_COMMAND="$PROMPT_COMMAND ; autojump -a \"$(pwd -P)\""
    [ -z "$PROMPT_COMMAND" ] && export PROMPT_COMMAND='autojump -a "$(pwd -P)"'
fi

Also I don't understand why you must source /etc/profile from your .bashrc.
As far as I know /etc/profile contains all base settings and gets sourced on each login, and customisations on top of that get sourced through .bashrc and .bash_profile files in $HOME.  So I think re-sourcing the global /etc/profile is against "how it should work" and could even reset specific customisations a user wants.

I just saw your message, and I'd just like to say that the latest version (it's not been packaged for arch yet) doesn't override the prompt command anymore.

About /etc/profile, i don't think it gets sourced by default on arch, because otherwise autojump would work without re-sourcing it, right? But I don't really know how to check that.


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

Offline

#43 2009-04-19 20:48:26

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 1,958
Website

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

lardon wrote:

About /etc/profile, i don't think it gets sourced by default on arch, because otherwise autojump would work without re-sourcing it, right? But I don't really know how to check that.

Ah sorry, I keep forgetting there are people who do not login through bash but use graphical login managers.
The logic I explained only counts for login shells.
here is an interesting read: http://www.linuxquestions.org/questions … rc-273992/
I think you should use /etc/bashrc instead of /etc/profile , and source /etc/bashrc from the users .bashrc.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#44 2009-05-25 15:23:36

mang
Member
From: stockholm/sweden
Registered: 2008-11-11
Posts: 27
Website

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

Hey! It looks really nice! i tried it out in bash but what happened with the zsh version? i didn't understand how to use Vyazovoi version:/

Offline

#45 2009-05-26 13:47:06

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

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

mang wrote:

Hey! It looks really nice! i tried it out in bash but what happened with the zsh version? i didn't understand how to use Vyazovoi version:/

No need to use Vyazovoi's version, there is good zsh support in the mainstream code. Just use the zsh installer provided with the code (unfortunately the arch package is very outdated because the maintainer doesn't seem to be active anymore).


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

Offline

#46 2009-05-26 19:00:15

mang
Member
From: stockholm/sweden
Registered: 2008-11-11
Posts: 27
Website

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

Woho thanks a lot! Didn't look in the git, works great know:)

Offline

#47 2009-05-26 19:25:03

stefanwilkens
Member
From: Enschede, the Netherlands
Registered: 2008-12-10
Posts: 624

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

this just saved me a buttload of aliassing, thanks! big_smile

Last edited by stefanwilkens (2009-05-26 19:25:14)


Arch i686 on Phenom X4 | GTX760

Offline

#48 2009-07-18 08:42:03

TheGrudge
Member
Registered: 2006-06-15
Posts: 206
Website

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

Dieter@be wrote:

looks similar to cdargs (http://debaday.debian.net/2009/04/05/cd … er-for-cd/)
Too bad the users prompt command gets overridden.  I would like to keep my personal one.  Maybe there is a cleaner way to "append" logic to the prompt command instead of overriding.

For me it was enough to put

source /etc/profile

at top of my .bashrc, this fixed the prompt handling.

I have a question though: When I jump into a folder and type ls, this folder gets 3 point added each time I use ls.
Is this a feature?
If so, is there a way to turn it off?
For me autojump would be much nicer if it really counts how often I "cd" into a folder, not how active I am in it.

Nevertheless, great little program big_smile

Last edited by TheGrudge (2009-07-18 08:42:32)


digiKam developer - www.digikam.org

Offline

#49 2009-07-20 17:16:05

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

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

TheGrudge wrote:

I have a question though: When I jump into a folder and type ls, this folder gets 3 point added each time I use ls.
Is this a feature?
If so, is there a way to turn it off?
For me autojump would be much nicer if it really counts how often I "cd" into a folder, not how active I am in it.

Nevertheless, great little program big_smile

It should add only one point each time you use ls... Can you post your PROMPT_COMMAND?

Anyways, adding each time you do something in a directory is a feature, or at least a design decision. When creating autojump, I tried both options and liked the current one best. Of course, your experience may differ, and you may want to change it. One way you could do it is to get rid of the PROMPT_COMMAND entirely, and rebind the cd builtin to add the directory to autojump. Shouldn't be too hard smile


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

Offline

#50 2010-02-18 20:26:15

JezdziecBezNicka
Member
From: Cracow, Poland
Registered: 2009-12-03
Posts: 88

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

This tool is amazing, sweet etc., I didn't even realize how miserable I was without it.

In fact, if I had known how inefficient cd-ing really was (which I couldn't have known, since I haven't had used j back then), I would do something drastic. Fortunately, this is not Terminator 3 and I'm not my own son sent to the past by my father to have a kid with my mother (or something like that), and the knowledge of inefficiency of cd came _after_ using j for the first time, I'm not angry at myself at all.

Anyway it is a must-have for any Archer! Why not include it in here?


This is my signature. If you want to read it, first you need to agree to the EULA.

Offline

Board footer

Powered by FluxBB