mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
Use set -l to force use of a local variable
Bare set overwrites a global/universal variable if it exists.
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
# author: Acidhub - https://acidhub.click/
|
||||
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
set laststatus $status
|
||||
set -l laststatus $status
|
||||
|
||||
set -l git_info
|
||||
if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '')
|
||||
set git_branch (set_color -o blue)"$git_branch"
|
||||
set -l git_status
|
||||
if command git diff-index --quiet HEAD --
|
||||
if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
|
||||
echo $count | read -l ahead behind
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
|
||||
function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present'
|
||||
# Set variable identifying the chroot you work in (used in the prompt below)
|
||||
if not set -q debian_chroot
|
||||
set -l debian_chroot $debian_chroot
|
||||
if not set -q debian_chroot[1]
|
||||
and test -r /etc/debian_chroot
|
||||
set debian_chroot (cat /etc/debian_chroot)
|
||||
end
|
||||
if not set -q __fish_debian_chroot_prompt
|
||||
and set -q debian_chroot
|
||||
and set -q debian_chroot[1]
|
||||
and test -n "$debian_chroot"
|
||||
set -g __fish_debian_chroot_prompt "($debian_chroot)"
|
||||
end
|
||||
|
||||
@@ -32,8 +32,8 @@ function fish_prompt
|
||||
|
||||
function _nim_prompt_wrapper
|
||||
set retc $argv[1]
|
||||
set field_name $argv[2]
|
||||
set field_value $argv[3]
|
||||
set -l field_name $argv[2]
|
||||
set -l field_value $argv[3]
|
||||
|
||||
set_color normal
|
||||
set_color $retc
|
||||
@@ -107,7 +107,7 @@ function fish_prompt
|
||||
and _nim_prompt_wrapper $retc V (basename "$VIRTUAL_ENV")
|
||||
|
||||
# git
|
||||
set prompt_git (fish_git_prompt | string trim -c ' ()')
|
||||
set -l prompt_git (fish_git_prompt | string trim -c ' ()')
|
||||
test -n "$prompt_git"
|
||||
and _nim_prompt_wrapper $retc G $prompt_git
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ function fish_prompt
|
||||
|
||||
set -l cwd $cyan(basename (prompt_pwd))
|
||||
|
||||
set -l repo_info
|
||||
if set -l repo_type (_repo_type)
|
||||
set -l repo_branch $red(_repo_branch_name $repo_type)
|
||||
set repo_info "$blue $repo_type:($repo_branch$blue)"
|
||||
|
||||
Reference in New Issue
Block a user