fix(fish): explicitly set scope in fish init script (#2636)

* fix: use correct scope in fish init script

* Prefix variable names with Starship

* Use `functions -e` to remove `fish_mode_prompt`

* Update src/init/starship.fish

Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>

Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
This commit is contained in:
Kid 2021-04-30 01:16:10 +08:00 committed by GitHub
parent d57a0fe9df
commit 16855fe8e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -1,20 +1,22 @@
function fish_prompt
switch "$fish_key_bindings"
case fish_hybrid_key_bindings fish_vi_key_bindings
set keymap "$fish_bind_mode"
set STARSHIP_KEYMAP "$fish_bind_mode"
case '*'
set keymap insert
set STARSHIP_KEYMAP insert
end
set -l exit_code $status
set STARSHIP_CMD_STATUS $status
# Account for changes in variable name between v2.7 and v3.0
set -l starship_duration "$CMD_DURATION$cmd_duration"
::STARSHIP:: prompt --status=$exit_code --keymap=$keymap --cmd-duration=$starship_duration --jobs=(count (jobs -p))
set STARSHIP_DURATION "$CMD_DURATION$cmd_duration"
::STARSHIP:: prompt --status=$STARSHIP_CMD_STATUS --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=(count (jobs -p))
end
# disable virtualenv prompt, it breaks starship
set VIRTUAL_ENV_DISABLE_PROMPT 1
# Disable virtualenv prompt, it breaks starship
set -g VIRTUAL_ENV_DISABLE_PROMPT 1
# Remove default mode prompt
builtin functions -e fish_mode_prompt
function fish_mode_prompt; end
set -gx STARSHIP_SHELL "fish"
# Set up the session key that will be used to store logs