Skip to content

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

Closed
kc9jud wants to merge 1 commit into
b-ryan:masterfrom
kc9jud:master
Closed

cwd: Fix home indicator when HOME contains a symlink#504
kc9jud wants to merge 1 commit into
b-ryan:masterfrom
kc9jud:master

Conversation

@kc9jud

@kc9jud kc9jud commented Sep 23, 2020

Copy link
Copy Markdown
Contributor

Fixes #415.

@ghost

ghost commented Mar 9, 2023

Copy link
Copy Markdown

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

kc9jud commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

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

@kc9jud

kc9jud commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

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

1 participant