From 1bbe78bb1887f4345e548e2a6cebea47bbf03c90 Mon Sep 17 00:00:00 2001 From: Alex Kornitzer Date: Thu, 17 Nov 2016 21:07:53 +0000 Subject: [PATCH 1/5] Moved tmux-gitbar.conf out of the repo The new default location for the conf file is ~. This can be changed using an envar if required. The README has also been updated to relfect the changes. --- .gitignore | 1 - README.md | 26 ++++++++++++++++++-------- lib/tmux-gitbar.sh | 6 +++++- tmux-gitbar.tmux | 19 +++++++++++-------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 88eef8f..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -tmux-gitbar.conf diff --git a/README.md b/README.md index d1337d7..5b848d1 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Show **Local** and **Remote** Git branches information: issue, or even better, a pull-request, in case you discover any kind of incompatibility with a tmux plugin you are using. -**Customizable** +**Customizable** You can customize the content and the style of the Git status bar, this is all done in `tmux-gitbar.conf`, this file is auto-generated at first launch, in the installation directory. @@ -54,7 +54,7 @@ installation directory. * [Status bar location](#status-bar-location) * [Status bar color](#status-bar-color) * [Symbols](#symbols) -* [Troubleshooting](#troubleshooting) +* [Troubleshooting](#troubleshooting) * [Credits](#credits) * [License](#license) * [Changelog](#changelog) @@ -93,7 +93,7 @@ Let's say you prefer to install **tmux-gitbar** in git clone https://github.com/aurelien-rainone/tmux-gitbar.git /path/to/tmux-gitbar ``` -**Add those 2 lines to your `tmux.conf`** +**Add these 2 lines to your `tmux.conf`** ```bash TMUX_GITBAR_DIR="/path/to/tmux-gitbar" @@ -101,10 +101,20 @@ source-file "/path/to/tmux-gitbar/tmux-gitbar.tmux" ``` **Important:** `TMUX_GITBAR_DIR` environment variable **must be set** before -sourcing `tmux-gitbar.tmux`. +sourcing `tmux-gitbar.tmux`. **Note:** Do not include the trailing slash. +## Modifying tmux-gitbar.conf location + +If you prefer to store the **.tmux-gitbar.conf** somewhere other than `~/`. + +**Add this line to your `tmux.conf`** + +```bash +TMUX_GITBAR_CONF="/path/to/.tmux-gitbar.conf" +``` + ## Font The default tmux-gitbar configuration does not require you to install any @@ -149,7 +159,7 @@ the default `BRANCH_SYMBOL has been replaced. # Documentation -Customizing the location and appearance of tmux-gitbar is realized in +Customizing the location and appearance of tmux-gitbar is realized in `tmux-gitbar.conf`, this file is auto-generated at first launch if it doesn't exist already. @@ -203,7 +213,7 @@ Shows the `⭠` symbol followed by the local branch name. |`…n`|there are n untracked files| |`⚑n`|there are n stash entries| -Flags with number being 0 are not shown. +Flags with number being 0 are not shown. The working tree is considered *clean* if all flags are 0, in this case a `✔` is shown. @@ -228,7 +238,7 @@ tmux-gitbar background color. Default is black. ## Symbols You can replace the default symbols with others. Symbols defined in -`tmux-gitbar.conf` take precedence over the default ones. +`tmux-gitbar.conf` take precedence over the default ones. For example, if you want to use the `x` to represent conflicts, instead of the default '✖' (unicode 0x2716), simply add to your `tmux-gitbar.conf`: @@ -282,7 +292,7 @@ Other credits for : - Fix issue 10: some symbols do not render with the stock font ### v1.3.0, 2016-04-02 -- `tmux-gitbar.conf` is not version controlled any more, and generated at first +- `tmux-gitbar.conf` is not version controlled any more, and generated at first launch, allowing to update tmux-gitbar without overwriting user-customized configuration. diff --git a/lib/tmux-gitbar.sh b/lib/tmux-gitbar.sh index ce7c8b2..e13c6ca 100644 --- a/lib/tmux-gitbar.sh +++ b/lib/tmux-gitbar.sh @@ -44,9 +44,13 @@ RESET_FMT="#[fg=default]" TMGB_OUTREPO_STATUS="" TMGB_OUTREPO_STYLE="" +if [ -z ${TMUX_GITBAR_CONF} ]; then + TMUX_GITBAR_CONF=${HOME}/.tmux-gitbar.conf +fi + # Load the config file load_config() { - source "${SCRIPT_DIR}/../tmux-gitbar.conf" + source "${TMUX_GITBAR_CONF}" } # Save status bar settings so that we can reset it later diff --git a/tmux-gitbar.tmux b/tmux-gitbar.tmux index 005e6c8..2c5786a 100644 --- a/tmux-gitbar.tmux +++ b/tmux-gitbar.tmux @@ -3,15 +3,18 @@ # Created by Aurélien Rainone # github.com/aurelien-rainone/tmux-gitbar -# generate tmux-gitbar.conf if it doesn't exist +# ensure TMUX_GITBAR_DIR is defined if-shell 'test -z ${TMUX_GITBAR_DIR}' \ - "if-shell '! stat ~/.tmux-gitbar/tmux-gitbar.conf' \ - 'run-shell \"~/.tmux-gitbar/lib/generate-config.sh ~/.tmux-gitbar/tmux-gitbar.conf\"'" \ - "if-shell '! stat $TMUX_GITBAR_DIR/tmux-gitbar.conf' \ - 'run-shell \"$TMUX_GITBAR_DIR/lib/generate-config.sh $TMUX_GITBAR_DIR/tmux-gitbar.conf\"'" + 'TMUX_GITBAR_DIR="$HOME/.tmux-gitbar"' + +# ensure TMUX_GITBAR_CONF is defined +if-shell 'test -z ${TMUX_GITBAR_CONF}' \ + 'TMUX_GITBAR_CONF="$HOME/.tmux-gitbar.conf"' + +# generate configuration file if it doesn't exist +if-shell '! stat ${TMUX_GITBAR_CONF}' \ + 'run-shell "$TMUX_GITBAR_DIR/lib/generate-config.sh $TMUX_GITBAR_CONF"' # install update-gitbar as a prompt command if not done already if-shell 'echo $PROMPT_COMMAND | grep -qv update-gitbar' \ - "if-shell 'test -z \"${TMUX_GITBAR_DIR}\"' \ - 'PROMPT_COMMAND=\"~/.tmux-gitbar/update-gitbar; $PROMPT_COMMAND\"' \ - 'PROMPT_COMMAND=\"$TMUX_GITBAR_DIR/update-gitbar; $PROMPT_COMMAND\"'" + 'PROMPT_COMMAND="$TMUX_GITBAR_DIR/update-gitbar; $PROMPT_COMMAND"' From c98c06fee67de3ad6e4ad8ffe3f46152de3f04f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Rainone?= Date: Sat, 19 Nov 2016 23:43:59 +0100 Subject: [PATCH 2/5] Fix integration test: make tmgb.conf path absolute --- test/integration-tests/run_integration_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration-tests/run_integration_tests.sh b/test/integration-tests/run_integration_tests.sh index 77c8593..8d6a839 100755 --- a/test/integration-tests/run_integration_tests.sh +++ b/test/integration-tests/run_integration_tests.sh @@ -5,6 +5,7 @@ export TMUXCONF="$PWD/tmux.conf" # Create a minimal tmux conf file > "${TMUXCONF}" echo TMUX_GITBAR_DIR=\""$PWD"\" >> "${TMUXCONF}" +echo TMUX_GITBAR_CONF=\""$PWD/tmux-gitbar.conf"\" >> "${TMUXCONF}" echo source-file \""$PWD/tmux-gitbar.tmux"\" >> "${TMUXCONF}" bats test/integration-tests/main.bats From bed1486b57c1b8c28597ad91f634cbb3c31f3fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Rainone?= Date: Sat, 19 Nov 2016 23:52:04 +0100 Subject: [PATCH 3/5] Update README: more verbosity --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b848d1..3431597 100644 --- a/README.md +++ b/README.md @@ -105,9 +105,12 @@ sourcing `tmux-gitbar.tmux`. **Note:** Do not include the trailing slash. -## Modifying tmux-gitbar.conf location +## Configuration file -If you prefer to store the **.tmux-gitbar.conf** somewhere other than `~/`. +**tmux-gitbar** auto-generates its own configuration file at first launch +and places it in `$HOME/.tmux-gitbar.conf`. If for whatever reasons you +would like to store it somewhere else, or rename it, just define +`$TMUX_GITBAR_CONF`. **Add this line to your `tmux.conf`** From aeff2e54baa14692a84cbb028a27657c4f61c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Rainone?= Date: Sat, 19 Nov 2016 23:52:24 +0100 Subject: [PATCH 4/5] Update README: update TOC --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3431597..e329437 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ installation directory. * [How-to install](#how-to-install) * [Default installation](#default-installation) * [Installing to another location](#installing-to-another-location) + * [Configuration file](#configuration-file) * [Font](#font) * [Examples](#examples) * [Documentation](#documentation) From b0cf3bdbd0e7885896543f65cc9da6296bf4230a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Rainone?= Date: Sat, 19 Nov 2016 23:54:35 +0100 Subject: [PATCH 5/5] Update README: add contributers sections --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e329437..3f3546d 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,9 @@ from those 2 great projects: - [bash-git-prompt][3] an informative and fancy bash prompt for Git users. - [tmux-git][4] a script for showing current Git branch in Tmux status bar +Contributers: + - [AlexKornitzer][7] + Other credits for : - [tmux/tmux][1] - [gh-md-toc][6] @@ -339,3 +342,4 @@ configuration. [4]: https://github.com/drmad/tmux-git [5]: https://github.com/runsisi/consolas-font-for-powerline [6]: https://github.com/ekalinin/github-markdown-toc +[7]: https://github.com/AlexKornitzer