Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish_prompt_pwd_full_dirs variable gets reset to 1 every time a prompt appears #9123

Closed
jakubdabek opened this issue Aug 7, 2022 · 0 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@jakubdabek
Copy link

The behavior is as follows (at current master):

<host> ~/l/k/f/build (master)> set -e fish_prompt_pwd_full_dirs
<host> ~/l/k/f/build (master)> set -S fish_prompt_pwd_full_dirs
<host> ~/l/k/f/build (master)> set -U fish_prompt_pwd_full_dirs 2
<host> ~/l/k/fish-shell/build (master)> set -S fish_prompt_pwd_full_dirs
$fish_prompt_pwd_full_dirs: set in universal scope, unexported, with 1 elements
$fish_prompt_pwd_full_dirs[1]: |1|
<host> ~/l/k/f/build (master)> set -U fish_prompt_pwd_full_dirs 2; set -S fish_prompt_pwd_full_dirs
$fish_prompt_pwd_full_dirs: set in universal scope, unexported, with 1 elements
$fish_prompt_pwd_full_dirs[1]: |2|
<host> ~/l/k/fish-shell/build (master)>
<host> ~/l/k/f/build (master)>

What's going on is that prompt_pwd incorrectly sets the global variable instead of the local one when using flags:

set -ql _flag_d
and set -l fish_prompt_pwd_dir_length $_flag_d
set -q fish_prompt_pwd_dir_length
or set -l fish_prompt_pwd_dir_length 1
set -l fulldirs 0
set -ql _flag_D
and set fish_prompt_pwd_full_dirs $_flag_D
set -q fish_prompt_pwd_full_dirs
or set -l fish_prompt_pwd_full_dirs 1

See lines 15 and 22. The fix would be to set the local instead:

- and set fish_prompt_pwd_full_dirs $_flag_D
+ and set -l fish_prompt_pwd_full_dirs $_flag_D

Sidenote - the variable is changed every time a prompt appears, because prompt_pwd is called in fish_title:

echo -- $ssh (string sub -l 20 -- $argv[1]) (prompt_pwd -d 1 -D 1)

@krobelus krobelus added this to the fish 3.6.0 milestone Aug 7, 2022
@krobelus krobelus added the bug Something that's not working as intended label Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants