Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with exit on cd with fish shell #86

Open
skewballfox opened this issue Mar 15, 2020 · 3 comments
Open

Issue with exit on cd with fish shell #86

skewballfox opened this issue Mar 15, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@skewballfox
Copy link

Hey, new user here. Just installed hunter via cargo for nightly. This probably isn't a bug so much as misconfiguration but I figured I'd bring it to your attention just in case it is.

I'm currently using fish shell on fedora and I'm trying to configure hunter to drop into last traversed directory on quit.
I wrote an equivalent shell script for fish shell for hunter_cd.sh for fish:

function hunter
     env hunter
     if test -e $HOME/.hunter_cwd
        source $HOME/.hunter_cwd and \
        rm $HOME/.hunter_cwd and cd $HUNTER_CWD
    end
end

however it's not dropping into the directory. I suspect it's because $HOME/.hunter_cwd isn't being created, though I didn't see anything in the readme about needing to be created, so I assume this is suppose to be automatic. Any ideas what I'm doing wrong?

@rabite0
Copy link
Owner

rabite0 commented May 21, 2020

You need to press Q to enable this feature on quit. That should create this file.

Btw, mind if I add that function to the repo?

@rabite0 rabite0 self-assigned this May 21, 2020
@rabite0 rabite0 added the bug Something isn't working label May 21, 2020
@ohmree
Copy link

ohmree commented Nov 22, 2020

The above solution didn't work for me since fish chokes on POSIX-style variable definitions (not if you export them first though, which could also be a solution but would require a modification to hunter).
What I ended up doing was parsing the file and using the result to set fish variables.

The code also had a subtle bug (at least I think so): rm $HOME/.hunter_cwd and #... needs to have a semicolon before the and, otherwise the rest of the line is seen as the argument list for rm.

Also env is unnecessary here, fish has the builtin command exactly for this purpose (I'm also running a few of the other commands using command because they're aliases on my machine).

With that in mind, here's my function:

function hunter
     command hunter
     if test -e $HOME/.hunter_cwd
         for line in (command cat ~/.hunter_cwd | string split '\n')
             set split (string split '=' $line)
             set $split[1] (string unescape $split[2])
         end
         command rm $HOME/.hunter_cwd; and cd $HUNTER_CWD
    end
end

@ohmree
Copy link

ohmree commented Nov 22, 2020

I do think a better solution would be to generate a separate file for fish, I've had a brief look at the code but couldn't find where exactly this happens on the master branch so I can't implement this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants