我将Fish设置为此处引用的登录shell (https://fishshell.com/docs/current/index.html#default-shell)。
然后安装rbenv
。
但是我必须重新加载Fish shell来调用rbenv
。
看下面很容易理解。
yas ~ ps -f
UID PID PPID C STIME TTY TIME CMD
501 55722 55721 0 5:09PM ttys001 0:00.02 -fish //set fish as login shell
yas ~ rbenv // couldn't find rbenv
fish: Unknown command: rbenv
yas ~ echo $PATH // couldn't find a path to rbenv
/Users/yas/.anyenv/envs/pyenv/shims /opt/homebrew/bin /opt/homebrew/sbin /opt/homebrew/opt/openssl@1.1/bin /opt/homebrew/opt/openssl@3/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Users/yas/.anyenv/envs/pyenv/bin
yas ~ exec $SHELL -l // Reloading the shell
yas ~ rbenv --version // succeeded
rbenv 1.2.0-14-gc6cc0a1
yas ~ echo $PATH // Paths are added after reloading the shell.
/Users/yas/.anyenv/envs/rbenv/shims /Users/yas/.anyenv/envs/pyenv/shims /opt/homebrew/bin /opt/homebrew/sbin /opt/homebrew/opt/openssl@1.1/bin /opt/homebrew/opt/openssl@3/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/homebrew/bin /opt/homebrew/sbin /Users/yas/.anyenv/envs/pyenv/bin /Users/yas/.anyenv/envs/pyenv/bin /Users/yas/.anyenv/envs/rbenv/bin
yas ~ ps -f // shell path has changed from -fish after reloading.
UID PID PPID C STIME TTY TIME CMD
501 55722 55721 0 5:09PM ttys001 0:00.16 /opt/homebrew/bin/fish -l
Inside~/.config/fish/config.fish
if status is-interactive
# Commands to run in interactive sessions can go here
end
eval (/opt/homebrew/bin/brew shellenv)
status --is-interactive; and source (anyenv init -|psub)
set fish_function_path $fish_function_path "/Users/yas/.anyenv/envs/pyenv/versions/3.10.5/lib/python3.10/site-packages/powerline/bindings/fish"
powerline-setup
我不喜欢每次启动时都输入exec $SHELL -l
。有人帮帮我吗?
这是https://github.com/anyenv/anyenv/pull/99 - anyenv的pyenv设置会干扰其他env:
在当前情况下,pyenv init——path也会导致anyenv的问题。当登录到zsh时,初始化过程停止在pyenv,而不可能继续(如rbenv或sbtenv)。
作为一种解决方案,应该可以只运行两次anyenv init -
,因为似乎pyenv设置被跳过或第二次成功(这将是当您运行两次fish时修复它的方法!):
status --is-interactive; and source (anyenv init -|psub)
status --is-interactive; and source (anyenv init -|psub)
可简化为
if status is-interactive
anyenv init - | source
anyenv init - | source
end