Implement venv detection for fish
This commit is contained in:
parent
1daf745d74
commit
831043b773
@ -569,16 +569,14 @@ class CloneCmd:
|
|||||||
if k == 'a':
|
if k == 'a':
|
||||||
self.args.append(v)
|
self.args.append(v)
|
||||||
elif k == 'env':
|
elif k == 'env':
|
||||||
self.env = parse_bash_env(v) if self.envfmt == 'bash' else parse_null_env(v)
|
env = parse_bash_env(v) if self.envfmt == 'bash' else parse_null_env(v)
|
||||||
for filtered in (
|
self.env = {k: v for k, v in env.items() if k not in (
|
||||||
'HOME', 'LOGNAME', 'USER',
|
'HOME', 'LOGNAME', 'USER',
|
||||||
# some people export these. We want the shell rc files to
|
# some people export these. We want the shell rc files to recreate them
|
||||||
# recreate them
|
|
||||||
'PS0', 'PS1', 'PS2', 'PS3', 'PS4', 'RPS1', 'PROMPT_COMMAND', 'SHLVL',
|
'PS0', 'PS1', 'PS2', 'PS3', 'PS4', 'RPS1', 'PROMPT_COMMAND', 'SHLVL',
|
||||||
# skip SSH environment variables
|
# skip SSH environment variables
|
||||||
'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_ORIGINAL_COMMAND', 'SSH_TTY', 'SSH2_TTY',
|
'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_ORIGINAL_COMMAND', 'SSH_TTY', 'SSH2_TTY',
|
||||||
):
|
)}
|
||||||
self.env.pop(filtered, None)
|
|
||||||
elif k == 'cwd':
|
elif k == 'cwd':
|
||||||
self.cwd = v
|
self.cwd = v
|
||||||
elif k == 'argv':
|
elif k == 'argv':
|
||||||
|
|||||||
@ -24,6 +24,14 @@ not functions -q __ksi_schedule || exit 0
|
|||||||
set -q fish_killring || set -q status_generation || string match -qnv "3.1.*" "$version"
|
set -q fish_killring || set -q status_generation || string match -qnv "3.1.*" "$version"
|
||||||
or echo -en \eP@kitty-print\|V2FybmluZzogVXBkYXRlIGZpc2ggdG8gdmVyc2lvbiAzLjMuMCsgdG8gZW5hYmxlIGtpdHR5IHNoZWxsIGludGVncmF0aW9uLgo=\e\\ && exit 0 || exit 0
|
or echo -en \eP@kitty-print\|V2FybmluZzogVXBkYXRlIGZpc2ggdG8gdmVyc2lvbiAzLjMuMCsgdG8gZW5hYmxlIGtpdHR5IHNoZWxsIGludGVncmF0aW9uLgo=\e\\ && exit 0 || exit 0
|
||||||
|
|
||||||
|
if test -n "$KITTY_IS_CLONE_LAUNCH"
|
||||||
|
set -g __ksi_is_clone_launch "$KITTY_IS_CLONE_LAUNCH"
|
||||||
|
set --erase KITTY_IS_CLONE_LAUNCH
|
||||||
|
set -g __ksi_pre_rc_path "$PATH"
|
||||||
|
set -g __ksi_pre_rc_conda_default_env "$CONDA_DEFAULT_ENV"
|
||||||
|
set -g __ksi_pre_rc_python_venv "$VIRTUAL_ENV"
|
||||||
|
end
|
||||||
|
|
||||||
function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after other scripts have run, we hope"
|
function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after other scripts have run, we hope"
|
||||||
functions --erase __ksi_schedule
|
functions --erase __ksi_schedule
|
||||||
test -n "$KITTY_SHELL_INTEGRATION" || return 0
|
test -n "$KITTY_SHELL_INTEGRATION" || return 0
|
||||||
@ -106,6 +114,22 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after
|
|||||||
end
|
end
|
||||||
__update_cwd_osc
|
__update_cwd_osc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Handle clone launches
|
||||||
|
if test -n "$__ksi_is_clone_launch"
|
||||||
|
set -gx --path PATH "$__ksi_pre_rc_path"
|
||||||
|
if test -n "$__ksi_pre_rc_python_venv" -a -r "$__ksi_pre_rc_python_venv/bin/activate.fish"
|
||||||
|
set -e VIRTUAL_ENV _OLD_FISH_PROMPT_OVERRIDE # activate.fish stupidly exports _OLD_FISH_PROMPT_OVERRIDE
|
||||||
|
source "$__ksi_pre_rc_python_venv/bin/activate.fish"
|
||||||
|
else if test -n "$__ksi_pre_rc_conda_default_env"
|
||||||
|
and type -q conda
|
||||||
|
and test "$__ksi_pre_rc_conda_default_env" != "$CONDA_DEFAULT_ENV"
|
||||||
|
echo $__ksi_pre_rc_conda_default_env
|
||||||
|
# for some reason that I cant be bothered to figure out this doesnt take effect
|
||||||
|
conda activate $_ksi_pre_rc_conda_default_env
|
||||||
|
end
|
||||||
|
set --erase __ksi_is_clone_launch __ksi_pre_rc_path __ksi_pre_rc_conda_default_env __ksi_pre_rc_python_venv
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function clone-in-kitty -d "Clone the current fish session into a new kitty window"
|
function clone-in-kitty -d "Clone the current fish session into a new kitty window"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user