oh-my-bash
oh-my-bash copied to clipboard
lib: provide a prompt function for the dirstack
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.
I have a question. Is it different from directly putting $(dirs)
in PS1
?
I have a question. Is it different from directly putting
$(dirs)
inPS1
?
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.
OK. Thank you for the clarification! I think I will keep this PR open as an "example configuration".
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!