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:
Johannes Altmanninger
2020-05-15 07:56:06 +02:00
parent fe6c76d058
commit 49c5f96470
59 changed files with 152 additions and 146 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)"