autojump icon indicating copy to clipboard operation
autojump copied to clipboard

Please support git-bash (msysgit)

Open davux opened this issue 9 years ago • 12 comments

Git-bash is a very powerful bash, posix-compatible implementation for Windows. Currently autojump doesn't support it, as it assumes that "platform=Windows" means you're using the traditional cmd.exe "shell": .bat scripts, C:\Foo\Bar directories and the like. However git-bash provides "normal" bash concepts: .sh scripting, forward-slash (/) separator, one root directory, etc. It does have some specificities: for example the users' home directories are in /c/users/ (equivalent of C:\Users), but you can still use stuff like $HOME and "~/.autojump".

Autojump support on git-bash would be completely awesome. Please add support for it.

davux avatar Feb 27 '15 20:02 davux

It would be nice if support for this was added.

cipri-tom avatar Jun 20 '16 13:06 cipri-tom

I'd be more than happy to accept pull requests. However due to lack of time and access to a Windows I can't add support myself.

wting avatar Jun 21 '16 15:06 wting

I've opened a PR which adds support for git bash. Some output that shows it working:

azrie@timberwolf MINGW64 ~
$ j -s
10.0:   C:/Users/azrie
________________________________________

10:      total weight
1:       number of entries
0.00:    current directory weight

data:    C:\Users\azrie\AppData\Roaming\autojump\autojump.txt

azrie@timberwolf MINGW64 ~
$ cd /d/work/github/wting/autojump/

azrie@timberwolf MINGW64 /d/work/github/wting/autojump (feature/issue-356-support-git-bash-msysgit)
$ cd /d/work/github/azriel91/

azrie@timberwolf MINGW64 /d/work/github/azriel91
$ j auto
D:/work/github/wting/autojump

azrie@timberwolf MINGW64 /d/work/github/wting/autojump (feature/issue-356-support-git-bash-msysgit)
$ j az
C:/Users/azrie

azrie@timberwolf MINGW64 ~
$ j az
D:/work/github/azriel91

Upon installation, it displays the /unix/like/path for sourcing in ~/.bashrc.

azrie@timberwolf MINGW64 /d/work/github/wting/autojump (feature/issue-356-support-git-bash-msysgit)
$ ./uninstall.py && ./install.py
Uninstalling autojump...

Found user installation...
deleting directory: C:\Users\azrie\AppData\Local\autojump
Installing autojump to C:\Users\azrie\AppData\Local\autojump ...
creating directory: C:\Users\azrie\AppData\Local\autojump\bin
creating directory: C:\Users\azrie\AppData\Local\autojump\share\man\man1
creating directory: C:\Users\azrie\AppData\Local\autojump\etc\profile.d
creating directory: C:\Users\azrie\AppData\Local\autojump\share\autojump
copying file: ./bin/autojump -> C:\Users\azrie\AppData\Local\autojump\bin
copying file: ./bin/autojump_argparse.py -> C:\Users\azrie\AppData\Local\autojump\bin
copying file: ./bin/autojump_data.py -> C:\Users\azrie\AppData\Local\autojump\bin
copying file: ./bin/autojump_match.py -> C:\Users\azrie\AppData\Local\autojump\bin
copying file: ./bin/autojump_utils.py -> C:\Users\azrie\AppData\Local\autojump\bin
copying file: ./bin/icon.png -> C:\Users\azrie\AppData\Local\autojump\share\autojump
copying file: ./docs/autojump.1 -> C:\Users\azrie\AppData\Local\autojump\share\man\man1
creating directory: C:\Users\azrie\AppData\Local\autojump\etc\profile.d
creating directory: C:\Users\azrie\AppData\Local\autojump\share\autojump
creating directory: C:\Users\azrie\AppData\Local\autojump\functions
copying file: ./bin/autojump.sh -> C:\Users\azrie\AppData\Local\autojump\etc\profile.d
copying file: ./bin/autojump.bash -> C:\Users\azrie\AppData\Local\autojump\share\autojump
copying file: ./bin/autojump.fish -> C:\Users\azrie\AppData\Local\autojump\share\autojump
copying file: ./bin/autojump.zsh -> C:\Users\azrie\AppData\Local\autojump\share\autojump
copying file: ./bin/_j -> C:\Users\azrie\AppData\Local\autojump\functions

Please manually add the following line(s) to ~/.bashrc:

        [[ -s /c/Users/azrie/AppData/Local/autojump/etc/profile.d/autojump.sh ]] && source /c/Users/azrie/AppData/Local/autojump/etc/profile.d/autojump.sh

Please restart terminal(s) before running autojump.

azriel91 avatar Jul 23 '16 02:07 azriel91

@wting I think it's awesome that @azriel91 contributed some code, as you suggested. What's the next step?

davux avatar May 31 '17 19:05 davux

This works with git bash on windows, is the PR going to be accepted?

gdieguez avatar Aug 18 '17 19:08 gdieguez

What is the status of this feature? Seems people would like the PR to be accepted thus we can use autojump in Git-Bash

0mza987 avatar Dec 29 '18 03:12 0mza987

"I'm not sure" is the best answer I can give – it was working 2 years ago when I first pushed, and last year based on the comments.

I rebased over master recently as it had about 46 commits ahead and force pushed, but I hadn't tested it completely from scratch this time. That's because I broke my python autojump by mixing it with this Rust autojump, and fixed it by hand (i.e. hacked my bashrc).

I guess it warrants a full retest, but it would take me a while to get to it (need to break my computer again, and I don't want to do that juust yet)

azriel91 avatar Dec 29 '18 03:12 azriel91

@wting when is this going to be actioned if at all? It seems like the PR's been open for a while now.

hangjit-domain avatar Feb 27 '20 06:02 hangjit-domain

Hey, just installed from your branch, and it's working like a charm for me. Hopefully it gets merged in! The only thing I notice is that things like:

C:\users\nsnyder\this-directory

Show up like:

C:\users
snyder   his-directory

It looks like the \ needs to be escaped to render properly, but that's just a cosmetic issue.

nsnyder avatar Mar 26 '20 13:03 nsnyder

I came across this issue today. This fix would be a great addition.

davidmn avatar Jun 18 '21 14:06 davidmn

It's an awesome feature!

Any action?

codecalvin avatar Jul 10 '21 07:07 codecalvin

Here's my solution.

Using the install script, i could call autojump command but it didn't work properly with git-bash for Windows.

I added the following to .bash_profile in my home dir:

winPathRetVal="";

winPath() {
    unixPath=$1
    # Replace /c with C:
    temp=${unixPath/\/c/C:};
    # Replace all forward slashes with backward slashes
    winPathRetVal=${temp//\//\\};
}

j() {
    # If arguments starts with "-", pass it to autojump.
    if [[ "$1" == -* ]]; then
        autojump $@
    # Else change dir and increase it's weight.
    else
        builtin cd $(autojump $@);
        winPath $(pwd);
        autojump -a $winPathRetVal;
    fi
}

cd() {
    # change dir and increase it's weight.
    builtin cd $@;
    winPath $(pwd);
    j -a $winPathRetVal;
}

ndraiman avatar May 29 '23 07:05 ndraiman