Bug 327720 - Konsole should remember it was following symlinks on session restore, new tab
Summary: Konsole should remember it was following symlinks on session restore, new tab
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.11.2
Platform: Kubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-17 14:05 UTC by Chintalagiri Shashank
Modified: 2018-05-22 09:14 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chintalagiri Shashank 2013-11-17 14:05:40 UTC
When following symlinks, Konsole follows the symlink as expected (listing the link instead of the target in pwd / terminal prompt) within the original tab. However, opening a new tab or during KDE session restore post Logout/Login or restart, it 'forgets' that it was following a symlink and expands to symlink to the target path in pwd and the terminal prompt.

chintal@longclaw:~$ ls -l code
lrwxrwxrwx 1 chintal chintal 18 Nov 17 13:29 code -> /media/ldata/code/

chintal@longclaw:~$ cd code
chintal@longclaw:~/code$ pwd
/home/chintal/code

New tab created now, I expect it to remain in /home/chintal/code.

chintal@longclaw:/media/ldata/code$ pwd
/media/ldata/code




Reproducible: Always

Steps to Reproduce:
1. Create a symlink to a folder somewhere
2. cd to the symlink, navigate inside the target folder if you like, or just stay at the symlink itself
3. Run pwd and look at terminal prompt to confirm it's working fine
4a. Create a new tab by double clicking on the empty space in the tab bar
4b. Instead of 4a, you could also at this point logout and login or reboot, for KDE session restore to invoke.
5. Look at prompt in the new konsole. Run pwd to confirm.
Actual Results:  
pwd changes to reflect target instead of symlink

Expected Results:  
pwd (or konsoles new tab creation code) should remember that it was following a symlink, and continue to do what it was doing originally, ie, in the first tab. Leaving it as it is makes for a rather inconsistent experience.

Bug 242114 seems to be related.
Comment 1 Ahmad Samir 2018-05-22 08:54:13 UTC
This has been fixed in konsole > 2.12.4[1]; you may use OSC 7 (OSC is ESC] or \033] or \e]) escape sequences to let the shell tell konsole about the $PWD.

Something like this should work:
- Get your current/default PROMPT_COMMAND:
$ echo $PROMPT_COMMAND
on my system it looks like this:
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"

- Then append the the OSC 7 escape sequence to it:
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"; printf "\033]7;file://%s\007" "${PWD}"'

You may then put that that line in e.g. ~/.bashrc and PWD will be set to the current working directory even if it's a symlink.

[1] https://bugs.kde.org/show_bug.cgi?id=336618
Comment 2 Ahmad Samir 2018-05-22 09:14:22 UTC
To clarify, in the printf command one can only use \033] or \e] .