externl/fish-symnav

cd into symlink

Closed this issue · 8 comments

When I step into a symlink

~/Apps -> /mnt/data/Apps
cd Apps

It shows me the prompt as
/mnt/data/Apps ~>

Furthermore, when I do cd .., it goes back to
/mnt/data ~>

What are the setting required so that cd Apps shows me ~/Apps ~>
and cd .. will take me back to ~

Hi @SanjayVyas

What is the output of the following commands:

  • fish -v
  • echo $symnav_initialized
  • echo $symnav_pwd
  • bind | grep __symnav
  • functions cd
  • functions fish_prompt

EDIT: If symnav is installed and working correctly what you you want to do is the default behavior.

fish, version 2.4.0

1

bind \t __symnav_complete
bind \n __symnav_execute
bind \r __symnav_execute

test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(hostname)' '
test $USER = 'root'; and echo (set_color red)"#"
echo -n (set_color cyan)(prompt_pwd) (set_color f4c430)'><'(set_color white)'(('(set_color green)'°> '
end

Can you update the formatting to use ``` your code ```, I can't tell what's what.

Can you also show me the output of:

  • functions cd
  • functions prompt_pwd
  • echo $symnav_pwd

Edit: I only tested fish 2.6.0, I wonder if this could be an issue with your version.

Got this after first cd upgrading to fish 2.6.0

functions: Function “copy-__symnav_shadow_cd” does not exist
~/.config/fish/functions/__symnav_initialize.fish (line 34): 
        functions --copy $func $function_name
        ^
in function “__symnav_initialize”
	called on line 7 of file ~/.config/fish/functions/__symnav_execute.fish

in function “__symnav_execute”
	called on standard input

functions cd is not defined

functions prompt_pwd

# Defined in - @ line 2
function prompt_pwd --description 'Print the current working directory, shortened to fit the prompt'
	set -q argv[1]
    and switch $argv[1]
        case -h --help
            __fish_print_help prompt_pwd
            return 0
    end

    # This allows overriding fish_prompt_pwd_dir_length from the outside (global or universal) without leaking it
    set -q fish_prompt_pwd_dir_length
    or set -l fish_prompt_pwd_dir_length 1

    # Replace $HOME with "~"
    set realhome ~
    set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $symnav_pwd)

    if [ $fish_prompt_pwd_dir_length -eq 0 ]
        echo $tmp
    else
        # Shorten to at most $fish_prompt_pwd_dir_length characters per directory
        string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
    end
end

after cd to a symlink

echo $symnav_pwd 
/mnt/hayagriva/Apps

Got it working finally...
Installed fish 2.6.0 and then reinstalled symnav.

Thanks.

One question.. when I do cd .. from symlink, it substitutes the symlink parent directory name. Is there a way to silently go back to it rather than substitution?

Currently no, substitution is always performed on all commandline tokens.

It's possible to add for the cd since we install a shim for the builtin one. It would be impossible to not have substitution for a command like:

../../foo --arg ../../bar

Suggestions about how all of this should/could be handled are welcome.

Note: You can execute the completion automatically by setting set symnav_execute_substitution 1

Closing this issue.