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

lib: provide a prompt function for the dirstack #376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jjmcdn
Copy link
Contributor

@jjmcdn jjmcdn commented Dec 6, 2022

Providing this additional function for prompts allows anyone using pushd/popd/dirs to navigate directory trees to quickly view their stack and find which entry they want to switch to.

This degrades gracefully for anyone not using the directory stack since dirs will always display the same as \w when the stack is only one entry deep.

The bakke theme has been tweaked to use the new function as an example.

Signed-off-by: Joe MacDonald [email protected]

For what it looks like when it use, I'm adding a screenshot here.

2022-12-06-123744_3840x1080_scrot

@jjmcdn jjmcdn marked this pull request as ready for review December 6, 2022 17:51
@akinomyoga
Copy link
Contributor

I have a question. Is it different from directly putting $(dirs) in PS1?

@jjmcdn
Copy link
Contributor Author

jjmcdn commented Dec 6, 2022

I have a question. Is it different from directly putting $(dirs) in PS1?

As currently implemented, no, it's the same thing. I had thought that if this change was okay that there could be a use for having this in a function, such as optionally using the -l option to dirs based on an environment variable (I don't like that behaviour but I can see why others would) or limiting the number of stack entries displayed so it could be used in single-line prompts.

@akinomyoga
Copy link
Contributor

OK. Thank you for the clarification! I think I will keep this PR open as an "example configuration".

@jjmcdn jjmcdn force-pushed the jjm/master/dirs_prompt branch from f207b7c to 38376d5 Compare December 12, 2022 15:42
@jjmcdn
Copy link
Contributor Author

jjmcdn commented Dec 12, 2022

OK. Thank you for the clarification! I think I will keep this PR open as an "example configuration".

Okay, sorry about the delayed follow up on this. I added the full feature as I'd intended it, with the optional -l expansion and limiting the number of dirstack entries from an environment variable. It's only slightly more complex than the simple dirs one I'd initially proposed, so it's probably still useful as an example for others.

Thanks!

Providing this additional function for prompts allows anyone using
pushd/popd/dirs to navigate directory trees to quickly view their
stack and find which entry they want to switch to.

This degrades gracefully for anyone not using the directory stack since
dirs will always display the same as \w when the stack is only one entry
deep.

Setting DIRSTACK_EXPAND_TILDE to true in the environment will display
the directory stack with ~ expanded to the full path of the user's home
directory.

Setting DIRSTACK_LIMIT to any value greater than 0 will limit the
display to that number of entries, though the directory stack will still
contain all entries in it.

The bakke theme has been tweaked to use the new function as an example.

Signed-off-by: Joe MacDonald <[email protected]>
@jjmcdn jjmcdn force-pushed the jjm/master/dirs_prompt branch from 38376d5 to 944e440 Compare January 13, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants