Skip to content

Commit

Permalink
Make stderr redirection compatible with Fish 3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Jan 6, 2019
1 parent 5e484cc commit 9ea93b1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ end

function available -a name -d "Check if a function or program is available."
#-a NAMES assigns the value of successive command-line arguments to the names given in NAMES
type "$name" ^/dev/null >&2
type "$name" 2> /dev/null >&2
end

function _col #Set Color 'name b u' bold, underline
Expand Down Expand Up @@ -172,7 +172,7 @@ function _prompt_git -a current_dir -d 'Display the actual git state'
echo -n -s $flag_fg(_git_branch)(_git_status)(_col_res) #add space if dirty to separate from icons "$dirty"
end
function _git_status -d 'Check git status'
set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2)
set -l git_status (command git status --porcelain 2> /dev/null | cut -c 1-2)
set -l ahead (_git_ahead); echo -n $ahead #show # of commits ahead/behind
if [ (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D") -gt 0 ] #added
echo -n (_col green)$ICON_VCS_STAGED
Expand Down Expand Up @@ -209,7 +209,7 @@ function _git_status -d 'Check git status'
#echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked
end
function _is_git_dirty -d 'Check if branch is dirty'
echo (command git status -s --ignore-submodules=dirty ^/dev/null) #'-s' short format
echo (command git status -s --ignore-submodules=dirty 2> /dev/null) #'-s' short format
end
function _git_branch -d "Display the current git state"
set -l ref
Expand All @@ -231,10 +231,10 @@ function _git_ahead -d 'Print the ahead/behind state for the current bra
_git_ahead_verbose
return
end
command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0 && b > 0) nextfile} END {if (a > 0 && b > 0) print "⇕"; else if (a > 0) print ""; else if (b > 0) print ""}' #↑↓⇕⬍↕
command git rev-list --left-right '@{upstream}...HEAD' 2> /dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0 && b > 0) nextfile} END {if (a > 0 && b > 0) print "⇕"; else if (a > 0) print ""; else if (b > 0) print ""}' #↑↓⇕⬍↕
end
function _git_ahead_verbose -d 'Print a more verbose ahead/behind state for the current branch'
set -l commits (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null)
set -l commits (command git rev-list --left-right '@{upstream}...HEAD' 2> /dev/null)
if [ $status != 0 ]
return
end
Expand Down Expand Up @@ -267,12 +267,12 @@ function _node_version -d "Get the currently used node version if NVM exists"
test $node_version; and echo -n -s (_col brgreen)$ICON_NODE(_col green)$node_version(_col_res)
end

function _ruby_version -d "Get RVM or rbenv version and output" #^&1 stderr2stdout, >&2 vice versa, '>' stdout, '2>' stderr
function _ruby_version -d "Get RVM or rbenv version and output" #2>&1 stderr2stdout, >&2 vice versa, '>' stdout, '2>' stderr
set -l ruby_ver
if which rvm-prompt >/dev/null ^&1
if which rvm-prompt >/dev/null 2>&1
set ruby_ver (rvm-prompt i v g)
else
if which rbenv >/dev/null ^&1
if which rbenv >/dev/null 2>&1
set ruby_ver (rbenv version-name)
end
end
Expand All @@ -298,7 +298,7 @@ end

function _python_version -d "Get python version if pyenv is installed"
set -l python_version
if which pyenv >/dev/null ^&1
if which pyenv >/dev/null 2>&1
set python_version (pyenv version-name)
end
test $python_version; and echo -n -s (_col brblue)$ICON_PYTHON(_col green)$python_version(_col_res)
Expand Down Expand Up @@ -374,12 +374,12 @@ set -g CMD_DURATION 0
#end

#current_gemset alternativ
# else if test (rbenv gemset active >/dev/null ^&1) = "no active gemsets" # not sure what ^&1
# else if test (rbenv gemset active >/dev/null 2>&1) = "no active gemsets" # not sure what 2>&1
# else
# set -l active_gemset (string split -m1 " " (rbenv gemset active))
# echo $active_gemset[1]
#
# set -l active_gemset (rbenv gemset active ^/dev/null)
# set -l active_gemset (rbenv gemset active 2> /dev/null)
# if test -z "$active_gemset"
# else if test $active_gemset = "no active gemsets"
# else
Expand Down

0 comments on commit 9ea93b1

Please sign in to comment.