Merge pull request #2472 from collierscott/add-gitprompt

Add bash-git-prompt for more informative prompts for git repos
This commit is contained in:
Shao Yu-Lung (Allen) 2020-02-12 09:17:13 +08:00 committed by GitHub
commit 2f2539a51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 0 deletions

View File

@ -2122,6 +2122,25 @@ AST exposes the abstract syntax tree generated by PHP 7+. This extension is requ
<br>
<a name="Install-Bash-Git-Prompt"></a>
## Install Git Bash Prompt
A bash prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
1 - Open the `.env` file
2 - Search for the `WORKSPACE_INSTALL_GIT_PROMPT` argument under the Workspace Container
3 - Set it to `true`
4 - Re-build the container `docker-compose build workspace`
**Note** You can configure bash-git-prompt by editing the `workspace/gitprompt.sh` file and re-building the workspace container.
For configuration information, visit the [bash-git-prompt repository](https://github.com/magicmonty/bash-git-prompt).
<br>
<a name="phpstorm-debugging"></a>
## PHPStorm Debugging Guide

View File

@ -126,6 +126,7 @@ services:
- INSTALL_AST=${WORKSPACE_INSTALL_AST}
- INSTALL_YAML=${WORKSPACE_INSTALL_YAML}
- INSTALL_MAILPARSE=${WORKSPACE_INSTALL_MAILPARSE}
- INSTALL_GIT_PROMPT=${WORKSPACE_INSTALL_GIT_PROMPT}
- PUID=${WORKSPACE_PUID}
- PGID=${WORKSPACE_PGID}
- CHROME_DRIVER_VERSION=${WORKSPACE_CHROME_DRIVER_VERSION}

View File

@ -159,6 +159,7 @@ WORKSPACE_INSTALL_FFMPEG=false
WORKSPACE_INSTALL_GNU_PARALLEL=false
WORKSPACE_INSTALL_AST=true
WORKSPACE_AST_VERSION=1.0.3
WORKSPACE_INSTALL_GIT_PROMPT=false
### PHP_FPM ###############################################

View File

@ -1261,6 +1261,19 @@ RUN if [ ${INSTALL_GNU_PARALLEL} = true ]; then \
apt-get -y install parallel \
;fi
###########################################################################
# Bash Git Prompt
###########################################################################
ARG INSTALL_GIT_PROMPT=false
COPY git-prompt.sh /tmp/git-prompt
RUN if [ ${INSTALL_GIT_PROMPT} = true ]; then \
git clone https://github.com/magicmonty/bash-git-prompt.git /root/.bash-git-prompt --depth=1 && \
cat /tmp/git-prompt >> /root/.bashrc && \
rm /tmp/git-prompt \
;fi
###########################################################################
# Check PHP version:

24
workspace/git-prompt.sh Normal file
View File

@ -0,0 +1,24 @@
# Settings info at https://github.com/magicmonty/bash-git-prompt
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
# Set config variables first
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status
GIT_PROMPT_IGNORE_SUBMODULES=1 # uncomment to avoid searching for changed files in submodules
# GIT_PROMPT_WITH_VIRTUAL_ENV=0 # uncomment to avoid setting virtual environment infos for node/python/conda environments
# GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch
# GIT_PROMPT_SHOW_UNTRACKED_FILES=normal # can be no, normal or all; determines counting of untracked files
# GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=0 # uncomment to avoid printing the number of changed files
# GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10
# GIT_PROMPT_START=... # uncomment for custom prompt start sequence
# GIT_PROMPT_END=... # uncomment for custom prompt end sequence
# as last entry source the gitprompt script
# GIT_PROMPT_THEME=Custom # use custom theme specified in file GIT_PROMPT_THEME_FILE (default ~/.git-prompt-colors.sh)
# GIT_PROMPT_THEME_FILE=~/.git-prompt-colors.sh
# GIT_PROMPT_THEME=Solarized # use theme optimized for solarized color scheme
source $HOME/.bash-git-prompt/gitprompt.sh
fi