This patch adds very simple support for the Perforce SCM:
https://www.perforce.com/
Although perforce is proprietary software, it's somewhat prevalent in enterprise
companies. This patch looks to provide some basic bash_it functionality that
I've come to love for git. I base everything off of two perforce commands:
$ p4 set
This command does not require a connection the perforce server, it simply tells
us if a directory is managed by the Perforce SCM or not. In addition the
command:
$ p4 opened
is used to provide the list of pending changes in the client and the number of
opened files in the client. The `p4 opened` command requires a connection to the
perforce server, hence it's run under a `timeout` command. The "p4 opened"
processing into it's own bash file that now has to be sourced at the top-level
bash-it.sh. Since the processing in simple the newly added: _p4-opened-counts
function returns a number of things that are not currently used, but since I had
awk open and doing the processing, I've chosen to include them in the output
anyway.
Testing:
- Tested with the powerline-multiline theme in a few perforce based
workspaces/clients
- Ran:
❯ shellcheck themes/p4helpers.theme.bash
and fixed all the errors
- Ran the test suite:
❯ test/run
[...]
182 tests, 0 failures, 1 skipped
`tr 'A-Z' 'a-z'` will only convert non-accented characters. Switching to
`[:upper:]` and `[:lower:]` adds support for accents.
See https://github.com/koalaman/shellcheck/wiki/SC2018
Additionally, printf's character splitting does not support accented
characters, so output isn't as expected. Using bash's variable expansion
syntax instead will correctly get the full accented character.
Invoking the scm_char and scm_prompt_info functions separately for PS1
duplicates calls to the scm and scm_prompt_char functions to check what
${SCM}, if any, we currently reside in. This problem was exacerbated
when working outside of any repo as we had to go through all the
conditionals just to determine we're not in any scm repo. Unnecessary
conditionals slows down the prompt so this adds a new function that
streamlines printing out both the scm char and scm prompt info with one
invocation.
Add new variable to enable/disable git prompt minimal status information
and consolidate functions for code re-use. Also update README
documentation to capture the usage of new variable.
- Added more information to the README about the practice of using `git
pair`, and provided instructions on installing the support.
- Write a more reliable fallback that uses `user.name` to extract user
initials, when `user.initials` aren't set.
Running `rvm tools identifier` seems to be really slow. Using [`rvm-prompt`](https://rvm.io/workflow/prompt) greatly speeds up the evaluation of `$PROMPT_COMMAND`.
- Git prompt now indicates when remote tracked branch is "gone"
- New env var (SCM_GIT_DETACHED) that indicates when HEAD is detached
- New env vars available for themes (SCM_THEME_BRANCH_TRACK_PREFIX,
SCM_THEME_BRANCH_GONE_PREFIX, SCM_GIT_DETACHED_CHAR)
- Refactor of git_prompt_vars function from base theme
The current check of `git symbolic-ref HEAD` does not detect git
repositories in the 'detached HEAD' state. This is the state a
repository is in if HEAD is not pointing to a valid branch or tag (e.g.
you are in a recently-initiated submodule).
Improved prompt display speed when git is not installed by
preventing bash from walking the path before each prompt.
Removed pesky stash-related git error message when in bare repos.
* chruby.bash loads chruby
* chruby-auto.bash loads chruby and enables auto-switching
* add chruby_version_prompt() function for displaying ruby version
* inspired by https://gist.github.com/rssvihla/6153455
* `(git|svn|hg)_promp_vars` only assign values to the variables but do not `echo`
* `(git|svn|hg)_promp_info` still `echo`s, but now calls `*_prompt_info` first
* Introduce `SCM_CHANGE` to store the changeset id
* Introduce `SCM_BRANCH` to store the branch name