Closed christopher-hopper closed 8 years ago
Thanks for this.
At first glance, without testing, this looks very promising and I've already been considering some of the features you've included here. That said, I think it's less useful to lose the boxname in the prompt - this was always very handy for establishing which box you were SSHd into in which terminal window. Also, it's gonna be hard to depart from the wrapping "✝" symbols as these were a handy way of very quickly spotting what's a Vlad box and what's not - they're also kinda "on-brand" as it were.
Either way, there's bound to be things I'm missing here without testing so I'll give it a whirl and get back to you again here :)
Relates to: #338
Aaah, just thought, depending on when you started using Vlad it's possible that you never saw the previous bash prompt before #338 clobbered it. With that in mind, some of my previous comment might not make any sense - apologies if that's the case :)
Once again, thanks for submitting this. I've now briefly tested it. Feedback:
user@host
) - I totally missed that at first glance.vagrant@
) - this is why I originally omitted it. If someone really wants to verify who they're logged in as they're only a whoami
away (just like they'd need to run pwd
to see the full, un-truncated path).git branch
away from finding out what branch I'm on and I typically don't interact with git on the guest anyway).pwdmaxlen
) that controls when it kicks in? I guess this depends on how much space the drush prompt occupies when it kicks in.So, with all that in mind, may I suggest we tweak things so that this (output as of this PR):
[vagrant@nosferatu /var/www/site/docroot (master *=) (drush_prompt)]
$
changes to:
✝ nosferatu ✝ /var/www/site/docroot (drush_prompt)
$
This of course depends on what the drush prompt prints and whether it also has any performance impact to consider. Believe me, if the git prompt didn't knacker the performance as much I'd suggest keeping it but as it stands I just don't think it's a good trade.
BTW, for anyone following along that can't/won't test this PR, here's what my prompt looks like with the PR merged:
@danbohea Love the feedback. I'll make some adjustments and push another one for testing.
@christopher-hopper Good stuff. I look forward to it :)
@danbohea I've pushed some changes to incorporate your feedback.
Path hint
The current prompt uses a character limit of 25 for the path hint. What limit do you think we should increase that to?
User hint
I'd like to keep the user in the prompt as it does provide some value when you switch to a shell as the root user. Try this for an example of how that works and you may be surprised and hopefully delighted:
# Open shell as root
sudo -s
drush hint
The drush prompt hint was introduced a while back. I'd like to say in drush-6.x somewhere but definitely since drush-7.x. The only thing it does for now is tell you which drush site-alias
you're using. To see it in action yourself try switching to a site-alias with drush use
.
# List defined site aliases
drush site-alias
# Use a site-alias that will persist for the current session
drush use @site-alias-name
# Unset the site-alias
drush use @none
drush use
git hint
I've added a new variable bling_shell_prompt_git_upstream
that can be overridden in Vlad settings to turn off git upstream checks in the prompt hint. This improves the performance considerably. The variable can be set to 'true' or 'false' or a valid value defined for GIT_PS1_UPSTREAM
. If accepted I'm happy to document this behaviour in the Vlad documentation.
As well as a relying on the global setting for bling_shell_prompt_git_upstream
, git allows you to override this for individual repositories by using the git config
setting bash.showupstream
.
Valid values for GIT_PS1_UPSTREAM
and bash.showupstream
can be a comma separated string containing one or more of these:
verbose
show number of commits ahead/behind (+/-) upstreamname
if verbose, then also show the upstream abbrev namelegacy
don't use the '--count' option available in recent versions of git-rev-listgit
always compare HEAD to @{upstream}svn
always compare HEAD to your SVN upstreamSee the git-prompt.sh
code for details.
@christopher-hopper You da man. This makes me smile hard:
local APOT='✝'; # apotropaic symbol
Will test ASAP and get back to you. Smells like a merge to me....
Looks good! I have some tweaks but I'm happy to merge first - tweak later. The main issue is that I believe we should disable the git hint by default - the "out of the box" experience is important and this does effect that.
Thanks for the contributions of late, they all been very thorough and very much appreciated :)
This is now merged and I have since added some very minor tweaks:
force
if needed for simpler prompt updates/development.It would appear that bling_shell_prompt_git_upstream
is not having the desired effect (at least not when it still defaults to false
). Would you mind taking a look at this when you get time?
Over to you on the docs update as suggested, please make sure you use the dev branch of the docs.
bling_shell_prompt_git_upstream
won't turn off the git hint altogether. It just stops it from doing the expensive job or comparing the local changes to the upstream remote and showing you whether it matches, is ahead, behind, etc.
I'll look at adding full control over both the git and drush promt hints and push that as another new PR for you. Also happy to add documentation.
Aaaaah, with you now. All good :)
For your consideration: improved bash prompt "bling" that is consistent, useful and colourful.
These changes configure and enable drush and git hints in the bash prompt and terminal title bar that work with all currently supported drush and git versions. They can be disabled using the existing Vlad variable
bling_shell_prompt
.So far tested with:
Yet to be tested: