3

So I'm trying to change my fish shell terminal prompt but every time I change anything too complicated (beyond colour changes and rearranging the prompt), it just turns up blank.

I'm running Arch Linux.

I've tried lots of terminal emulators. termite, kitty, konsole, simple terminal, rxvt-u, terminology. None of the normal terminal emulators would show the prompt I'm expecting.

But there was one that worked, the terminal emulator inside visual studio code.

I've tried as many random different prompts I could get my hand on but all of them would just look blank everywhere except visual studio code.

Any idea how I can get the terminal prompt to look the way it should?

in short, it looks like this

enter image description here

When it should look like this

enter image description here

Heres the content of ~/.config/fish/functions/fish_prompt.fish

# name: sashimi
function fish_prompt
  set -l last_status $status
  set -l cyan (set_color -o cyan)
  set -l yellow (set_color -o yellow)
  set -g red (set_color -o red)
  set -g blue (set_color -o blue)
  set -l green (set_color -o green)
  set -g normal (set_color normal)

  set -l ahead (_git_ahead)
  set -g whitespace ' '

  if test $last_status = 0
    set initial_indicator "$green◆"
    set status_indicator "$normal❯$cyan❯$green❯"
  else
    set initial_indicator "$red✖ $last_status"
    set status_indicator "$red❯$red❯$red❯"
  end
  set -l cwd $cyan(basename (prompt_pwd))

  if [ (_git_branch_name) ]

    if test (_git_branch_name) = 'master'
      set -l git_branch (_git_branch_name)
      set git_info "$normal git:($red$git_branch$normal)"
    else
      set -l git_branch (_git_branch_name)
      set git_info "$normal git:($blue$git_branch$normal)"
    end

    if [ (_is_git_dirty) ]
      set -l dirty "$yellow ✗"
      set git_info "$git_info$dirty"
    end
  end

  # Notify if a command took more than 5 minutes
  if [ "$CMD_DURATION" -gt 300000 ]
    echo The last command took (math "$CMD_DURATION/1000") seconds.
  end

  echo -n -s $initial_indicator $whitespace $cwd $git_info $whitespace $ahead $status_indicator $whitespace
end

function _git_ahead
  set -l commits (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null)
  if [ $status != 0 ]
    return
  end
  set -l behind (count (for arg in $commits; echo $arg; end | grep '^<'))
  set -l ahead  (count (for arg in $commits; echo $arg; end | grep -v '^<'))
  switch "$ahead $behind"
    case ''     # no upstream
    case '0 0'  # equal to upstream
      return
    case '* 0'  # ahead of upstream
      echo "$blue↑$normal_c$ahead$whitespace"
    case '0 *'  # behind upstream
      echo "$red↓$normal_c$behind$whitespace"
    case '*'    # diverged from upstream
      echo "$blue↑$normal$ahead $red↓$normal_c$behind$whitespace"
  end
end

function _git_branch_name
  echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end

function _is_git_dirty
  echo (command git status -s --ignore-submodules=dirty ^/dev/null)
end

0

1 Answer 1

4

This is a bug in fish triggered by using non-ASCII chars with a non-unicode capable locale.

Set your locale to something that can handle UTF-8 (i.e. not the default "C")

2
  • You're right. locale says I'm running C. But it seems I'm having some trouble changing it. I made sure to have LANG=en_US.UTF-8 in my /etc/locale.conf and tried localectl set-locale LANG=en_US.UTF-8 but I can't seem to change the locale the terminal is using. Am I doing something wrong? how do I go about changing the terminals locale? Apr 24, 2020 at 22:41
  • nevermind, I managed to set the environment variable in ~/.config/fish/config.fish. Thank you! Apr 24, 2020 at 22:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .