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

cwd: Fix home indicator when HOME contains a symlink #504

Closed
wants to merge 1 commit into from

Conversation

kc9jud
Copy link
Contributor

@kc9jud kc9jud commented Sep 23, 2020

Fixes #415.

@domfi
Copy link

domfi commented Mar 9, 2023

Maybe you just could use os.path.abspath() instead of os.path.realpath(). This changes only a few chars in the code.

--- cwd.py.orig 2023-03-09 11:50:20.450706673 +0100
+++ cwd.py      2023-03-09 11:45:32.158572853 +0100
@@ -6,7 +6,7 @@


 def replace_home_dir(cwd):
-    home = os.path.realpath(os.getenv('HOME'))
+    home = os.path.abspath(os.getenv('HOME'))
     if cwd.startswith(home):
         return '~' + cwd[len(home):]
     return cwd

@kc9jud
Copy link
Contributor Author

kc9jud commented Oct 26, 2023

@domfi os.path.abspath() does not resolve/normalize symlinks, but os.path.realpath() does.

@kc9jud
Copy link
Contributor Author

kc9jud commented Oct 26, 2023

Superseded by #551.

@kc9jud kc9jud closed this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

when cwd is home, tilde doesn't show up if home is linked
2 participants