How do you change fish pwd length in prompt using fish_prompt_pwd_dir_length?

UPD (June 20, 2016):

Since version 2.3.0 (which is now recent) all is working as expected

Previous answer:

My workaround so far is to copy prompt_pwd into new function prompt_pwd_full and mess with it a little bit.

prompt_pwd_full.fish:

set -l args_pre
set args_pre $args_pre -e 's|^/private/|/|'

function prompt_pwd_full -V args_pre
  set -q fish_prompt_pwd_dir_length; or set -l fish_prompt_pwd_dir_length 1

  if [ $fish_prompt_pwd_dir_length -eq 0 ]
    set -l fish_prompt_pwd_dir_length 99999
  end

  set -l realhome ~
  echo $PWD | sed -e "s|^$realhome|~|" $args_pre -e 's-\([^/.]{'"$fish_prompt_pwd_dir_length"'}\)[^/]*/-\1/-g'
end

note: I am on OS X, so I threw out a bunch of code that wasn’t related to it, so it might not work in other OS’es.

UPD: As faho noted in the comment, there is no particular reason to rewrite /private/ to /, so my function is looking like this now:

function prompt_pwd_full
  set -q fish_prompt_pwd_dir_length; or set -l fish_prompt_pwd_dir_length 1

  if [ $fish_prompt_pwd_dir_length -eq 0 ]
    set -l fish_prompt_pwd_dir_length 99999
  end

  set -l realhome ~
  echo $PWD | sed -e "s|^$realhome|~|" -e 's-\([^/.]{'"$fish_prompt_pwd_dir_length"'}\)[^/]*/-\1/-g'
end

Tags:

Shell

Fish