Skip to content
This repository has been archived by the owner on Dec 12, 2019. It is now read-only.

Default bash prompt should be performant and configurable #347

Open
christopher-hopper opened this issue Mar 7, 2016 · 4 comments
Open

Comments

@christopher-hopper
Copy link
Contributor

Problem

The default Vlad bash prompt includes Git and drush hints that are is having a noticeable performance impact for some users.

Steps to Reproduce

  1. Checkout the Vlad dev branch at or after commit b7e0c22 (See Improved bash prompt hints #346).

  2. Configure Vlad by following the installation and getting started steps.

  3. Ensure the Vlad host_synced_folder points to a folder containing a

    • git repository with a commit history and remote.
    • Drupal install with a drush site-alias definition (ie. sites/all/drush/aliases.drushrc.php)
  4. Run vagrant up to provision the box.

  5. Open a secure shell prompt on the newly provisioned box using vagrant ssh.

  6. Run drush status

  7. Get a list of available drush site-alias names using drush sa

  8. Set the drush site-alias using drush use @alias where @alias is a name listed in the previous step

  9. Create a new file in the Drupal install path and commit it like this:

    mkdir --parents sites/all/test
    touch sites/all/test/README.txt
    git add sites/all/test/README.txt
    git commit -m "Test commit"
  10. Change to the newly created folder using cd sites/all/test.

Expected Result

  1. The drush site-alias that is set by drush use or similar is shown in the prompt
  2. The git branch name will be shown in the bash prompt when in a git repository
  3. There is no noticeable delay when changing folders with cd

Actual Result

  1. The drush site-alias is shown in the prompt as expected.
  2. The git branch name is shown with an extra symbol after it to indicate whether the current local git branch has diverged from the upstream git remote tracking branch (ie. git log branch...origin/branch):
    • = when the local matches the remote
    • > when the local is ahead of the remote
    • < when the local is behind the remote
    • <> when the local has diverged from the remote
  3. When changing folder using cd or running other commands there is a noticeable delay on slower computers as git calculates the difference between the local and remote branch.

Suggested Solution

  1. Turn-off git checks against the upstream remote for the default bash prompt that comes with Vlad.
  2. Add new default variables for the ansible role playbook bling that provides users with the ability to turn on or off hints altogether for
    • git
    • drush
  3. Add new default variables for the ansible role playbook bling that provide values for the git prompt settings currently available

I would like to see these available in yaml using a simple, easy to read format like this:

bling_shell_prompt_hints:
  - name: git
    show:
    - upstream: false
    - dirtystate: false
    - stashstate: false
    - untrackedfiles: false
  - name: drush

Open to suggestions on this as it has to be a data structure that is easy to work with in ansible.

@christopher-hopper
Copy link
Contributor Author

This issue has been created to continue the conversation and improve up the solution in #346

@christopher-hopper
Copy link
Contributor Author

I've begun work on implementing the suggested solution above but any feedback on the approach I'm suggesting would be appreciated.

@dixhuit
Copy link
Contributor

dixhuit commented Mar 7, 2016

Rushing around a bit here but after a quick read through your approach sounds great. Feel free to submit a PR whenever you're ready. Thanks!

@christopher-hopper
Copy link
Contributor Author

I've been testing this on both Ubuntu and Centos.

I've found the following need to be set in the shell profile to get the best performance.

export GIT_PS1_SHOWUNTRACKEDFILES=
export GIT_PS1_SHOWDIRTYSTATE=
export GIT_PS1_SHOWUPSTREAM=

This turn's off checks done by git, in a git repository folder tree, for

  • Untracked Files
  • Local changes
  • Upstream changes (remote)

I've also found that a few packages are missing in the default Centos build that enable effective development. I've had to do a yum install after build to add:

  • man
  • man-pages
  • bash-doc
  • bash-completion

Also missing is a ~/.profile file. I'll raise these as another issue perhaps, if I can find where the base package installs should happen.

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

No branches or pull requests

2 participants