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

Explicit fasd in cd function instead of implicit on postexec #19

Closed
wants to merge 3 commits into from

Conversation

ianhomer
Copy link

@ianhomer ianhomer commented Feb 7, 2021

A cautious PR to address #16.

Cautious because it works for what I need, however it is opinionated in the override of cd. It will also regress behaviour for anyone who was relying on the implicit effect of fish postexec. This change causes the fasd register to only occur when you use cd. I'm raising this PR since it may help find the right direction - happy for any iteration / debate / alternatives.

@ianhomer ianhomer changed the title Explicit fasd in cd instead of implicit on postexec Explicit fasd in cd function instead of implicit on postexec Feb 7, 2021
@gretel
Copy link
Member

gretel commented Feb 7, 2021

@ianhomer thanks! i don't worry much about the postexec but about

it is opinionated in the override of cd

think this is too much of a override just calling for confusion.

@ianhomer
Copy link
Author

ianhomer commented Feb 8, 2021

Thx @gretel - agree, that concerns me too for a general release. Fine in someone's dotfiles though.

fasd --init auto shows how it is done in other shells, e.g. bash executes it in the prompt (pretty much like the postexec approach)

_fasd_prompt_func() {
  eval "fasd --proc $(fasd --sanitize $(history 1 | \
    sed "s/^[ ]*[0-9]*[ ]*//"))" >> "/dev/null" 2>&1
}

This generic approach does seem excessive since it fires after each command.

@ianhomer
Copy link
Author

ianhomer commented Feb 8, 2021

Closing pull request - since just not happy with suggesting everyone should override their cd function

@ianhomer ianhomer closed this Feb 8, 2021
@gretel
Copy link
Member

gretel commented Feb 9, 2021

@ianhomer hmm ok but what now? :)

@ianhomer
Copy link
Author

ianhomer commented Feb 14, 2021

Good question - this has led me to realise all I need from fasd is remembering the directories I cd into. I think I have lighter need than other fasd users and now I realised that there was this postexec / prompt exec (bash) going on I wanted to strip that out from my systems (since it feels overkill). My use case for fasd is simply the functions / completion below

function cd -d "Register directory and change to directory"
  fasd -A $argv
  builtin cd $argv
end
function z -d "Change directory"
  cd $argv
end

with completions/z.fish

complete -c z -a "(fasd -l -d)" -f

The cd function above is not really compatible with the general scope of the full fasd support that this plugin is trying to achieve. To answer the what next question we'd need to find generic way to do a pre-exec on a command in fish - postexec is too late for wild card removal of files that had been removed. I couldn't find any pre-exec way, so I was stumped - and hence just gone for the simple functions in my dotfiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants