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

move common prompt to external function #1016

Merged
merged 1 commit into from Apr 13, 2017
Merged

move common prompt to external function #1016

merged 1 commit into from Apr 13, 2017

Conversation

Eriner
Copy link
Contributor

@Eriner Eriner commented Nov 2, 2015

No description provided.


if [[ "$pwd" == (#m)[/~] ]]; then
# because this function is sourced from other scripts, the vars must be exported
export _prompt_"${prompt}"_pwd="$MATCH"
Copy link
Owner

Choose a reason for hiding this comment

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

Why are you exporting it?

@Eriner
Copy link
Contributor Author

Eriner commented Nov 2, 2015

I believe the comment is self-explanatory. To go into more detail, if it isn't exported, the variable isn't available to the calling function ex: prompt_damoekri_setup.

An alternative way of handling it would be to create local dir and assign what is currently being exported to that, then at the end of the function, echo ${dir}. Inside the prompt setups, they could just assign the output of that to a variable and use that instead.

If you know of a better way to handle it, please let me know and I will commit a change.

@Eriner
Copy link
Contributor Author

Eriner commented Nov 2, 2015

This would close issue #701

@Eriner Eriner closed this Nov 15, 2015
@sorin-ionescu sorin-ionescu reopened this Nov 15, 2015
@amerlyq
Copy link

amerlyq commented Dec 22, 2015

Hm, I have slightly different approach to this problem as whole -- I have splitted all prompt into keyparts to make it modular. See at prompt and prompt.d. Not ideal, of course, but allows much more control.

@sorin-ionescu
Copy link
Owner

Your prompts will share styling. In this case, it's just one function, no styling.

@@ -0,0 +1,15 @@
#
# prompt setup function common to many prompts
# moved to external function to ruduce code rudundancy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: should be "reduce"

@belak belak changed the base branch from master to belak/tmp-branch April 13, 2017 08:08
@belak
Copy link
Collaborator

belak commented Apr 13, 2017

I'm merging this into a temp branch so I can make a tweak and cherry-pick it to master. I guess weird things happen when a repo is deleted while there are still PRs open.

@belak belak merged commit 909b8cb into sorin-ionescu:belak/tmp-branch Apr 13, 2017
@belak
Copy link
Collaborator

belak commented Apr 13, 2017

This has been merged into master along with some spelling fixes and a fix to ensure extendedglob is set for this function. Thanks for your contribution!

@sorin-ionescu
Copy link
Owner

Be careful with those functions. They are not always completely identical. I was trying to think of a naming scheme since promptpwd is not descriptive enough.

@belak
Copy link
Collaborator

belak commented Apr 16, 2017

Maybe shortpwd or something similar?

@sorin-ionescu
Copy link
Owner

It's still doesn't say how short it is and what's included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants