ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
22.07k stars 537 forks source link

using --cmd with init in fish config configuration doesn't replace the cd command #730

Closed blyzer closed 6 months ago

blyzer commented 7 months ago

using --cmd in fish config configuration doesn't replace the cd command

I have reopened three times.

here is my configuration:

#if test $(defaults read -globalDomain AppleInterfaceStyle) = "Dark"
#            base16-tomorrow-night-eighties
#else
#           base16-tomorrow
#end

#function starship_transient_prompt_func
#  starship module character
#end

#starship init fish | source

#enable_transience

#function fish_right_prompt_loading_indicator
#    echo (set_color '#aaa')' … '(set_color normal)
#end

function _git_branch_name
    sleep 1 # For demo.
    git symbolic-ref --short HEAD ^/dev/null
end

# Async prompt setup.
#set async_prompt_functions _git_branch_name

function fzf --wraps=fzf --description="Use fzf-tmux if in tmux session"
  if set --query TMUX
    fzf-tmux $argv
  else
    command fzf $argv
  end
end

#/opt/homebrew/Cellar/starship/1.11.0/bin/./starship init fish | source
#base16_tomorrow_night_eighties

# pnpm
set -gx PNPM_HOME "/Users/*****/Library/pnpm"
set -gx PATH "$PNPM_HOME" $PATH
# pnpm end
# retrieve command cheat sheets from cheat.sh
# fish version by @tobiasreischmann

function cheat.sh
    curl cheat.sh/$argv
end

# register completions (on-the-fly, non-cached, because the actual command won't be cached anyway
complete -c cheat.sh -xa '(curl -s cheat.sh/:list)'

if status is-interactive
  printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "fish"}}\x9c'
end
set -gx AWS_PROFILE (aws configure get profile)
function kubectl
  kubecolor $argv
end

# Setting PATH for Python 3.12
# The original version is saved in /Users/****/.config/fish/config.fish.pysave
set -x PATH "/Library/Frameworks/Python.framework/Versions/3.12/bin" "$PATH"
**zoxide init --cmd cd fish | source**
ajeetdsouza commented 7 months ago

What do you mean by doesn't replace the cd command?

aybarsnazlica commented 7 months ago

I have the same problem. Adding zoxide init fish | source to the end of fish config file works fine. However, zoxide init --cmd cd fish | source doesn't add zoxide to fish.

ajeetdsouza commented 7 months ago

However, zoxide init --cmd cd fish | source doesn't add zoxide to fish.

I've still not fully understood - what do you mean by "zoxide is not added to fish"? Also, what is your fish version / zoxide version?

andyw134 commented 7 months ago

I have zoxide init --cmd cd fish | source in my fish config at ~/.config/fish/config.fish when I launch a new terminal and run which cd I get /usr/bin/cd

If I run zoxide init --cmd cd fish | source in a terminal I get the same result.

Running alias I do get the following results alias cd __zoxide_z alias cdi __zoxide_zi

And when I try to use zoxide as described it does work For example cd code will take me to ~/dev/code from the home directory

On MacOS 14.2.1, Fish v3.7.0, zoxide 0.9.4

ajeetdsouza commented 7 months ago

@andyw134 the which command locates binaries with a given name, whereas zoxide defines cd as a function. Is there any issue you're having with the setup?

andyw134 commented 7 months ago

No issues, but I initially thought it was not working. Was contributing my experience in case it would help others.

gprst commented 7 months ago

Thank you, I had the exact same setup and too thought that because which cd returned /usr/bin/cd it wouldn't work. I know now that it does. Thanks for sharing 👍

ajeetdsouza commented 6 months ago

Cool cool, closing this issue.