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
117 lines
2.9 KiB
Bash
Executable File
117 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Initialize Bash It
|
|
|
|
# Reload Library
|
|
case $OSTYPE in
|
|
darwin*)
|
|
alias reload='source ~/.bash_profile'
|
|
;;
|
|
*)
|
|
alias reload='source ~/.bashrc'
|
|
;;
|
|
esac
|
|
|
|
# Only set $BASH_IT if it's not already set
|
|
if [ -z "$BASH_IT" ];
|
|
then
|
|
# Setting $BASH to maintain backwards compatibility
|
|
# TODO: warn users that they should upgrade their .bash_profile
|
|
export BASH_IT=$BASH
|
|
export BASH="$(bash -c 'echo $BASH')"
|
|
fi
|
|
|
|
# For backwards compatibility, look in old BASH_THEME location
|
|
if [ -z "$BASH_IT_THEME" ];
|
|
then
|
|
# TODO: warn users that they should upgrade their .bash_profile
|
|
export BASH_IT_THEME="$BASH_THEME";
|
|
unset $BASH_THEME;
|
|
fi
|
|
|
|
# Load composure first, so we support function metadata
|
|
# shellcheck source=./lib/composure.bash
|
|
source "${BASH_IT}/lib/composure.bash"
|
|
|
|
# support 'plumbing' metadata
|
|
cite _about _param _example _group _author _version
|
|
|
|
# libraries, but skip appearance (themes) for now
|
|
LIB="${BASH_IT}/lib/*.bash"
|
|
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
|
|
for config_file in $LIB
|
|
do
|
|
if [ $config_file != $APPEARANCE_LIB ]; then
|
|
# shellcheck disable=SC1090
|
|
source $config_file
|
|
fi
|
|
done
|
|
|
|
# Load the global "enabled" directory
|
|
_load_global_bash_it_files
|
|
|
|
# Load enabled aliases, completion, plugins
|
|
for file_type in "aliases" "plugins" "completion"
|
|
do
|
|
_load_bash_it_files $file_type
|
|
done
|
|
|
|
# Load colors and helpers first so they can be used in base theme
|
|
# shellcheck source=./themes/colors.theme.bash
|
|
source "${BASH_IT}/themes/colors.theme.bash"
|
|
# shellcheck source=./themes/githelpers.theme.bash
|
|
source "${BASH_IT}/themes/githelpers.theme.bash"
|
|
# shellcheck source=./themes/p4helpers.theme.bash
|
|
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
|
# shellcheck source=./themes/base.theme.bash
|
|
source "${BASH_IT}/themes/base.theme.bash"
|
|
|
|
# appearance (themes) now, after all dependencies
|
|
# shellcheck source=./lib/appearance.bash
|
|
source $APPEARANCE_LIB
|
|
|
|
# Load custom aliases, completion, plugins
|
|
for file_type in "aliases" "completion" "plugins"
|
|
do
|
|
if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]
|
|
then
|
|
# shellcheck disable=SC1090
|
|
source "${BASH_IT}/${file_type}/custom.${file_type}.bash"
|
|
fi
|
|
done
|
|
|
|
# Custom
|
|
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
|
|
for config_file in $CUSTOM
|
|
do
|
|
if [ -e "${config_file}" ]; then
|
|
# shellcheck disable=SC1090
|
|
source $config_file
|
|
fi
|
|
done
|
|
|
|
unset config_file
|
|
if [[ $PROMPT ]]; then
|
|
export PS1="\[""$PROMPT""\]"
|
|
fi
|
|
|
|
# Adding Support for other OSes
|
|
PREVIEW="less"
|
|
|
|
if [ -s /usr/bin/gloobus-preview ]; then
|
|
PREVIEW="gloobus-preview"
|
|
elif [ -s /Applications/Preview.app ]; then
|
|
# shellcheck disable=SC2034
|
|
PREVIEW="/Applications/Preview.app"
|
|
fi
|
|
|
|
# Load all the Jekyll stuff
|
|
|
|
if [ -e "$HOME/.jekyllconfig" ]
|
|
then
|
|
# shellcheck disable=SC1090
|
|
. "$HOME/.jekyllconfig"
|
|
fi
|
|
|
|
# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040
|
|
set +T
|