I want fish shell to show full path in prompt. Looking at source of pwd_prompt I see a variable named fish_prompt_pwd_dir_length, that should do what I want if I set it to 0.
But when I do set -U fish_prompt_pwd_dir_length 0 nothing happens.
Looking in fish_config variables tab I see that this var is set to 0, but still path shown reduced.
What am I doing wrong and can you actually do that without writing your own pwd_prompt function?
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
Adding set -g fish_prompt_pwd_dir_length 80 to ~/.config/fish/config.fish works for me. My fish version is 3.0.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With