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

Get link destinations via realpath instead of pwd #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

klane
Copy link

@klane klane commented Oct 2, 2019

Using pwd after moving into the link returns the path to the link, not its destination. This PR uses readlink to get the link destination without having to cd into it.

Fixes: #10

set -l output ""
for mark_name in $mark_list
cd $MARKPATH/$mark_name
set -l real_path (pwd)
set -l real_path (readlink $MARKPATH/$mark_name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how portable readlink is. fish has a built-in realpath function to accomplish the same thing: https://fishshell.com/docs/current/commands.html#realpath

Copy link
Author

@klane klane Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I changed the function to use realpath.

@klane klane changed the title Get link destinations via readlink instead of pwd Get link destinations via realpath instead of pwd Oct 25, 2019
@OPeyrusse
Copy link

Any chance to see this PR merge?
Because of the cd call, it triggers direnv [1] when entering the directory. As a consequence, it prints tens of lines when calling marks, because direnv is setting various tools and immediately un-setting them.

From what I see, the change is good.

[1] https://direnv.net/

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.

marks command doesn't print the link destination correctly
3 participants