Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ffbc85a62 | ||
|
|
60c4c0b598 | ||
|
|
088212fd32 | ||
|
|
d1b831a92d | ||
|
|
69407018a7 | ||
|
|
a481ff41ab | ||
|
|
7cc2ced3b9 | ||
|
|
66fbed7f6f | ||
|
|
6b0ca17df0 | ||
|
|
23efb39fb0 | ||
|
|
e1ddf6e311 | ||
|
|
634c1f8c18 | ||
|
|
4686ce1f12 | ||
|
|
a6fd93076d | ||
|
|
13531c9534 | ||
|
|
77c135956d | ||
|
|
23ac376f10 | ||
|
|
ec6d371db8 | ||
|
|
db6fd42104 | ||
|
|
f2b4d82527 | ||
|
|
55e698a737 | ||
|
|
3a778072db | ||
|
|
866e5be86b | ||
|
|
1c2fc2837f | ||
|
|
4e0e59230b | ||
|
|
6ca10cf84c | ||
|
|
33505d4db1 | ||
|
|
09e8c25b64 | ||
|
|
ad1d73aaa1 | ||
|
|
ca8101b34a | ||
|
|
9dece7fe58 | ||
|
|
49649c5f0c | ||
|
|
6a53066b05 | ||
|
|
53e5965f2d | ||
|
|
999b787c92 | ||
|
|
0286a50fcd | ||
|
|
f7cba27f10 | ||
|
|
029e53a433 | ||
|
|
6d422f17e4 | ||
|
|
dc380e9ed6 | ||
|
|
6734baf950 | ||
|
|
df87b41635 | ||
|
|
7762aa687a | ||
|
|
c9efc161ff | ||
|
|
d86a182b6e | ||
|
|
c6ac9109d7 | ||
|
|
2b3af0d8c9 | ||
|
|
ac0d91b682 | ||
|
|
1d73537dbf | ||
|
|
6bacd5fb1c | ||
|
|
fbc5d0a5af | ||
|
|
0e0e0d3035 | ||
|
|
a9dda3d358 | ||
|
|
0d55a2406c | ||
|
|
f0dfe1a67f | ||
|
|
b686515877 | ||
|
|
a36a4c4038 | ||
|
|
fbf7efa1b8 | ||
|
|
4a9df8ec88 | ||
|
|
6e2e0af7f9 | ||
|
|
beac9c430a | ||
|
|
fd91211704 | ||
|
|
629a1b0c0d | ||
|
|
e5cd10112c | ||
|
|
1ddec65d56 | ||
|
|
425ef3e10a | ||
|
|
2a95e983d0 | ||
|
|
c837232643 | ||
|
|
de31a308f9 | ||
|
|
fd1771d45c | ||
|
|
cb9b999f06 | ||
|
|
014c102b71 | ||
|
|
fdff1d81cd | ||
|
|
5c592c9a6f | ||
|
|
1722ea963e | ||
|
|
be755d63af | ||
|
|
df1881acfa | ||
|
|
2927f672fd | ||
|
|
2b8928f2bd | ||
|
|
dfe681d223 | ||
|
|
eb91f4ec69 | ||
|
|
a4e41badf1 |
46
.github/ISSUE_TEMPLATE/bug_report.md
vendored
46
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,46 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a bug report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: bug:general
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--- Provide a general summary of the issue in the Title above -->
|
|
||||||
|
|
||||||
## Expected Behavior
|
|
||||||
<!--- Tell us what should happen -->
|
|
||||||
|
|
||||||
## Current Behavior
|
|
||||||
<!--- Tell us what happens instead of the expected behavior -->
|
|
||||||
|
|
||||||
## Possible Solution
|
|
||||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
|
||||||
|
|
||||||
## Context
|
|
||||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
|
||||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
|
||||||
|
|
||||||
## Steps to Reproduce
|
|
||||||
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
|
||||||
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
|
||||||
1.
|
|
||||||
2.
|
|
||||||
3.
|
|
||||||
4.
|
|
||||||
|
|
||||||
## Your Environment
|
|
||||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
|
||||||
* Bash-it version used:
|
|
||||||
* List of enabled plugins, themes and aliases (use ``bash-it show (plugins/themes/aliases)``):
|
|
||||||
* ``bash-it doctor`` output:
|
|
||||||
* Bash version:
|
|
||||||
* Operating System and version:
|
|
||||||
|
|
||||||
## Your Bash Config File
|
|
||||||
<!--- Please paste here your bash config file (.bashrc/.bash_profile) -->
|
|
||||||
<!--- This will help us debug and locate the problem -->
|
|
||||||
```bash
|
|
||||||
# Your bash config file should be here
|
|
||||||
```
|
|
||||||
85
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
85
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
name: 🐛 Bug report
|
||||||
|
title: "[Bug]: "
|
||||||
|
description: Create a bug report to help us improve
|
||||||
|
labels: "bug:general"
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: Tell us what should happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Current behavior
|
||||||
|
description: Tell us what happens instead of the expected behavior.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Possible solution
|
||||||
|
description: Tell us how it could be fixed at your glance.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Context
|
||||||
|
description: >
|
||||||
|
How has this issue affected you? What are you trying to accomplish?
|
||||||
|
Providing context helps us come up with a solution that is most useful in the real world.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: >
|
||||||
|
Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Bash-it version
|
||||||
|
placeholder: "How to get: bash-it version"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: List of enabled plugins, themes and aliases
|
||||||
|
placeholder: "How to get: bash-it show plugins|themes|aliases (it is not a pipe)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Bash version
|
||||||
|
placeholder: "How to get: bash --version"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Operating system and version
|
||||||
|
placeholder: "How to get: neofetch (or another command)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "bash-it doctor output"
|
||||||
|
value: |
|
||||||
|
```
|
||||||
|
# How to get: bash-it doctor
|
||||||
|
```
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Your ~/.bashrc
|
||||||
|
value: |
|
||||||
|
```bash
|
||||||
|
# How to get: cat ~/.bashrc
|
||||||
|
```
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Notes
|
||||||
|
description: >
|
||||||
|
Provide any extra details here.
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: true
|
||||||
|
contact_links:
|
||||||
|
- name: Libera chat
|
||||||
|
url: https://web.libera.chat/?channel=#bash-it
|
||||||
|
about: You can ask and answer questions here
|
||||||
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: feature request
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--- Provide a general summary of the issue in the Title above -->
|
|
||||||
|
|
||||||
## Expected Behavior
|
|
||||||
<!--- Tell us how your feature should work -->
|
|
||||||
|
|
||||||
## Current Behavior
|
|
||||||
<!--- Explain the difference your feature will have from current behavior -->
|
|
||||||
|
|
||||||
## Possible Solution
|
|
||||||
<!--- Not obligatory, but suggest ideas on how to implement the addition or change -->
|
|
||||||
|
|
||||||
## Context
|
|
||||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
|
||||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
|
||||||
34
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
34
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: 💡 Feature request
|
||||||
|
title: "[Feature]: "
|
||||||
|
description: Suggest an idea for this project
|
||||||
|
labels: "feature request"
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: Tell us how your feature should work.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Current behavior
|
||||||
|
description: Explain the difference your feature will have from current behavior.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Possible solution
|
||||||
|
description: Tell us how it could be fixed at your glance.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Context
|
||||||
|
description: >
|
||||||
|
How has this issue affected you? What are you trying to accomplish?
|
||||||
|
Providing context helps us come up with a solution that is most useful in the real world.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Notes
|
||||||
|
description: >
|
||||||
|
Provide any extra details here.
|
||||||
@@ -34,7 +34,7 @@ fi
|
|||||||
alias c='clear'
|
alias c='clear'
|
||||||
alias cls='clear'
|
alias cls='clear'
|
||||||
|
|
||||||
alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}'
|
alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
|
||||||
alias pager='${PAGER:=less}'
|
alias pager='${PAGER:=less}'
|
||||||
|
|
||||||
alias q='exit'
|
alias q='exit'
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ alias safari='open -a safari'
|
|||||||
alias firefox='open -a firefox'
|
alias firefox='open -a firefox'
|
||||||
alias chrome='open -a "Google Chrome"'
|
alias chrome='open -a "Google Chrome"'
|
||||||
alias chromium='open -a chromium'
|
alias chromium='open -a chromium'
|
||||||
|
alias brave='open -a "Brave Browser"'
|
||||||
alias dashcode='open -a dashcode'
|
alias dashcode='open -a dashcode'
|
||||||
alias f='open -a Finder '
|
alias f='open -a Finder '
|
||||||
alias fh='open -a Finder .'
|
alias fh='open -a Finder .'
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ if [[ -n "${BASH_IT_THEME:-}" ]]; then
|
|||||||
source "${BASH_IT}/themes/githelpers.theme.bash"
|
source "${BASH_IT}/themes/githelpers.theme.bash"
|
||||||
BASH_IT_LOG_PREFIX="themes: p4helpers: "
|
BASH_IT_LOG_PREFIX="themes: p4helpers: "
|
||||||
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
||||||
BASH_IT_LOG_PREFIX="themes: command_duration: "
|
|
||||||
source "${BASH_IT}/themes/command_duration.theme.bash"
|
|
||||||
BASH_IT_LOG_PREFIX="themes: base: "
|
BASH_IT_LOG_PREFIX="themes: base: "
|
||||||
source "${BASH_IT}/themes/base.theme.bash"
|
source "${BASH_IT}/themes/base.theme.bash"
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ lint_clean_files.sh
|
|||||||
#
|
#
|
||||||
completion/available/apm.completion.bash
|
completion/available/apm.completion.bash
|
||||||
completion/available/awless.completion.bash
|
completion/available/awless.completion.bash
|
||||||
|
completion/available/awscli.completion.bash
|
||||||
completion/available/bash-it.completion.bash
|
completion/available/bash-it.completion.bash
|
||||||
completion/available/brew.completion.bash
|
completion/available/brew.completion.bash
|
||||||
completion/available/cargo.completion.bash
|
completion/available/cargo.completion.bash
|
||||||
@@ -76,7 +77,9 @@ completion/available/vuejs.completion.bash
|
|||||||
completion/available/wpscan.completion.bash
|
completion/available/wpscan.completion.bash
|
||||||
|
|
||||||
# libraries
|
# libraries
|
||||||
|
lib/appearance.bash
|
||||||
lib/colors.bash
|
lib/colors.bash
|
||||||
|
lib/command_duration.bash
|
||||||
lib/helpers.bash
|
lib/helpers.bash
|
||||||
lib/history.bash
|
lib/history.bash
|
||||||
lib/log.bash
|
lib/log.bash
|
||||||
@@ -134,10 +137,9 @@ plugins/available/zoxide.plugin.bash
|
|||||||
|
|
||||||
# tests
|
# tests
|
||||||
#
|
#
|
||||||
test/plugins/alias-completion.plugin.bats
|
test/completion/aliases.completion.bats
|
||||||
test/run
|
test/run
|
||||||
test/test_helper.bash
|
test/test_helper.bash
|
||||||
test/test_helper_libs.bash
|
|
||||||
|
|
||||||
# themes
|
# themes
|
||||||
#
|
#
|
||||||
@@ -155,11 +157,13 @@ themes/bobby-python
|
|||||||
themes/brainy
|
themes/brainy
|
||||||
themes/brunton
|
themes/brunton
|
||||||
themes/candy
|
themes/candy
|
||||||
themes/command_duration.theme.bash
|
|
||||||
themes/easy
|
themes/easy
|
||||||
themes/essential
|
themes/essential
|
||||||
|
themes/githelpers.theme.bash
|
||||||
themes/modern
|
themes/modern
|
||||||
themes/norbu
|
themes/norbu
|
||||||
|
themes/oh-my-posh
|
||||||
|
themes/p4helpers.theme.bash
|
||||||
themes/pete
|
themes/pete
|
||||||
themes/powerline
|
themes/powerline
|
||||||
themes/pure
|
themes/pure
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
if _command_exists aws_completer
|
if _command_exists aws_completer; then
|
||||||
then
|
|
||||||
complete -C "$(command -v aws_completer)" aws
|
complete -C "$(command -v aws_completer)" aws
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -346,6 +346,19 @@ NWinkler
|
|||||||
:alt:
|
:alt:
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
.. _oh_my_posh_image:
|
||||||
|
|
||||||
|
Oh-My-Posh
|
||||||
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
|
||||||
|
.. image:: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png
|
||||||
|
:target: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png
|
||||||
|
:alt:
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Pete
|
Pete
|
||||||
|
|||||||
15
docs/themes-list/oh-my-posh.rst
Normal file
15
docs/themes-list/oh-my-posh.rst
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
.. _oh-my-posh:
|
||||||
|
|
||||||
|
Oh-My-Posh Theme
|
||||||
|
================
|
||||||
|
|
||||||
|
The oh-my-posh ״theme״ is really a plug to a whole other system
|
||||||
|
of managing your prompt. To use it please start here:
|
||||||
|
`Oh-My-Posh homepage <https://ohmyposh.dev/>`_
|
||||||
|
|
||||||
|
It is beyond the scope of bash-it to install and manage oh-my-posh,
|
||||||
|
this theme is here just to make sure your OMP setup doesn't clash
|
||||||
|
with other bash-it themes. Once installed, OMP will load a default
|
||||||
|
OMP theme (jandedobbeleer), which you can then customize or override.
|
||||||
|
|
||||||
|
Note: Nerd Fonts are highly recommended, as most of the themes are graphic candies.
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
# colored ls
|
: "${CLICOLOR:=$(tput colors)}"
|
||||||
export LSCOLORS='Gxfxcxdxdxegedabagacad'
|
export CLICOLOR
|
||||||
|
|
||||||
if [[ -z "$CUSTOM_THEME_DIR" ]]; then
|
: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes"}"
|
||||||
CUSTOM_THEME_DIR="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Load the theme
|
# Load the theme
|
||||||
if [[ $BASH_IT_THEME ]]; then
|
# shellcheck disable=SC1090
|
||||||
if [[ -f $BASH_IT_THEME ]]; then
|
if [[ -n "${BASH_IT_THEME:-}" ]]; then
|
||||||
source $BASH_IT_THEME
|
if [[ -f "${BASH_IT_THEME}" ]]; then
|
||||||
|
source "${BASH_IT_THEME}"
|
||||||
elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
|
elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
|
||||||
source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
|
source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
|
||||||
else
|
else
|
||||||
|
|||||||
61
lib/command_duration.bash
Normal file
61
lib/command_duration.bash
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
#
|
||||||
|
# Functions for measuring and reporting how long a command takes to run.
|
||||||
|
|
||||||
|
: "${COMMAND_DURATION_START_SECONDS:=${EPOCHREALTIME:-$SECONDS}}"
|
||||||
|
: "${COMMAND_DURATION_ICON:=🕘}"
|
||||||
|
: "${COMMAND_DURATION_MIN_SECONDS:=1}"
|
||||||
|
|
||||||
|
function _command_duration_pre_exec() {
|
||||||
|
COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _dynamic_clock_icon {
|
||||||
|
local clock_hand
|
||||||
|
# clock hand value is between 90 and 9b in hexadecimal.
|
||||||
|
# so between 144 and 155 in base 10.
|
||||||
|
printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144))
|
||||||
|
printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _command_duration() {
|
||||||
|
[[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return
|
||||||
|
|
||||||
|
local command_duration=0 command_start="${COMMAND_DURATION_START_SECONDS:-0}"
|
||||||
|
local -i minutes=0 seconds=0 deciseconds=0
|
||||||
|
local -i command_start_seconds="${command_start%.*}"
|
||||||
|
local -i command_start_deciseconds=$((10#${command_start##*.}))
|
||||||
|
command_start_deciseconds="${command_start_deciseconds:0:1}"
|
||||||
|
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
||||||
|
local -i current_time_seconds="${current_time%.*}"
|
||||||
|
local -i current_time_deciseconds="$((10#${current_time##*.}))"
|
||||||
|
current_time_deciseconds="${current_time_deciseconds:0:1}"
|
||||||
|
|
||||||
|
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
|
||||||
|
# seconds
|
||||||
|
command_duration="$((current_time_seconds - command_start_seconds))"
|
||||||
|
|
||||||
|
if ((current_time_deciseconds >= command_start_deciseconds)); then
|
||||||
|
deciseconds="$((current_time_deciseconds - command_start_deciseconds))"
|
||||||
|
else
|
||||||
|
((command_duration -= 1))
|
||||||
|
deciseconds="$((10 - (command_start_deciseconds - current_time_deciseconds)))"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
command_duration=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((command_duration > 0)); then
|
||||||
|
minutes=$((command_duration / 60))
|
||||||
|
seconds=$((command_duration % 60))
|
||||||
|
fi
|
||||||
|
|
||||||
|
_dynamic_clock_icon "${command_duration}"
|
||||||
|
if ((minutes > 0)); then
|
||||||
|
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
|
||||||
|
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
|
||||||
|
printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_bash_it_library_finalize_hook+=("safe_append_preexec '_command_duration_pre_exec'")
|
||||||
@@ -45,7 +45,7 @@ function _bash-it-log-prefix-by-path() {
|
|||||||
|
|
||||||
function _has_colors() {
|
function _has_colors() {
|
||||||
# Check that stdout is a terminal, and that it has at least 8 colors.
|
# Check that stdout is a terminal, and that it has at least 8 colors.
|
||||||
[[ -t 1 && "${_bash_it_available_colors:=$(tput colors 2> /dev/null)}" -ge 8 ]]
|
[[ -t 1 && "${CLICOLOR:=$(tput colors 2> /dev/null)}" -ge 8 ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function _bash-it-log-message() {
|
function _bash-it-log-message() {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function _bash-it-preview() {
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
for BASH_IT_THEME in "${themes[@]}"; do
|
for BASH_IT_THEME in "${themes[@]}"; do
|
||||||
BASH_IT_LOG_LEVEL=0
|
BASH_IT_LOG_LEVEL=0
|
||||||
bash --init-file "${BASH_IT_BASHRC:-${BASH_IT?}/bash_it.sh}" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"'
|
bash --init-file "${BASH_IT?}/bash_it.sh" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"'
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ function _bash-it-flash-term() {
|
|||||||
local -i len="${1:-0}" # redundant
|
local -i len="${1:-0}" # redundant
|
||||||
local term="${2:-}"
|
local term="${2:-}"
|
||||||
# as currently implemented, `$match` has already been printed to screen the first time
|
# as currently implemented, `$match` has already been printed to screen the first time
|
||||||
local delay=0.1
|
local delay=0.2
|
||||||
local color
|
local color
|
||||||
[[ "${#term}" -gt 0 ]] && len="${#term}"
|
[[ "${#term}" -gt 0 ]] && len="${#term}"
|
||||||
|
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ function _bash-it-array-dedup() {
|
|||||||
|
|
||||||
# Outputs a full path of the grep found on the filesystem
|
# Outputs a full path of the grep found on the filesystem
|
||||||
function _bash-it-grep() {
|
function _bash-it-grep() {
|
||||||
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
|
: "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}"
|
||||||
printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}"
|
printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Runs `grep` with extended regular expressions
|
# Runs `grep` with extended regular expressions
|
||||||
function _bash-it-egrep() {
|
function _bash-it-egrep() {
|
||||||
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
|
: "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}"
|
||||||
"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
|
"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ about-plugin 'display info about your battery charge level'
|
|||||||
function ac_adapter_connected() {
|
function ac_adapter_connected() {
|
||||||
local batteries
|
local batteries
|
||||||
if _command_exists upower; then
|
if _command_exists upower; then
|
||||||
batteries="$(upower -e | grep --max-count=1 -i BAT)"
|
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||||
upower -i "${batteries}" | grep 'state' | grep -q 'charging\|fully-charged'
|
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'charging\|fully-charged'
|
||||||
elif _command_exists acpi; then
|
elif _command_exists acpi; then
|
||||||
acpi -a | grep -q "on-line"
|
acpi -a | grep -q "on-line"
|
||||||
elif _command_exists pmset; then
|
elif _command_exists pmset; then
|
||||||
@@ -20,8 +20,8 @@ function ac_adapter_connected() {
|
|||||||
function ac_adapter_disconnected() {
|
function ac_adapter_disconnected() {
|
||||||
local batteries
|
local batteries
|
||||||
if _command_exists upower; then
|
if _command_exists upower; then
|
||||||
batteries="$(upower -e | grep --max-count=1 -i BAT)"
|
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||||
upower -i "${batteries}" | grep 'state' | grep -q 'discharging'
|
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'discharging'
|
||||||
elif _command_exists acpi; then
|
elif _command_exists acpi; then
|
||||||
acpi -a | grep -q "off-line"
|
acpi -a | grep -q "off-line"
|
||||||
elif _command_exists pmset; then
|
elif _command_exists pmset; then
|
||||||
@@ -40,8 +40,8 @@ function battery_percentage() {
|
|||||||
local command_output batteries
|
local command_output batteries
|
||||||
|
|
||||||
if _command_exists upower; then
|
if _command_exists upower; then
|
||||||
batteries="$(upower --enumerate | grep --max-count=1 -i BAT)"
|
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||||
command_output="$(upower --show-info "${batteries:-}" | grep percentage | grep -o '[0-9]\+' | head -1)"
|
command_output="$(upower --show-info "${batteries[0]:-}" | grep percentage | grep -o '[0-9]\+' | head -1)"
|
||||||
elif _command_exists acpi; then
|
elif _command_exists acpi; then
|
||||||
command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}')
|
command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}')
|
||||||
elif _command_exists pmset; then
|
elif _command_exists pmset; then
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
|
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
|
||||||
|
|
||||||
precmd_return_notification() {
|
function precmd_return_notification() {
|
||||||
export LAST_COMMAND_DURATION=$(($(date +%s) - ${LAST_COMMAND_TIME:=$(date +%s)}))
|
local command_start="${COMMAND_DURATION_START_SECONDS:=0}"
|
||||||
[[ ${LAST_COMMAND_DURATION} -gt ${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5} ]] && echo -e "\a"
|
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
||||||
export LAST_COMMAND_TIME=
|
local -i command_duration="$((${current_time%.*} - ${command_start%.*}))"
|
||||||
|
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then
|
||||||
|
printf '\a'
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
preexec_return_notification() {
|
safe_append_prompt_command 'precmd_return_notification'
|
||||||
[[ -z "${LAST_COMMAND_TIME}" ]] && LAST_COMMAND_TIME=$(date +%s)
|
safe_append_preexec '_command_duration_pre_exec'
|
||||||
}
|
|
||||||
|
|
||||||
precmd_functions+=(precmd_return_notification)
|
|
||||||
preexec_functions+=(preexec_return_notification)
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function pj() {
|
|||||||
# with the same name in project directories
|
# with the same name in project directories
|
||||||
IFS=':' read -ra dests <<< "${BASH_IT_PROJECT_PATHS?${FUNCNAME[0]}: project working folders must be configured}"
|
IFS=':' read -ra dests <<< "${BASH_IT_PROJECT_PATHS?${FUNCNAME[0]}: project working folders must be configured}"
|
||||||
for d in "${!dests[@]}"; do
|
for d in "${!dests[@]}"; do
|
||||||
if [[ ! -d "${dests[d]}" ]]; then
|
if [[ ! -d "${dests[d]}/${proj}" ]]; then
|
||||||
unset 'dests[d]'
|
unset 'dests[d]'
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
|
|
||||||
function local_setup {
|
|
||||||
setup_test_fixture
|
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
# Copy the test fixture to the Bash-it folder
|
# Copy the test fixture to the Bash-it folder
|
||||||
if command -v rsync &> /dev/null
|
cp -fRP "${BASH_IT?}/test/fixtures/bash_it"/* "${BASH_IT?}/" || true
|
||||||
then
|
# don't load any libraries as the tests here test the *whole* kit
|
||||||
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
|
||||||
else
|
|
||||||
find "$BASH_IT/test/fixtures/bash_it" \
|
|
||||||
-mindepth 1 -maxdepth 1 \
|
|
||||||
-exec cp -r {} "$BASH_IT/" \;
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "bash-it: verify that the test fixture is available" {
|
@test "bash-it: verify that the test fixture is available" {
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
|
setup_libs "helpers"
|
||||||
# Load something, anything...
|
# Load something, anything...
|
||||||
load ../../completion/available/capistrano.completion
|
load ../../completion/available/capistrano.completion
|
||||||
|
}
|
||||||
|
|
||||||
@test "alias-completion: See that aliases with double quotes and brackets do not break the plugin" {
|
@test "alias-completion: See that aliases with double quotes and brackets do not break the plugin" {
|
||||||
alias gtest="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative"
|
alias gtest="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative"
|
||||||
run load ../../completion/available/aliases.completion
|
run load "${BASH_IT?}/completion/available/aliases.completion.bash"
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "alias-completion: See that aliases with single quotes and brackets do not break the plugin" {
|
@test "alias-completion: See that aliases with single quotes and brackets do not break the plugin" {
|
||||||
alias gtest='git log --graph --pretty=format:"%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset" --abbrev-commit --date=relative'
|
alias gtest='git log --graph --pretty=format:"%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset" --abbrev-commit --date=relative'
|
||||||
run load ../../completion/available/aliases.completion
|
run load "${BASH_IT?}/completion/available/aliases.completion.bash"
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "alias-completion: See that having aliased rm command does not output unnecessary output" {
|
@test "alias-completion: See that having aliased rm command does not output unnecessary output" {
|
||||||
alias rm='rm -v'
|
alias rm='rm -v'
|
||||||
run load ../../completion/available/aliases.completion
|
run load "${BASH_IT?}/completion/available/aliases.completion.bash"
|
||||||
|
|
||||||
refute_output
|
refute_output
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../../lib/utilities
|
|
||||||
load ../../lib/helpers
|
|
||||||
load ../../completion/available/bash-it.completion
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup_file() {
|
||||||
setup_test_fixture
|
setup_libs "helpers"
|
||||||
|
load "${BASH_IT?}/completion/available/bash-it.completion.bash"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "completion bash-it: ensure that the _bash-it function is available" {
|
@test "completion bash-it: ensure that the _bash-it function is available" {
|
||||||
type -a _bash-it &> /dev/null
|
run type -t _bash-it
|
||||||
assert_success
|
assert_success
|
||||||
|
assert_output "function"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __check_completion () {
|
function __check_completion () {
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
|
|
||||||
|
function local_setup() {
|
||||||
|
export HOME="$BATS_TEST_TMPDIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
# Determine which config file to use based on OS.
|
# Determine which config file to use based on OS.
|
||||||
case $OSTYPE in
|
case $OSTYPE in
|
||||||
darwin*)
|
darwin*)
|
||||||
@@ -11,9 +16,7 @@ case $OSTYPE in
|
|||||||
export BASH_IT_CONFIG_FILE=.bashrc
|
export BASH_IT_CONFIG_FILE=.bashrc
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
# don't load any libraries as the tests here test the *whole* kit
|
||||||
function local_setup {
|
|
||||||
setup_test_fixture
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install: verify that the install script exists" {
|
@test "install: verify that the install script exists" {
|
||||||
@@ -25,7 +28,7 @@ function local_setup {
|
|||||||
|
|
||||||
./install.sh --silent
|
./install.sh --silent
|
||||||
|
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
|
|
||||||
assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
||||||
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
|
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
|
||||||
@@ -37,16 +40,16 @@ function local_setup {
|
|||||||
@test "install: verify that a backup file is created" {
|
@test "install: verify that a backup file is created" {
|
||||||
cd "$BASH_IT"
|
cd "$BASH_IT"
|
||||||
|
|
||||||
touch "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
touch "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
echo "test file content" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
local md5_orig=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
||||||
|
|
||||||
./install.sh --silent
|
./install.sh --silent
|
||||||
|
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
|
||||||
|
|
||||||
local md5_bak=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')
|
local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')
|
||||||
|
|
||||||
assert_equal "$md5_orig" "$md5_bak"
|
assert_equal "$md5_orig" "$md5_bak"
|
||||||
}
|
}
|
||||||
@@ -70,15 +73,15 @@ function local_setup {
|
|||||||
@test "install: verify that the template is appended" {
|
@test "install: verify that the template is appended" {
|
||||||
cd "$BASH_IT"
|
cd "$BASH_IT"
|
||||||
|
|
||||||
touch "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
touch "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
echo "test file content" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
|
|
||||||
./install.sh --silent --append-to-config
|
./install.sh --silent --append-to-config
|
||||||
|
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
|
||||||
|
|
||||||
run cat $BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE
|
run cat "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
|
|
||||||
assert_line "test file content"
|
assert_line "test file content"
|
||||||
assert_line "source \"\$BASH_IT\"/bash_it.sh"
|
assert_line "source \"\$BASH_IT\"/bash_it.sh"
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
|
|
||||||
|
function local_setup() {
|
||||||
|
export HOME="$BATS_TEST_TMPDIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
# Determine which config file to use based on OS.
|
# Determine which config file to use based on OS.
|
||||||
case $OSTYPE in
|
case $OSTYPE in
|
||||||
darwin*)
|
darwin*)
|
||||||
@@ -11,9 +16,7 @@ case $OSTYPE in
|
|||||||
export BASH_IT_CONFIG_FILE=.bashrc
|
export BASH_IT_CONFIG_FILE=.bashrc
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
# don't load any libraries as the tests here test the *whole* kit
|
||||||
function local_setup {
|
|
||||||
setup_test_fixture
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "uninstall: verify that the uninstall script exists" {
|
@test "uninstall: verify that the uninstall script exists" {
|
||||||
@@ -23,19 +26,18 @@ function local_setup {
|
|||||||
@test "uninstall: run the uninstall script with an existing backup file" {
|
@test "uninstall: run the uninstall script with an existing backup file" {
|
||||||
cd "$BASH_IT"
|
cd "$BASH_IT"
|
||||||
|
|
||||||
echo "test file content for backup" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
|
echo "test file content for backup" > "$HOME/$BASH_IT_CONFIG_FILE.bak"
|
||||||
echo "test file content for original file" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
local md5_bak=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')
|
local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}')
|
||||||
|
|
||||||
./uninstall.sh
|
|
||||||
|
|
||||||
|
run ./uninstall.sh
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall"
|
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall"
|
||||||
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
|
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
|
|
||||||
local md5_conf=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
local md5_conf=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
||||||
|
|
||||||
assert_equal "$md5_bak" "$md5_conf"
|
assert_equal "$md5_bak" "$md5_conf"
|
||||||
}
|
}
|
||||||
@@ -43,18 +45,17 @@ function local_setup {
|
|||||||
@test "uninstall: run the uninstall script without an existing backup file" {
|
@test "uninstall: run the uninstall script without an existing backup file" {
|
||||||
cd "$BASH_IT"
|
cd "$BASH_IT"
|
||||||
|
|
||||||
echo "test file content for original file" > "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
local md5_orig=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}')
|
||||||
|
|
||||||
./uninstall.sh
|
|
||||||
|
|
||||||
|
run ./uninstall.sh
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_file_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall"
|
assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall"
|
||||||
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.bak"
|
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak"
|
||||||
assert_file_not_exist "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE"
|
assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE"
|
||||||
|
|
||||||
local md5_uninstall=$(md5sum "$BASH_IT_TEST_HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}')
|
local md5_uninstall=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}')
|
||||||
|
|
||||||
assert_equal "$md5_orig" "$md5_uninstall"
|
assert_equal "$md5_orig" "$md5_uninstall"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
|
true
|
||||||
|
# don't load any libraries as the tests here test the *whole* kit
|
||||||
|
}
|
||||||
|
|
||||||
@test "lib composure: _composure_keywords()" {
|
@test "lib composure: _composure_keywords()" {
|
||||||
run _composure_keywords
|
run _composure_keywords
|
||||||
|
|||||||
22
test/lib/helpers.bats
Executable file → Normal file
22
test/lib/helpers.bats
Executable file → Normal file
@@ -1,21 +1,15 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
load ../../plugins/available/base.plugin
|
|
||||||
load ../../lib/colors
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup_file() {
|
||||||
setup_test_fixture
|
setup_libs "colors"
|
||||||
|
load "${BASH_IT?}/plugins/available/base.plugin.bash"
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_setup() {
|
||||||
# Copy the test fixture to the Bash-it folder
|
# Copy the test fixture to the Bash-it folder
|
||||||
if command -v rsync &> /dev/null; then
|
cp -RP "$BASH_IT/test/fixtures/bash_it"/* "$BASH_IT/"
|
||||||
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
|
||||||
else
|
|
||||||
find "$BASH_IT/test/fixtures/bash_it" \
|
|
||||||
-mindepth 1 -maxdepth 1 \
|
|
||||||
-exec cp -r {} "$BASH_IT/" \;
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO Create global __is_enabled function
|
# TODO Create global __is_enabled function
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../../lib/colors
|
|
||||||
|
|
||||||
load ../../lib/log
|
function local_setup_file() {
|
||||||
load ../../lib/helpers
|
setup_libs "log"
|
||||||
load ../../plugins/available/base.plugin
|
}
|
||||||
|
|
||||||
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" {
|
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" {
|
||||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
|
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ function local_setup {
|
|||||||
|
|
||||||
@test "lib preexec: __check_precmd_conflict()" {
|
@test "lib preexec: __check_precmd_conflict()" {
|
||||||
test_precmd_function_name="test"
|
test_precmd_function_name="test"
|
||||||
load ../test_helper_libs
|
setup_libs "preexec"
|
||||||
|
|
||||||
run __check_precmd_conflict "$test_precmd_function_name"
|
run __check_precmd_conflict "$test_precmd_function_name"
|
||||||
assert_failure
|
assert_failure
|
||||||
@@ -124,7 +124,7 @@ function local_setup {
|
|||||||
|
|
||||||
@test "lib preexec: __check_preexec_conflict()" {
|
@test "lib preexec: __check_preexec_conflict()" {
|
||||||
test_preexec_function_name="test"
|
test_preexec_function_name="test"
|
||||||
load ../test_helper_libs
|
setup_libs "preexec"
|
||||||
|
|
||||||
run __check_preexec_conflict "$test_preexec_function_name"
|
run __check_preexec_conflict "$test_preexec_function_name"
|
||||||
assert_failure
|
assert_failure
|
||||||
@@ -137,7 +137,7 @@ function local_setup {
|
|||||||
|
|
||||||
@test "lib preexec: safe_append_prompt_command()" {
|
@test "lib preexec: safe_append_prompt_command()" {
|
||||||
test_precmd_function_name="test"
|
test_precmd_function_name="test"
|
||||||
load ../test_helper_libs
|
setup_libs "preexec"
|
||||||
|
|
||||||
export precmd_functions=()
|
export precmd_functions=()
|
||||||
assert_equal "${precmd_functions[*]}" ""
|
assert_equal "${precmd_functions[*]}" ""
|
||||||
@@ -151,7 +151,7 @@ function local_setup {
|
|||||||
|
|
||||||
@test "lib preexec: safe_append_preexec()" {
|
@test "lib preexec: safe_append_preexec()" {
|
||||||
test_preexec_function_name="test"
|
test_preexec_function_name="test"
|
||||||
load ../test_helper_libs
|
setup_libs "preexec"
|
||||||
|
|
||||||
export preexec_functions=()
|
export preexec_functions=()
|
||||||
assert_equal "${preexec_functions[*]}" ""
|
assert_equal "${preexec_functions[*]}" ""
|
||||||
|
|||||||
28
test/lib/search.bats
Executable file → Normal file
28
test/lib/search.bats
Executable file → Normal file
@@ -1,28 +1,14 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
load ../../plugins/available/base.plugin
|
function local_setup_file() {
|
||||||
load ../../aliases/available/git.aliases
|
setup_libs "search"
|
||||||
load ../../plugins/available/ruby.plugin
|
|
||||||
load ../../plugins/available/rails.plugin
|
|
||||||
load ../../completion/available/bundler.completion
|
|
||||||
load ../../completion/available/gem.completion
|
|
||||||
load ../../completion/available/rake.completion
|
|
||||||
|
|
||||||
load ../../lib/helpers
|
|
||||||
|
|
||||||
function local_setup {
|
|
||||||
setup_test_fixture
|
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
|
||||||
export PATH="/usr/bin:/bin:/usr/sbin"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function local_teardown {
|
function local_setup() {
|
||||||
export PATH="$OLD_PATH"
|
# shellcheck disable=SC2034
|
||||||
unset OLD_PATH
|
BASH_IT_SEARCH_USE_COLOR=false
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "search: plugin base" {
|
@test "search: plugin base" {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup_file() {
|
||||||
setup_test_fixture
|
setup_libs "helpers"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "_bash-it-component-item-is-enabled() - for a disabled item" {
|
@test "_bash-it-component-item-is-enabled() - for a disabled item" {
|
||||||
|
|||||||
35
test/plugins/base.plugin.bats
Executable file → Normal file
35
test/plugins/base.plugin.bats
Executable file → Normal file
@@ -1,14 +1,13 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
load ../../plugins/available/base.plugin
|
function local_setup_file() {
|
||||||
|
setup_libs "helpers"
|
||||||
|
load "${BASH_IT?}/plugins/available/base.plugin.bash"
|
||||||
|
}
|
||||||
|
|
||||||
@test 'plugins base: ips()' {
|
@test 'plugins base: ips()' {
|
||||||
if [[ $CI ]]; then
|
|
||||||
skip 'ifconfig probably requires sudo on TravisCI'
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r localhost='127.0.0.1'
|
declare -r localhost='127.0.0.1'
|
||||||
run ips
|
run ips
|
||||||
assert_success
|
assert_success
|
||||||
@@ -23,7 +22,7 @@ load ../../plugins/available/base.plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins base: pickfrom()' {
|
@test 'plugins base: pickfrom()' {
|
||||||
stub_file="${BASH_IT_ROOT}/stub_file"
|
stub_file="${BATS_TEST_TMPDIR}/stub_file"
|
||||||
printf "l1\nl2\nl3" > $stub_file
|
printf "l1\nl2\nl3" > $stub_file
|
||||||
run pickfrom $stub_file
|
run pickfrom $stub_file
|
||||||
assert_success
|
assert_success
|
||||||
@@ -31,28 +30,30 @@ load ../../plugins/available/base.plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins base: mkcd()' {
|
@test 'plugins base: mkcd()' {
|
||||||
cd "${BASH_IT_ROOT}"
|
cd "${BATS_TEST_TMPDIR}"
|
||||||
declare -r dir_name="-dir_with_dash"
|
declare -r dir_name="-dir_with_dash"
|
||||||
|
|
||||||
# Make sure that the directory does not exist prior to the test
|
# Make sure that the directory does not exist prior to the test
|
||||||
rm -rf "${BASH_IT_ROOT}/${dir_name}"
|
rm -rf "${BATS_TEST_TMPDIR}/${dir_name}"
|
||||||
|
|
||||||
|
run mkcd "${dir_name}"
|
||||||
|
assert_success
|
||||||
|
assert_dir_exist "${BATS_TEST_TMPDIR}/${dir_name}"
|
||||||
|
|
||||||
mkcd "${dir_name}"
|
mkcd "${dir_name}"
|
||||||
assert_success
|
assert_equal "${PWD}" "${BATS_TEST_TMPDIR//\/\///}/${dir_name}"
|
||||||
assert_dir_exist "${BASH_IT_ROOT}/${dir_name}"
|
|
||||||
assert_equal "${PWD}" "${BASH_IT_ROOT//\/\///}/${dir_name}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins base: lsgrep()' {
|
@test 'plugins base: lsgrep()' {
|
||||||
for i in 1 2 3; do mkdir -p "${BASH_IT_TEST_DIR}/${i}"; done
|
for i in 1 2 3; do mkdir -p "${BASH_IT}/${i}"; done
|
||||||
cd $BASH_IT_TEST_DIR
|
cd $BASH_IT
|
||||||
run lsgrep 2
|
run lsgrep 2
|
||||||
assert_success
|
assert_success
|
||||||
assert_equal $output 2
|
assert_equal $output 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins base: buf()' {
|
@test 'plugins base: buf()' {
|
||||||
declare -r file="${BASH_IT_ROOT}/file"
|
declare -r file="${BATS_TEST_TMPDIR}/file"
|
||||||
touch $file
|
touch $file
|
||||||
|
|
||||||
# Take one timestamp before running the `buf` function
|
# Take one timestamp before running the `buf` function
|
||||||
|
|||||||
13
test/plugins/battery.plugin.bats
Executable file → Normal file
13
test/plugins/battery.plugin.bats
Executable file → Normal file
@@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
load ../../plugins/available/battery.plugin
|
function local_setup_file() {
|
||||||
|
setup_libs "helpers"
|
||||||
|
load "${BASH_IT?}/plugins/available/battery.plugin.bash"
|
||||||
|
}
|
||||||
|
|
||||||
# Sets up the `_command_exists` function so that it only responds `true` if called with
|
# Sets up the `_command_exists` function so that it only responds `true` if called with
|
||||||
# the name of the function that was passed in as an argument to `setup_command_exists`.
|
# the name of the function that was passed in as an argument to `setup_command_exists`.
|
||||||
@@ -199,8 +201,7 @@ function setup_upower {
|
|||||||
function upower {
|
function upower {
|
||||||
case $1 in
|
case $1 in
|
||||||
'-e'|'--enumerate')
|
'-e'|'--enumerate')
|
||||||
# don't just `echo` twice because `grep` will close the pipe after matching the first line...
|
printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
|
||||||
echo "$BAT0"$'\n'"/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
|
|
||||||
;;
|
;;
|
||||||
'-i'|'--show-info')
|
'-i'|'--show-info')
|
||||||
if [[ $2 == "$BAT0" ]]
|
if [[ $2 == "$BAT0" ]]
|
||||||
|
|||||||
41
test/plugins/cmd-returned-notify.plugin.bats
Executable file → Normal file
41
test/plugins/cmd-returned-notify.plugin.bats
Executable file → Normal file
@@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
load ../../plugins/available/cmd-returned-notify.plugin
|
function local_setup_file() {
|
||||||
|
setup_libs "command_duration"
|
||||||
|
load "${BASH_IT?}/plugins/available/cmd-returned-notify.plugin.bash"
|
||||||
|
}
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: notify after elapsed time" {
|
@test "plugins cmd-returned-notify: notify after elapsed time" {
|
||||||
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
|
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
|
||||||
export LAST_COMMAND_TIME=$(date +%s)
|
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||||
sleep 1
|
sleep 1
|
||||||
run precmd_return_notification
|
run precmd_return_notification
|
||||||
assert_success
|
assert_success
|
||||||
@@ -16,31 +18,24 @@ load ../../plugins/available/cmd-returned-notify.plugin
|
|||||||
|
|
||||||
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
|
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
|
||||||
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
|
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
|
||||||
export LAST_COMMAND_TIME=$(date +%s)
|
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||||
sleep 1
|
sleep 1
|
||||||
run precmd_return_notification
|
run precmd_return_notification
|
||||||
assert_success
|
assert_success
|
||||||
assert_output $''
|
assert_output $''
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: preexec no output" {
|
@test "lib command_duration: preexec no output" {
|
||||||
export LAST_COMMAND_TIME=
|
export COMMAND_DURATION_START_SECONDS=
|
||||||
run preexec_return_notification
|
run _command_duration_pre_exec
|
||||||
assert_success
|
assert_success
|
||||||
assert_output ""
|
assert_output ""
|
||||||
}
|
}
|
||||||
|
@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" {
|
||||||
@test "plugins cmd-returned-notify: preexec no output env set" {
|
export COMMAND_DURATION_START_SECONDS=
|
||||||
export LAST_COMMAND_TIME=$(date +%s)
|
assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
|
||||||
run preexec_return_notification
|
NOW="${EPOCHREALTIME:-$SECONDS}"
|
||||||
assert_failure
|
_command_duration_pre_exec
|
||||||
assert_output ""
|
# We need to make sure to account for nanoseconds...
|
||||||
}
|
assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}"
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: preexec set LAST_COMMAND_TIME" {
|
|
||||||
export LAST_COMMAND_TIME=
|
|
||||||
assert_equal "${LAST_COMMAND_TIME}" ""
|
|
||||||
NOW=$(date +%s)
|
|
||||||
preexec_return_notification
|
|
||||||
assert_equal "${LAST_COMMAND_TIME}" "${NOW}"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
function local_setup()
|
function local_setup_file() {
|
||||||
{
|
setup_libs "helpers"
|
||||||
setup_test_fixture
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_go_path()
|
function setup_go_path()
|
||||||
|
|||||||
27
test/plugins/ruby.plugin.bats
Executable file → Normal file
27
test/plugins/ruby.plugin.bats
Executable file → Normal file
@@ -1,24 +1,15 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup_file() {
|
||||||
setup_test_fixture
|
setup_libs "helpers"
|
||||||
|
|
||||||
_command_exists "ruby" && mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
|
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
|
||||||
export PATH="/usr/bin:/bin:/usr/sbin"
|
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export PATH="$OLD_PATH"
|
|
||||||
unset OLD_PATH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins ruby: remove_gem is defined" {
|
@test "plugins ruby: remove_gem is defined" {
|
||||||
load ../../plugins/available/ruby.plugin
|
run load "${BASH_IT?}/plugins/available/ruby.plugin.bash"
|
||||||
|
assert_success
|
||||||
|
load "${BASH_IT?}/plugins/available/ruby.plugin.bash"
|
||||||
|
|
||||||
run type remove_gem
|
run type remove_gem
|
||||||
assert_line -n 1 "remove_gem () "
|
assert_line -n 1 "remove_gem () "
|
||||||
@@ -31,7 +22,9 @@ function local_teardown {
|
|||||||
|
|
||||||
mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
|
mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
|
||||||
|
|
||||||
load ../../plugins/available/ruby.plugin
|
run load "${BASH_IT?}/plugins/available/ruby.plugin.bash"
|
||||||
|
assert_success
|
||||||
|
load "${BASH_IT?}/plugins/available/ruby.plugin.bash"
|
||||||
|
|
||||||
local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")"
|
local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")"
|
||||||
[[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]]
|
[[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]]
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
load ../../plugins/available/xterm.plugin
|
function local_setup_file() {
|
||||||
|
setup_libs "helpers"
|
||||||
function local_setup {
|
load "${BASH_IT?}/plugins/available/xterm.plugin.bash"
|
||||||
setup_test_fixture
|
|
||||||
|
|
||||||
# Copy the test fixture to the Bash-it folder
|
|
||||||
if _command_exists rsync; then
|
|
||||||
rsync -a "$BASH_IT/test/fixtures/plugin/xterm/" "$BASH_IT/"
|
|
||||||
else
|
|
||||||
find "$BASH_IT/test/fixtures/plugin/xterm" \
|
|
||||||
-mindepth 1 -maxdepth 1 \
|
|
||||||
-exec cp -r {} "$BASH_IT/" \;
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins xterm: shorten command output" {
|
@test "plugins xterm: shorten command output" {
|
||||||
|
|||||||
20
test/run
20
test/run
@@ -2,17 +2,23 @@
|
|||||||
test_directory="$(cd "$(dirname "$0")" && pwd)"
|
test_directory="$(cd "$(dirname "$0")" && pwd)"
|
||||||
bats_executable="${test_directory}/../test_lib/bats-core/bin/bats"
|
bats_executable="${test_directory}/../test_lib/bats-core/bin/bats"
|
||||||
|
|
||||||
|
# Locate ourselves for easy reference.
|
||||||
|
export MAIN_BASH_IT_DIR="${test_directory%/*}"
|
||||||
|
export MAIN_BASH_IT_GITDIR="${MAIN_BASH_IT_DIR}/.git"
|
||||||
|
|
||||||
|
# Make sure BATS is available:
|
||||||
git submodule init && git submodule update
|
git submodule init && git submodule update
|
||||||
|
|
||||||
if [[ -z "${BASH_IT}" ]]; then
|
# Warn user that tests run from the current git HEAD
|
||||||
BASH_IT="$(cd "${test_directory}" && dirname "${PWD}")"
|
if ! git diff --quiet; then
|
||||||
export BASH_IT
|
echo "${BASH_SOURCE##*/}: your worktree is dirty; uncommitted changes will *not* be tested!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
# Which tests do we run?
|
||||||
|
if [[ $# -eq '0' ]]; then
|
||||||
test_dirs=("${test_directory}"/{bash_it,completion,install,lib,plugins,themes})
|
test_dirs=("${test_directory}"/{bash_it,completion,install,lib,plugins,themes})
|
||||||
else
|
else
|
||||||
test_dirs=("$1")
|
test_dirs=("$@")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure that the `parallel` command is installed,
|
# Make sure that the `parallel` command is installed,
|
||||||
@@ -38,8 +44,8 @@ if command -v parallel &> /dev/null \
|
|||||||
fi
|
fi
|
||||||
)"
|
)"
|
||||||
exec "$bats_executable" "${CI:+--tap}" --jobs "${test_jobs_effective}" \
|
exec "$bats_executable" "${CI:+--tap}" --jobs "${test_jobs_effective}" \
|
||||||
"${test_dirs[@]}"
|
--no-parallelize-within-files "${test_dirs[@]}"
|
||||||
else
|
else
|
||||||
# Run `bats` in single-threaded mode.
|
# Run `bats` in single-threaded mode.
|
||||||
exec "$bats_executable" ${CI:+--tap} "${test_dirs[@]}"
|
exec "$bats_executable" "${CI:+--tap}" "${test_dirs[@]}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
178
test/test_helper.bash
Executable file → Normal file
178
test/test_helper.bash
Executable file → Normal file
@@ -1,105 +1,117 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bash
|
||||||
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
|
||||||
|
|
||||||
unset BASH_IT_THEME
|
function setup_file() {
|
||||||
unset GIT_HOSTING
|
common_setup_file
|
||||||
unset NGINX_PATH
|
}
|
||||||
unset IRC_CLIENT
|
|
||||||
unset TODO
|
|
||||||
unset SCM_CHECK
|
|
||||||
unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE
|
|
||||||
|
|
||||||
export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.."
|
function common_setup_file() {
|
||||||
export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}"
|
# export *everything* to subshells, needed to support tests
|
||||||
|
set -a
|
||||||
|
|
||||||
# be independent of git's system configuration
|
# Locate ourselves for easy reference.
|
||||||
export GIT_CONFIG_NOSYSTEM
|
TEST_MAIN_DIR="${MAIN_BASH_IT_DIR:-${BATS_TEST_DIRNAME?}/../..}/test"
|
||||||
|
TEST_DEPS_DIR="${MAIN_BASH_IT_DIR:-${TEST_MAIN_DIR}/..}/test_lib"
|
||||||
|
|
||||||
|
# Load the BATS modules we use:
|
||||||
load "${TEST_DEPS_DIR}/bats-support/load.bash"
|
load "${TEST_DEPS_DIR}/bats-support/load.bash"
|
||||||
load "${TEST_DEPS_DIR}/bats-assert/load.bash"
|
load "${TEST_DEPS_DIR}/bats-assert/load.bash"
|
||||||
load "${TEST_DEPS_DIR}/bats-file/load.bash"
|
load "${TEST_DEPS_DIR}/bats-file/load.bash"
|
||||||
|
|
||||||
# support 'plumbing' metadata
|
# shellcheck disable=SC2034 # Clear any inherited environment:
|
||||||
cite _about _param _example _group _author _version
|
XDG_DUMMY="" BASH_IT_DUMMY="" # avoid possible invalid reference:
|
||||||
cite about-alias about-plugin about-completion
|
unset "${!XDG_@}" "${!BASH_IT@}" # unset all BASH_IT* and XDG_* variables
|
||||||
|
unset GIT_HOSTING NGINX_PATH IRC_CLIENT TODO SCM_CHECK
|
||||||
local_setup() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
local_teardown() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function sets up a local test fixture, i.e. a completely
|
|
||||||
# fresh and isolated Bash-it directory. This is done to avoid
|
|
||||||
# messing with your own Bash-it source directory.
|
|
||||||
# If you need this, call it in your .bats file's `local_setup` function.
|
|
||||||
setup_test_fixture() {
|
|
||||||
mkdir -p "$BASH_IT"
|
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
local src_topdir="$lib_directory/../../../.."
|
|
||||||
|
|
||||||
if command -v rsync &> /dev/null; then
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=helper.bash --exclude=enabled "$src_topdir" "$BASH_IT"
|
|
||||||
else
|
|
||||||
rm -rf "$BASH_IT"
|
|
||||||
mkdir -p "$BASH_IT"
|
|
||||||
|
|
||||||
find "$src_topdir" \
|
|
||||||
-mindepth 1 -maxdepth 1 \
|
|
||||||
-not -name .git \
|
|
||||||
-exec cp -r {} "$BASH_IT" \;
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
# Some tests use the BASH_IT_TEST_HOME variable, e.g. install/uninstall
|
|
||||||
export BASH_IT_TEST_HOME="$TEST_TEMP_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
# The `temp_make` function from "bats-file" requires the tralston/bats-file fork,
|
|
||||||
# since the original ztombol/bats-file's `temp_make` does not work on macOS.
|
|
||||||
TEST_TEMP_DIR="$(temp_make --prefix 'bash-it-test-')"
|
|
||||||
export TEST_TEMP_DIR
|
|
||||||
|
|
||||||
export BASH_IT_TEST_DIR="${TEST_TEMP_DIR}/.bash_it"
|
|
||||||
|
|
||||||
export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root"
|
|
||||||
export BASH_IT=$BASH_IT_TEST_DIR
|
|
||||||
|
|
||||||
mkdir -p -- "${BASH_IT_ROOT}"
|
|
||||||
|
|
||||||
# Some tools, e.g. `git` use configuration files from the $HOME directory,
|
# Some tools, e.g. `git` use configuration files from the $HOME directory,
|
||||||
# which interferes with our tests. The only way to keep `git` from doing this
|
# which interferes with our tests. The only way to keep `git` from doing
|
||||||
# seems to set HOME explicitly to a separate location.
|
# this seems to set HOME explicitly to a separate location.
|
||||||
# Refer to https://git-scm.com/docs/git-config#FILES.
|
# Refer to https://git-scm.com/docs/git-config#FILES.
|
||||||
unset XDG_CONFIG_HOME
|
readonly HOME="${BATS_SUITE_TMPDIR?}"
|
||||||
export HOME="${TEST_TEMP_DIR}"
|
|
||||||
mkdir -p "${HOME}"
|
mkdir -p "${HOME}"
|
||||||
|
|
||||||
# For `git` tests to run well, user name and email need to be set.
|
# For `git` tests to run well, user name and email need to be set.
|
||||||
# Refer to https://git-scm.com/docs/git-commit#_commit_information.
|
# Refer to https://git-scm.com/docs/git-commit#_commit_information.
|
||||||
# This goes to the test-specific config, due to the $HOME overridden above.
|
# This goes to the test-specific config, due to the $HOME overridden above.
|
||||||
git config --global user.name "John Doe"
|
git config --global user.name "Bash It BATS Runner"
|
||||||
git config --global user.email "johndoe@example.com"
|
git config --global user.email "bats@bash.it"
|
||||||
|
git config --global advice.detachedHead false
|
||||||
|
git config --global init.defaultBranch "master"
|
||||||
|
|
||||||
|
# Locate the temporary folder, avoid double-slash.
|
||||||
|
BASH_IT="${BATS_FILE_TMPDIR//\/\///}/.bash_it"
|
||||||
|
|
||||||
|
# This sets up a local test fixture, i.e. a completely fresh and isolated Bash-it directory. This is done to avoid messing with your own Bash-it source directory.
|
||||||
|
git --git-dir="${MAIN_BASH_IT_GITDIR?}" worktree add -d "${BASH_IT}"
|
||||||
|
|
||||||
|
load "${BASH_IT?}/vendor/github.com/erichs/composure/composure.sh"
|
||||||
|
# support 'plumbing' metadata
|
||||||
|
cite _about _param _example _group _author _version
|
||||||
|
cite about-alias about-plugin about-completion
|
||||||
|
|
||||||
|
# Run any local test setup
|
||||||
|
local_setup_file
|
||||||
|
set +a # not needed, but symetiric!
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load standard _Bash It_ libraries
|
||||||
|
function setup_libs() {
|
||||||
|
local lib
|
||||||
|
# Use a loop to allow convenient short-circuiting for some test files
|
||||||
|
for lib in "log" "utilities" "helpers" "search" "preexec" "colors" "command_duration"; do
|
||||||
|
load "${BASH_IT?}/lib/${lib}.bash" || return
|
||||||
|
# shellcheck disable=SC2015 # short-circuit if we've reached the requested library
|
||||||
|
[[ "${lib}" == "${1:-}" ]] && return 0 || true
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_setup_file() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_setup() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
function local_teardown() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_test_fixture() {
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/enabled"
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/aliases/enabled"
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/completion/enabled"
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/plugins/enabled"
|
||||||
|
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/tmp/cache"
|
||||||
|
rm -rf "${BASH_IT_CONFIG?}/profiles"/test*.bash_it
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_test_fixture() {
|
||||||
|
mkdir -p "${BASH_IT_CONFIG?}/enabled"
|
||||||
|
mkdir -p "${BASH_IT_CONFIG?}/aliases/enabled"
|
||||||
|
mkdir -p "${BASH_IT_CONFIG?}/completion/enabled"
|
||||||
|
mkdir -p "${BASH_IT_CONFIG?}/plugins/enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
# be independent of git's system configuration
|
||||||
|
export GIT_CONFIG_NOSYSTEM
|
||||||
|
# Locate the temporary folder:
|
||||||
|
BASH_IT_CONFIG="${BASH_IT?}" #"${BATS_TEST_TMPDIR//\/\///}"
|
||||||
|
export XDG_CACHE_HOME="${BATS_TEST_TMPDIR?}"
|
||||||
|
|
||||||
|
setup_test_fixture
|
||||||
local_setup
|
local_setup
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
function teardown() {
|
||||||
|
unset GIT_CONFIG_NOSYSTEM
|
||||||
local_teardown
|
local_teardown
|
||||||
|
clean_test_fixture
|
||||||
rm -rf "${BASH_IT_TEST_DIR}"
|
}
|
||||||
temp_del "${TEST_TEMP_DIR}"
|
|
||||||
|
function teardown_file() {
|
||||||
|
# This only serves to clean metadata from the real git repo.
|
||||||
|
git --git-dir="${MAIN_BASH_IT_GITDIR?}" worktree remove -f "${BASH_IT?}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
load "${BASH_IT}/lib/log.bash"
|
|
||||||
load "${BASH_IT}/lib/utilities.bash"
|
|
||||||
load "${BASH_IT}/lib/helpers.bash"
|
|
||||||
load "${BASH_IT}/lib/search.bash"
|
|
||||||
load "${BASH_IT}/lib/preexec.bash"
|
|
||||||
load "${BASH_IT}/lib/colors.bash"
|
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
load ../../themes/base.theme
|
function local_setup_file() {
|
||||||
|
setup_libs "colors" #"theme"
|
||||||
|
load "${BASH_IT?}/themes/base.theme.bash"
|
||||||
|
}
|
||||||
|
|
||||||
@test 'themes base: battery_percentage should not exist' {
|
@test 'themes base: battery_percentage should not exist' {
|
||||||
run type -a battery_percentage &> /dev/null
|
run type -a battery_percentage &> /dev/null
|
||||||
@@ -10,7 +13,7 @@ load ../../themes/base.theme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test 'themes base: battery_percentage should exist if battery plugin loaded' {
|
@test 'themes base: battery_percentage should exist if battery plugin loaded' {
|
||||||
load ../../plugins/available/battery.plugin
|
load "${BASH_IT?}/plugins/available/battery.plugin.bash"
|
||||||
|
|
||||||
run type -a battery_percentage &> /dev/null
|
run type -a battery_percentage &> /dev/null
|
||||||
assert_success
|
assert_success
|
||||||
@@ -28,12 +31,12 @@ load ../../themes/base.theme
|
|||||||
@test 'themes base: battery_char should exist if battery plugin loaded' {
|
@test 'themes base: battery_char should exist if battery plugin loaded' {
|
||||||
unset -f battery_char
|
unset -f battery_char
|
||||||
|
|
||||||
load ../../plugins/available/battery.plugin
|
load "${BASH_IT?}/plugins/available/battery.plugin.bash"
|
||||||
run type -t battery_percentage
|
run type -t battery_percentage
|
||||||
assert_success
|
assert_success
|
||||||
assert_line "function"
|
assert_line "function"
|
||||||
|
|
||||||
load ../../themes/base.theme
|
load "${BASH_IT?}/themes/base.theme.bash"
|
||||||
run type -t battery_char
|
run type -t battery_char
|
||||||
assert_success
|
assert_success
|
||||||
assert_line "function"
|
assert_line "function"
|
||||||
@@ -51,13 +54,13 @@ load ../../themes/base.theme
|
|||||||
|
|
||||||
run battery_charge
|
run battery_charge
|
||||||
assert_success
|
assert_success
|
||||||
assert_line -n 0 ""
|
assert_output ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'themes base: battery_charge should exist if battery plugin loaded' {
|
@test 'themes base: battery_charge should exist if battery plugin loaded' {
|
||||||
unset -f battery_charge
|
unset -f battery_charge
|
||||||
load ../../plugins/available/battery.plugin
|
load "${BASH_IT?}/plugins/available/battery.plugin.bash"
|
||||||
load ../../themes/base.theme
|
load "${BASH_IT?}/themes/base.theme.bash"
|
||||||
|
|
||||||
run type -a battery_charge &> /dev/null
|
run type -a battery_charge &> /dev/null
|
||||||
assert_success
|
assert_success
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
load ../../themes/githelpers.theme
|
function local_setup_file() {
|
||||||
load ../../themes/base.theme
|
setup_libs "colors" #"theme"
|
||||||
|
load "${BASH_IT?}/themes/base.theme.bash"
|
||||||
|
load "${BASH_IT?}/themes/githelpers.theme.bash"
|
||||||
|
}
|
||||||
|
|
||||||
add_commit() {
|
add_commit() {
|
||||||
local file_name="general-${RANDOM}"
|
local file_name="general-${RANDOM}"
|
||||||
|
|||||||
@@ -1,29 +1,10 @@
|
|||||||
#!/usr/bin/env bats
|
# shellcheck shell=bats
|
||||||
|
|
||||||
load ../test_helper
|
load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"
|
||||||
load ../test_helper_libs
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup_file() {
|
||||||
setup_test_fixture
|
setup_libs "colors" #"theme"
|
||||||
|
load "${BASH_IT?}/themes/base.theme.bash"
|
||||||
# Copy the test fixture to the Bash-it folder
|
|
||||||
if command -v rsync &> /dev/null
|
|
||||||
then
|
|
||||||
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
|
||||||
else
|
|
||||||
find "$BASH_IT/test/fixtures/bash_it" \
|
|
||||||
-mindepth 1 -maxdepth 1 \
|
|
||||||
-exec cp -r {} "$BASH_IT/" \;
|
|
||||||
fi
|
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
|
||||||
|
|
||||||
load ../../themes/base.theme
|
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export PATH="$OLD_PATH"
|
|
||||||
unset OLD_PATH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_repo {
|
function setup_repo {
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
|
|
||||||
|
# Colors for listing files, using default color scheme.
|
||||||
|
# To customize color scheme by theme, check out https://geoff.greer.fm/lscolors/
|
||||||
|
export CLICOLOR LSCOLORS LS_COLORS
|
||||||
|
|
||||||
CLOCK_CHAR_THEME_PROMPT_PREFIX=''
|
CLOCK_CHAR_THEME_PROMPT_PREFIX=''
|
||||||
CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
|
CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
|
||||||
CLOCK_THEME_PROMPT_PREFIX=''
|
CLOCK_THEME_PROMPT_PREFIX=''
|
||||||
CLOCK_THEME_PROMPT_SUFFIX=''
|
CLOCK_THEME_PROMPT_SUFFIX=''
|
||||||
|
|
||||||
THEME_PROMPT_HOST='\H'
|
THEME_PROMPT_HOST='\h'
|
||||||
|
|
||||||
SCM=
|
SCM=
|
||||||
|
|
||||||
SCM_CHECK=${SCM_CHECK:=true}
|
: "${SCM_CHECK:=true}"
|
||||||
|
|
||||||
SCM_THEME_PROMPT_DIRTY=' ✗'
|
SCM_THEME_PROMPT_DIRTY=' ✗'
|
||||||
SCM_THEME_PROMPT_CLEAN=' ✓'
|
SCM_THEME_PROMPT_CLEAN=' ✓'
|
||||||
@@ -30,15 +34,15 @@ SCM_THEME_CHAR_SUFFIX=''
|
|||||||
: "${THEME_CHECK_SUDO:=false}"
|
: "${THEME_CHECK_SUDO:=false}"
|
||||||
: "${THEME_BATTERY_PERCENTAGE_CHECK:=true}"
|
: "${THEME_BATTERY_PERCENTAGE_CHECK:=true}"
|
||||||
|
|
||||||
SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true}
|
: "${SCM_GIT_SHOW_DETAILS:=true}"
|
||||||
SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
|
: "${SCM_GIT_SHOW_REMOTE_INFO:=auto}"
|
||||||
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
|
: "${SCM_GIT_IGNORE_UNTRACKED:=false}"
|
||||||
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false}
|
: "${SCM_GIT_SHOW_CURRENT_USER:=false}"
|
||||||
SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false}
|
: "${SCM_GIT_SHOW_MINIMAL_INFO:=false}"
|
||||||
SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true}
|
: "${SCM_GIT_SHOW_STASH_INFO:=true}"
|
||||||
SCM_GIT_SHOW_COMMIT_COUNT=${SCM_GIT_SHOW_COMMIT_COUNT:=true}
|
: "${SCM_GIT_SHOW_COMMIT_COUNT:=true}"
|
||||||
SCM_GIT_USE_GITSTATUS=${SCM_GIT_USE_GITSTATUS:=false}
|
: "${SCM_GIT_USE_GITSTATUS:=false}"
|
||||||
SCM_GIT_GITSTATUS_RAN=${SCM_GIT_GITSTATUS_RAN:=false}
|
: "${SCM_GIT_GITSTATUS_RAN:=false}"
|
||||||
|
|
||||||
SCM_GIT='git'
|
SCM_GIT='git'
|
||||||
SCM_GIT_CHAR='±'
|
SCM_GIT_CHAR='±'
|
||||||
@@ -73,9 +77,9 @@ NVM_THEME_PROMPT_SUFFIX='|'
|
|||||||
RVM_THEME_PROMPT_PREFIX=' |'
|
RVM_THEME_PROMPT_PREFIX=' |'
|
||||||
RVM_THEME_PROMPT_SUFFIX='|'
|
RVM_THEME_PROMPT_SUFFIX='|'
|
||||||
|
|
||||||
THEME_SHOW_RUBY_PROMPT=${THEME_SHOW_RUBY_PROMPT:=true}
|
: "${THEME_SHOW_RUBY_PROMPT:=true}"
|
||||||
|
|
||||||
THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
|
: "${THEME_SHOW_USER_HOST:=false}"
|
||||||
USER_HOST_THEME_PROMPT_PREFIX=''
|
USER_HOST_THEME_PROMPT_PREFIX=''
|
||||||
USER_HOST_THEME_PROMPT_SUFFIX=''
|
USER_HOST_THEME_PROMPT_SUFFIX=''
|
||||||
|
|
||||||
@@ -88,154 +92,160 @@ RBENV_THEME_PROMPT_SUFFIX='|'
|
|||||||
RBFU_THEME_PROMPT_PREFIX=' |'
|
RBFU_THEME_PROMPT_PREFIX=' |'
|
||||||
RBFU_THEME_PROMPT_SUFFIX='|'
|
RBFU_THEME_PROMPT_SUFFIX='|'
|
||||||
|
|
||||||
: "${GIT_EXE:=$SCM_GIT}"
|
: "${GIT_EXE:=${SCM_GIT?}}"
|
||||||
: "${P4_EXE:=$SCM_P4}"
|
: "${HG_EXE:=${SCM_HG?}}"
|
||||||
: "${HG_EXE:=$SCM_HG}"
|
: "${SVN_EXE:=${SCM_SVN?}}"
|
||||||
: "${SVN_EXE:=$SCM_SVN}"
|
: "${P4_EXE:=${SCM_P4?}}"
|
||||||
|
|
||||||
function _bash_it_appearance_scm_init() {
|
function _bash_it_appearance_scm_init() {
|
||||||
GIT_EXE="$(type -P $SCM_GIT || true)"
|
GIT_EXE="$(type -P "${SCM_GIT:-git}" || true)"
|
||||||
P4_EXE="$(type -P $SCM_P4 || true)"
|
HG_EXE="$(type -P "${SCM_HG:-hg}" || true)"
|
||||||
HG_EXE="$(type -P $SCM_HG || true)"
|
SVN_EXE="$(type -P "${SCM_SVN:-svn}" || true)"
|
||||||
SVN_EXE="$(type -P $SCM_SVN || true)"
|
P4_EXE="$(type -P "${SCM_P4:-p4}" || true)"
|
||||||
|
|
||||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||||
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
if [[ -x "${SVN_EXE-}" && -x "${SVN_EXE%/svn}/xcrun" ]]; then
|
||||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
if ! "${SVN_EXE}" --version > /dev/null 2>&1; then
|
||||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||||
SVN_EXE=""
|
SVN_EXE=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')
|
_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')
|
||||||
|
|
||||||
function scm {
|
function scm() {
|
||||||
if [[ "$SCM_CHECK" = false ]]; then
|
if [[ "${SCM_CHECK:-true}" == "false" ]]; then
|
||||||
SCM=$SCM_NONE
|
SCM="${SCM_NONE-NONE}"
|
||||||
elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then
|
elif [[ -x "${GIT_EXE-}" ]] && _bash-it-find-in-ancestor '.git' > /dev/null; then
|
||||||
SCM=$SCM_GIT
|
SCM="${SCM_GIT?}"
|
||||||
elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then
|
elif [[ -x "${HG_EXE-}" ]] && _bash-it-find-in-ancestor '.hg' > /dev/null; then
|
||||||
SCM=$SCM_HG
|
SCM="${SCM_HG?}"
|
||||||
elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then
|
elif [[ -x "${SVN_EXE-}" ]] && _bash-it-find-in-ancestor '.svn' > /dev/null; then
|
||||||
SCM=$SCM_SVN
|
SCM="${SCM_SVN?}"
|
||||||
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
|
elif [[ -x "${P4_EXE-}" && -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
|
||||||
SCM=$SCM_GIT
|
SCM="${SCM_P4?}"
|
||||||
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
|
|
||||||
SCM=$SCM_HG
|
|
||||||
elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2> /dev/null)" ]]; then
|
|
||||||
SCM=$SCM_SVN
|
|
||||||
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
|
|
||||||
SCM=$SCM_P4
|
|
||||||
else
|
else
|
||||||
SCM=$SCM_NONE
|
SCM="${SCM_NONE-NONE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
scm_prompt() {
|
function scm_prompt() {
|
||||||
local CHAR
|
local format="${SCM_PROMPT_FORMAT-"[%s%s]"}"
|
||||||
CHAR="$(scm_char)"
|
local scm_char scm_prompt_info
|
||||||
local format=${SCM_PROMPT_FORMAT:-'[%s%s]'}
|
scm_char="$(scm_char)"
|
||||||
|
scm_prompt_info="$(scm_prompt_info)"
|
||||||
|
|
||||||
if [[ "${CHAR}" != "$SCM_NONE_CHAR" ]]; then
|
if [[ "${scm_char}" != "${SCM_NONE_CHAR:-}" ]]; then
|
||||||
# shellcheck disable=2059
|
# shellcheck disable=2059
|
||||||
printf "$format\n" "$CHAR" "$(scm_prompt_info)"
|
printf "${format}" "${scm_char}" "${scm_prompt_info}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_prompt_char {
|
function scm_prompt_char() {
|
||||||
if [[ -z $SCM ]]; then scm; fi
|
if [[ -z "${SCM:-}" ]]; then
|
||||||
if [[ $SCM == "$SCM_GIT" ]]; then
|
scm
|
||||||
SCM_CHAR=$SCM_GIT_CHAR
|
|
||||||
elif [[ $SCM == "$SCM_P4" ]]; then
|
|
||||||
SCM_CHAR=$SCM_P4_CHAR
|
|
||||||
elif [[ $SCM == "$SCM_HG" ]]; then
|
|
||||||
SCM_CHAR=$SCM_HG_CHAR
|
|
||||||
elif [[ $SCM == "$SCM_SVN" ]]; then
|
|
||||||
SCM_CHAR=$SCM_SVN_CHAR
|
|
||||||
else
|
|
||||||
SCM_CHAR=$SCM_NONE_CHAR
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case ${SCM?} in
|
||||||
|
"${SCM_GIT?}")
|
||||||
|
SCM_CHAR="${SCM_GIT_CHAR?}"
|
||||||
|
;;
|
||||||
|
"${SCM_HG?}")
|
||||||
|
SCM_CHAR="${SCM_HG_CHAR?}"
|
||||||
|
;;
|
||||||
|
"${SCM_SVN?}")
|
||||||
|
SCM_CHAR="${SCM_SVN_CHAR?}"
|
||||||
|
;;
|
||||||
|
"${SCM_P4?}")
|
||||||
|
SCM_CHAR="${SCM_P4_CHAR?}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
SCM_CHAR="${SCM_NONE_CHAR:-}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_prompt_vars {
|
function scm_prompt_vars() {
|
||||||
scm
|
scm
|
||||||
scm_prompt_char
|
scm_prompt_char
|
||||||
SCM_DIRTY=0
|
SCM_DIRTY=0
|
||||||
SCM_STATE=''
|
SCM_STATE=''
|
||||||
[[ $SCM == "$SCM_GIT" ]] && git_prompt_vars && return
|
|
||||||
[[ $SCM == "$SCM_P4" ]] && p4_prompt_vars && return
|
local prompt_vars="${SCM}_prompt_vars"
|
||||||
[[ $SCM == "$SCM_HG" ]] && hg_prompt_vars && return
|
_is_function "${prompt_vars}" && "${prompt_vars}"
|
||||||
[[ $SCM == "$SCM_SVN" ]] && svn_prompt_vars && return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_prompt_info {
|
function scm_prompt_info() {
|
||||||
scm
|
scm
|
||||||
scm_prompt_char
|
scm_prompt_char
|
||||||
scm_prompt_info_common
|
scm_prompt_info_common
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_prompt_char_info {
|
function scm_prompt_char_info() {
|
||||||
scm_prompt_char
|
scm_prompt_char
|
||||||
echo -ne "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
echo -ne "${SCM_THEME_CHAR_PREFIX-}${SCM_CHAR?}${SCM_THEME_CHAR_SUFFIX-}"
|
||||||
scm_prompt_info_common
|
scm_prompt_info_common
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_prompt_info_common {
|
function scm_prompt_info_common() {
|
||||||
|
local prompt_info
|
||||||
SCM_DIRTY=0
|
SCM_DIRTY=0
|
||||||
SCM_STATE=''
|
SCM_STATE=''
|
||||||
|
|
||||||
if [[ ${SCM} == "${SCM_GIT}" ]]; then
|
case ${SCM?} in
|
||||||
if [[ ${SCM_GIT_SHOW_MINIMAL_INFO} == true ]]; then
|
"${SCM_GIT?}")
|
||||||
|
if [[ ${SCM_GIT_SHOW_MINIMAL_INFO:-false} == "true" ]]; then
|
||||||
# user requests minimal git status information
|
# user requests minimal git status information
|
||||||
git_prompt_minimal_info
|
prompt_info="${SCM}_prompt_minimal_info"
|
||||||
else
|
else
|
||||||
# more detailed git status
|
# more detailed git status
|
||||||
git_prompt_info
|
prompt_info="${SCM}_prompt_info"
|
||||||
fi
|
fi
|
||||||
return
|
;;
|
||||||
fi
|
*)
|
||||||
|
|
||||||
# TODO: consider adding minimal status information for hg and svn
|
# TODO: consider adding minimal status information for hg and svn
|
||||||
{ [[ ${SCM} == "${SCM_P4}" ]] && p4_prompt_info && return; } || true
|
prompt_info="${SCM}_prompt_info"
|
||||||
{ [[ ${SCM} == "${SCM_HG}" ]] && hg_prompt_info && return; } || true
|
;;
|
||||||
{ [[ ${SCM} == "${SCM_SVN}" ]] && svn_prompt_info && return; } || true
|
esac
|
||||||
|
_is_function "${prompt_info}" && "${prompt_info}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function terraform_workspace_prompt {
|
function terraform_workspace_prompt() {
|
||||||
if _command_exists terraform; then
|
if _command_exists terraform; then
|
||||||
if [ -d .terraform ]; then
|
if [[ -d .terraform ]]; then
|
||||||
echo -e "$(terraform workspace show 2> /dev/null)"
|
terraform workspace show 2> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function active_gcloud_account_prompt {
|
function active_gcloud_account_prompt() {
|
||||||
if _command_exists gcloud; then
|
if _command_exists gcloud; then
|
||||||
echo -e "$(gcloud config list account --format "value(core.account)" 2> /dev/null)"
|
gcloud config list account --format "value(core.account)" 2> /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_minimal_info {
|
function git_prompt_minimal_info() {
|
||||||
SCM_STATE=${SCM_THEME_PROMPT_CLEAN}
|
SCM_STATE="${SCM_THEME_PROMPT_CLEAN?}"
|
||||||
|
|
||||||
_git-hide-status && return
|
_git-hide-status && return
|
||||||
|
|
||||||
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}\$(_git-friendly-ref)"
|
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX-}\$(_git-friendly-ref)"
|
||||||
|
|
||||||
if [[ -n "$(_git-status | tail -n1)" ]]; then
|
if [[ -n "$(_git-status | tail -n1)" ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the git prompt
|
# Output the git prompt
|
||||||
SCM_PREFIX=${SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX="${SCM_THEME_PROMPT_PREFIX-}"
|
||||||
SCM_SUFFIX=${SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX="${SCM_THEME_PROMPT_SUFFIX-}"
|
||||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
echo -ne "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_vars {
|
function git_prompt_vars() {
|
||||||
if ${SCM_GIT_USE_GITSTATUS} && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT}" == "ok-sync" ]]; then
|
if [[ "${SCM_GIT_USE_GITSTATUS:-false}" != "false" ]] && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]]; then
|
||||||
# we can use faster gitstatus
|
# we can use faster gitstatus
|
||||||
# use this variable in githelpers and below to choose gitstatus output
|
# use this variable in githelpers and below to choose gitstatus output
|
||||||
SCM_GIT_GITSTATUS_RAN=true
|
SCM_GIT_GITSTATUS_RAN=true
|
||||||
@@ -251,190 +261,174 @@ function git_prompt_vars {
|
|||||||
|
|
||||||
local detached_prefix
|
local detached_prefix
|
||||||
if _git-tag &> /dev/null; then
|
if _git-tag &> /dev/null; then
|
||||||
detached_prefix=${SCM_THEME_TAG_PREFIX}
|
detached_prefix="${SCM_THEME_TAG_PREFIX}"
|
||||||
else
|
else
|
||||||
detached_prefix=${SCM_THEME_DETACHED_PREFIX}
|
detached_prefix="${SCM_THEME_DETACHED_PREFIX}"
|
||||||
fi
|
fi
|
||||||
SCM_BRANCH="${detached_prefix}\$(_git-friendly-ref)"
|
SCM_BRANCH="${detached_prefix}\$(_git-friendly-ref)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
commits_behind=${VCS_STATUS_COMMITS_BEHIND}
|
commits_behind="${VCS_STATUS_COMMITS_BEHIND?}"
|
||||||
commits_ahead=${VCS_STATUS_COMMITS_AHEAD}
|
commits_ahead="${VCS_STATUS_COMMITS_AHEAD?}"
|
||||||
else
|
else
|
||||||
IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)"
|
IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)"
|
||||||
fi
|
fi
|
||||||
if [[ "${commits_ahead}" -gt 0 ]]; then
|
if [[ "${commits_ahead}" -gt 0 ]]; then
|
||||||
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}"
|
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}"
|
||||||
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" = "true" ]] && SCM_BRANCH+="${commits_ahead}"
|
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_ahead}"
|
||||||
fi
|
fi
|
||||||
if [[ "${commits_behind}" -gt 0 ]]; then
|
if [[ "${commits_behind}" -gt 0 ]]; then
|
||||||
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}"
|
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}"
|
||||||
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" = "true" ]] && SCM_BRANCH+="${commits_behind}"
|
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_behind}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
|
if [[ "${SCM_GIT_SHOW_STASH_INFO}" == "true" ]]; then
|
||||||
local stash_count
|
local stash_count
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
||||||
stash_count=${VCS_STATUS_STASHES}
|
stash_count="${VCS_STATUS_STASHES?}"
|
||||||
else
|
else
|
||||||
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
|
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
|
||||||
fi
|
fi
|
||||||
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
|
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
SCM_STATE="${GIT_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN:-}}"
|
||||||
if ! _git-hide-status; then
|
if ! _git-hide-status; then
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
untracked_count=${VCS_STATUS_NUM_UNTRACKED}
|
untracked_count="${VCS_STATUS_NUM_UNTRACKED?}"
|
||||||
unstaged_count=${VCS_STATUS_NUM_UNSTAGED}
|
unstaged_count="${VCS_STATUS_NUM_UNSTAGED?}"
|
||||||
staged_count=${VCS_STATUS_NUM_STAGED}
|
staged_count="${VCS_STATUS_NUM_STAGED?}"
|
||||||
else
|
else
|
||||||
IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$(_git-status-counts)"
|
IFS=$'\t' read -r untracked_count unstaged_count staged_count < <(_git-status-counts)
|
||||||
fi
|
fi
|
||||||
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
|
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then
|
if [[ "${SCM_GIT_SHOW_DETAILS}" == "true" ]]; then
|
||||||
[[ "${staged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
|
[[ "${staged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
|
||||||
[[ "${unstaged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
|
[[ "${unstaged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
|
||||||
[[ "${untracked_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
|
[[ "${untracked_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
|
||||||
fi
|
fi
|
||||||
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${GIT_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# no if for gitstatus here, user extraction is not supported by it
|
# no if for gitstatus here, user extraction is not supported by it
|
||||||
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && SCM_BRANCH+="$(git_user_info)"
|
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && SCM_BRANCH+="$(git_user_info)"
|
||||||
|
|
||||||
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX="${GIT_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
|
||||||
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX="${GIT_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
|
||||||
|
|
||||||
SCM_CHANGE=$(_git-short-sha 2> /dev/null || echo "")
|
SCM_CHANGE=$(_git-short-sha 2> /dev/null || true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function p4_prompt_vars {
|
function p4_prompt_vars() {
|
||||||
|
local opened_count non_default_changes default_count \
|
||||||
|
add_file_count edit_file_count delete_file_count
|
||||||
|
|
||||||
IFS=$'\t' read -r \
|
IFS=$'\t' read -r \
|
||||||
opened_count non_default_changes default_count \
|
opened_count non_default_changes default_count \
|
||||||
add_file_count edit_file_count delete_file_count \
|
add_file_count edit_file_count delete_file_count \
|
||||||
<<< "$(_p4-opened-counts)"
|
< <(_p4-opened-counts)
|
||||||
if [[ "${opened_count}" -gt 0 ]]; then
|
if [[ "${opened_count}" -gt 0 ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}"
|
||||||
[[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR}${opened_count}"
|
[[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR?}${opened_count}"
|
||||||
[[ "${non_default_changes}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_CHANGES_CHAR}${non_default_changes}"
|
[[ "${non_default_changes}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_CHANGES_CHAR?}${non_default_changes}"
|
||||||
[[ "${default_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_DEFAULT_CHAR}${default_count}"
|
[[ "${default_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_DEFAULT_CHAR?}${default_count}"
|
||||||
else
|
else
|
||||||
SCM_DIRTY=0
|
SCM_DIRTY=0
|
||||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${SCM_THEME_PROMPT_CLEAN?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCM_PREFIX=${P4_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX="${P4_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
|
||||||
SCM_SUFFIX=${P4_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX="${P4_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function svn_prompt_vars {
|
function svn_prompt_vars() {
|
||||||
if [[ -n $(svn status | head -c1 2> /dev/null) ]]; then
|
if [[ -n "$(svn status | head -c1 2> /dev/null)" ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
SCM_STATE=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${SVN_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
|
||||||
else
|
else
|
||||||
SCM_DIRTY=0
|
SCM_DIRTY=0
|
||||||
SCM_STATE=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
SCM_STATE="${SVN_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN?}}"
|
||||||
fi
|
fi
|
||||||
SCM_PREFIX=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX="${SVN_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
|
||||||
SCM_SUFFIX=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX="${SVN_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
|
||||||
SCM_BRANCH=$(svn info --show-item=url 2> /dev/null | awk -F/ '{ for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return
|
SCM_BRANCH="$(svn info --show-item=url 2> /dev/null | awk -F/ '{ for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }')" || return
|
||||||
SCM_CHANGE=$(svn info --show-item=revision 2> /dev/null)
|
SCM_CHANGE="$(svn info --show-item=revision 2> /dev/null)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# this functions returns absolute location of .hg directory if one exists
|
function hg_prompt_vars() {
|
||||||
# It starts in the current directory and moves its way up until it hits /.
|
local hg_root bookmark
|
||||||
# If we get to / then no Mercurial repository was found.
|
|
||||||
# Example:
|
|
||||||
# - lets say we cd into ~/Projects/Foo/Bar
|
|
||||||
# - .hg is located in ~/Projects/Foo/.hg
|
|
||||||
# - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo
|
|
||||||
function get_hg_root {
|
|
||||||
local CURRENT_DIR="${PWD}"
|
|
||||||
|
|
||||||
while [[ "${CURRENT_DIR:-/}" != "/" ]]; do
|
|
||||||
if [[ -d "$CURRENT_DIR/.hg" ]]; then
|
|
||||||
echo "$CURRENT_DIR/.hg"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
CURRENT_DIR="${CURRENT_DIR%/*}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function hg_prompt_vars {
|
|
||||||
if [[ -n $(hg status 2> /dev/null) ]]; then
|
if [[ -n $(hg status 2> /dev/null) ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
SCM_STATE=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE="${HG_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
|
||||||
else
|
else
|
||||||
SCM_DIRTY=0
|
SCM_DIRTY=0
|
||||||
SCM_STATE=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
SCM_STATE="${HG_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN?}}"
|
||||||
fi
|
fi
|
||||||
SCM_PREFIX=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX="${HG_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
|
||||||
SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX="${HG_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
|
||||||
|
|
||||||
HG_ROOT=$(get_hg_root)
|
hg_root="$(_bash-it-find-in-ancestor ".hg")/.hg"
|
||||||
|
|
||||||
if [ -f "$HG_ROOT/branch" ]; then
|
if [[ -f "$hg_root/branch" ]]; then
|
||||||
# Mercurial holds it's current branch in .hg/branch file
|
# Mercurial holds it's current branch in .hg/branch file
|
||||||
SCM_BRANCH=$(< "${HG_ROOT}/branch")
|
SCM_BRANCH=$(< "${hg_root}/branch")
|
||||||
local bookmark=${HG_ROOT}/bookmarks.current
|
bookmark="${hg_root}/bookmarks.current"
|
||||||
[[ -f ${bookmark} ]] && SCM_BRANCH+=:$(< "${bookmark}")
|
[[ -f "${bookmark}" ]] && SCM_BRANCH+=:$(< "${bookmark}")
|
||||||
else
|
else
|
||||||
SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}')
|
SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$HG_ROOT/dirstate" ]; then
|
if [[ -f "$hg_root/dirstate" ]]; then
|
||||||
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
|
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
|
||||||
SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12)
|
SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$hg_root/dirstate" | cut -c-12)
|
||||||
else
|
else
|
||||||
SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}')
|
SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}')
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function nvm_version_prompt {
|
function nvm_version_prompt() {
|
||||||
local node
|
local node
|
||||||
if _is_function nvm; then
|
if _is_function nvm; then
|
||||||
node=$(nvm current 2> /dev/null)
|
node=$(nvm current 2> /dev/null)
|
||||||
[[ "${node}" == "system" ]] && return
|
[[ "${node}" == "system" ]] && return
|
||||||
echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}"
|
echo -ne "${NVM_THEME_PROMPT_PREFIX-}${node}${NVM_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function node_version_prompt {
|
function node_version_prompt() {
|
||||||
echo -e "$(nvm_version_prompt)"
|
nvm_version_prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function rvm_version_prompt {
|
function rvm_version_prompt() {
|
||||||
if which rvm &> /dev/null; then
|
if _command_exists rvm; then
|
||||||
rvm=$(rvm-prompt) || return
|
rvm="$(rvm-prompt)" || return
|
||||||
if [ -n "$rvm" ]; then
|
if [[ -n "$rvm" ]]; then
|
||||||
echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX"
|
echo -ne "${RVM_THEME_PROMPT_PREFIX-}${rvm}${RVM_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function rbenv_version_prompt {
|
function rbenv_version_prompt() {
|
||||||
if which rbenv &> /dev/null; then
|
if _command_exists rbenv; then
|
||||||
rbenv=$(rbenv version-name) || return
|
rbenv=$(rbenv version-name) || return
|
||||||
rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}"
|
rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}"
|
||||||
if [ "$rbenv" != "system" ]; then
|
if [[ "$rbenv" != "system" ]]; then
|
||||||
echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX"
|
echo -ne "${RBENV_THEME_PROMPT_PREFIX-}${rbenv}${RBENV_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function rbfu_version_prompt {
|
function rbfu_version_prompt() {
|
||||||
if [[ $RBFU_RUBY_VERSION ]]; then
|
if [[ -n "${RBFU_RUBY_VERSION:-}" ]]; then
|
||||||
echo -e "${RBFU_THEME_PROMPT_PREFIX}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX}"
|
echo -ne "${RBFU_THEME_PROMPT_PREFIX-}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function chruby_version_prompt {
|
function chruby_version_prompt() {
|
||||||
if _is_function chruby; then
|
if _is_function chruby; then
|
||||||
if _is_function chruby_auto; then
|
if _is_function chruby_auto; then
|
||||||
chruby_auto
|
chruby_auto
|
||||||
@@ -445,141 +439,142 @@ function chruby_version_prompt {
|
|||||||
if ! chruby | grep -q '\*'; then
|
if ! chruby | grep -q '\*'; then
|
||||||
ruby_version="${ruby_version} (system)"
|
ruby_version="${ruby_version} (system)"
|
||||||
fi
|
fi
|
||||||
echo -e "${CHRUBY_THEME_PROMPT_PREFIX}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX}"
|
echo -ne "${CHRUBY_THEME_PROMPT_PREFIX-}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ruby_version_prompt {
|
function ruby_version_prompt() {
|
||||||
if [[ "${THEME_SHOW_RUBY_PROMPT}" = "true" ]]; then
|
if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]]; then
|
||||||
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
|
rbfu_version_prompt
|
||||||
|
rbenv_version_prompt
|
||||||
|
rvm_version_prompt
|
||||||
|
chruby_version_prompt
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function k8s_context_prompt {
|
function k8s_context_prompt() {
|
||||||
echo -e "$(kubectl config current-context 2> /dev/null)"
|
kubectl config current-context 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function k8s_namespace_prompt {
|
function k8s_namespace_prompt() {
|
||||||
echo -e "$(kubectl config view --minify --output 'jsonpath={..namespace}' 2> /dev/null)"
|
kubectl config view --minify --output 'jsonpath={..namespace}' 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function virtualenv_prompt {
|
function virtualenv_prompt() {
|
||||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
local virtualenv
|
||||||
virtualenv=$(basename "$VIRTUAL_ENV")
|
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
|
||||||
echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX"
|
virtualenv="${VIRTUAL_ENV##*/}"
|
||||||
|
echo -ne "${VIRTUALENV_THEME_PROMPT_PREFIX-}${virtualenv}${VIRTUALENV_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function condaenv_prompt {
|
function condaenv_prompt() {
|
||||||
if [[ $CONDA_DEFAULT_ENV ]]; then
|
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
|
||||||
echo -e "${CONDAENV_THEME_PROMPT_PREFIX}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX}"
|
echo -ne "${CONDAENV_THEME_PROMPT_PREFIX-}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function py_interp_prompt {
|
function py_interp_prompt() {
|
||||||
py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return
|
local py_version
|
||||||
echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}"
|
py_version="$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}')" || return
|
||||||
|
echo -ne "${PYTHON_THEME_PROMPT_PREFIX-}${py_version}${PYTHON_THEME_PROMPT_SUFFIX-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function python_version_prompt {
|
function python_version_prompt() {
|
||||||
echo -e "$(virtualenv_prompt)$(condaenv_prompt)$(py_interp_prompt)"
|
virtualenv_prompt
|
||||||
|
condaenv_prompt
|
||||||
|
py_interp_prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_user_info {
|
function git_user_info() {
|
||||||
|
local current_user
|
||||||
# support two or more initials, set by 'git pair' plugin
|
# support two or more initials, set by 'git pair' plugin
|
||||||
SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%')
|
current_user="$(git config user.initials | sed 's% %+%')"
|
||||||
# if `user.initials` weren't set, attempt to extract initials from `user.name`
|
# if `user.initials` weren't set, attempt to extract initials from `user.name`
|
||||||
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" "$(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)")
|
[[ -z "${current_user}" ]] && current_user=$(printf "%s" "$(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)")
|
||||||
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
|
[[ -n "${current_user}" ]] && printf "%s" "${SCM_THEME_CURRENT_USER_PREFFIX-}${current_user}${SCM_THEME_CURRENT_USER_SUFFIX-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function clock_char {
|
function clock_char() {
|
||||||
CLOCK_CHAR=${THEME_CLOCK_CHAR:-"⌚"}
|
local clock_char clock_char_color show_clock_char
|
||||||
CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$normal"}
|
clock_char="${THEME_CLOCK_CHAR:-⌚}"
|
||||||
SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
|
clock_char_color="${THEME_CLOCK_CHAR_COLOR:-${normal:-}}"
|
||||||
|
show_clock_char="${THEME_SHOW_CLOCK_CHAR:-"true"}"
|
||||||
|
|
||||||
if [[ "${SHOW_CLOCK_CHAR}" = "true" ]]; then
|
if [[ "${show_clock_char}" == "true" ]]; then
|
||||||
echo -e "${CLOCK_CHAR_COLOR}${CLOCK_CHAR_THEME_PROMPT_PREFIX}${CLOCK_CHAR}${CLOCK_CHAR_THEME_PROMPT_SUFFIX}"
|
echo -ne "${clock_char_color}${CLOCK_CHAR_THEME_PROMPT_PREFIX-}${clock_char}${CLOCK_CHAR_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function clock_prompt {
|
function clock_prompt() {
|
||||||
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
|
local clock_color="${THEME_CLOCK_COLOR:-${normal?}}"
|
||||||
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"}
|
local clock_format="${THEME_CLOCK_FORMAT:-"%H:%M:%S"}"
|
||||||
[ -z "$THEME_SHOW_CLOCK" ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
|
local show_clock="${THEME_SHOW_CLOCK:-${THEME_CLOCK_CHECK:-true}}"
|
||||||
SHOW_CLOCK=$THEME_SHOW_CLOCK
|
local clock_string="\D{${clock_format}}"
|
||||||
|
|
||||||
if [[ "${SHOW_CLOCK}" = "true" ]]; then
|
if [[ "${show_clock}" == "true" ]]; then
|
||||||
CLOCK_STRING=$(date +"${CLOCK_FORMAT}")
|
echo -ne "${clock_color}${CLOCK_THEME_PROMPT_PREFIX-}${clock_string}${CLOCK_THEME_PROMPT_SUFFIX-}"
|
||||||
echo -e "${CLOCK_COLOR}${CLOCK_THEME_PROMPT_PREFIX}${CLOCK_STRING}${CLOCK_THEME_PROMPT_SUFFIX}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_host_prompt {
|
function user_host_prompt() {
|
||||||
if [[ "${THEME_SHOW_USER_HOST}" = "true" ]]; then
|
if [[ "${THEME_SHOW_USER_HOST:-false}" == "true" ]]; then
|
||||||
echo -e "${USER_HOST_THEME_PROMPT_PREFIX}\u@\h${USER_HOST_THEME_PROMPT_SUFFIX}"
|
echo -ne "${USER_HOST_THEME_PROMPT_PREFIX-}\u@${THEME_PROMPT_HOST:-\h}${USER_HOST_THEME_PROMPT_SUFFIX-}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# backwards-compatibility
|
# backwards-compatibility
|
||||||
function git_prompt_info {
|
function git_prompt_info() {
|
||||||
_git-hide-status && return
|
_git-hide-status && return
|
||||||
git_prompt_vars
|
git_prompt_vars
|
||||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}${SCM_STATE?}${SCM_SUFFIX?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function p4_prompt_info() {
|
function p4_prompt_info() {
|
||||||
p4_prompt_vars
|
p4_prompt_vars
|
||||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE}${SCM_STATE}${SCM_SUFFIX}"
|
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}:${SCM_CHANGE?}${SCM_STATE?}${SCM_SUFFIX?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function svn_prompt_info {
|
function svn_prompt_info() {
|
||||||
svn_prompt_vars
|
svn_prompt_vars
|
||||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}${SCM_STATE?}${SCM_SUFFIX?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function hg_prompt_info() {
|
function hg_prompt_info() {
|
||||||
hg_prompt_vars
|
hg_prompt_vars
|
||||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE#*:}${SCM_STATE}${SCM_SUFFIX}"
|
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}:${SCM_CHANGE#*:}${SCM_STATE?}${SCM_SUFFIX?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function scm_char {
|
function scm_char() {
|
||||||
scm_prompt_char
|
scm_prompt_char
|
||||||
echo -e "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
echo -ne "${SCM_THEME_CHAR_PREFIX?}${SCM_CHAR?}${SCM_THEME_CHAR_SUFFIX?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt_char {
|
function prompt_char() {
|
||||||
scm_char
|
scm_char
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_char {
|
function battery_char() {
|
||||||
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then
|
# The battery_char function depends on the presence of the battery_percentage function.
|
||||||
echo -e "${bold_red:-}$(battery_percentage)%"
|
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" == true ]] && _command_exists battery_percentage; then
|
||||||
|
echo -ne "${bold_red?}$(battery_percentage)%"
|
||||||
|
else
|
||||||
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! _command_exists battery_charge; then
|
if ! _command_exists battery_charge; then
|
||||||
# if user has installed battery plugin, skip this...
|
# if user has installed battery plugin, skip this...
|
||||||
function battery_charge() {
|
function battery_charge() {
|
||||||
# no op
|
: # no op
|
||||||
echo -n
|
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The battery_char function depends on the presence of the battery_percentage function.
|
function aws_profile() {
|
||||||
# If battery_percentage is not defined, then define battery_char as a no-op.
|
if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]]; then
|
||||||
if ! _command_exists battery_percentage; then
|
echo -ne "${AWS_DEFAULT_PROFILE}"
|
||||||
function battery_char() {
|
|
||||||
# no op
|
|
||||||
echo -n
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
function aws_profile {
|
|
||||||
if [[ $AWS_DEFAULT_PROFILE ]]; then
|
|
||||||
echo -e "${AWS_DEFAULT_PROFILE}"
|
|
||||||
else
|
else
|
||||||
echo -e "default"
|
echo -ne "default"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
if [ -z "$BASH_IT_COMMAND_DURATION" ] || [ "$BASH_IT_COMMAND_DURATION" != true ]; then
|
|
||||||
_command_duration() {
|
|
||||||
echo -n
|
|
||||||
}
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Define tmp dir and file
|
|
||||||
COMMAND_DURATION_TMPDIR="${TMPDIR:-/tmp}"
|
|
||||||
COMMAND_DURATION_FILE="${COMMAND_DURATION_FILE:-$COMMAND_DURATION_TMPDIR/bashit_theme_execution_$BASHPID}"
|
|
||||||
|
|
||||||
COMMAND_DURATION_ICON=${COMMAND_DURATION_ICON:-' '}
|
|
||||||
COMMAND_DURATION_MIN_SECONDS=${COMMAND_DURATION_MIN_SECONDS:-'1'}
|
|
||||||
|
|
||||||
trap _command_duration_delete_temp_file EXIT HUP INT TERM
|
|
||||||
|
|
||||||
_command_duration_delete_temp_file() {
|
|
||||||
if [[ -f "$COMMAND_DURATION_FILE" ]]; then
|
|
||||||
rm -f "$COMMAND_DURATION_FILE"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_command_duration_pre_exec() {
|
|
||||||
date +%s.%1N > "$COMMAND_DURATION_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
_command_duration() {
|
|
||||||
local command_duration command_start current_time
|
|
||||||
local minutes seconds deciseconds
|
|
||||||
local command_start_sseconds current_time_seconds command_start_deciseconds current_time_deciseconds
|
|
||||||
current_time=$(date +%s.%1N)
|
|
||||||
|
|
||||||
if [[ -f "$COMMAND_DURATION_FILE" ]]; then
|
|
||||||
command_start=$(< "$COMMAND_DURATION_FILE")
|
|
||||||
command_start_sseconds=${command_start%.*}
|
|
||||||
current_time_seconds=${current_time%.*}
|
|
||||||
|
|
||||||
command_start_deciseconds=$((10#${command_start#*.}))
|
|
||||||
current_time_deciseconds=$((10#${current_time#*.}))
|
|
||||||
|
|
||||||
# seconds
|
|
||||||
command_duration=$((current_time_seconds - command_start_sseconds))
|
|
||||||
|
|
||||||
if ((current_time_deciseconds >= command_start_deciseconds)); then
|
|
||||||
deciseconds=$(((current_time_deciseconds - command_start_deciseconds)))
|
|
||||||
else
|
|
||||||
((command_duration -= 1))
|
|
||||||
deciseconds=$((10 - ((command_start_deciseconds - current_time_deciseconds))))
|
|
||||||
fi
|
|
||||||
command rm "$COMMAND_DURATION_FILE"
|
|
||||||
else
|
|
||||||
command_duration=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ((command_duration > 0)); then
|
|
||||||
minutes=$((command_duration / 60))
|
|
||||||
seconds=$((command_duration % 60))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ((minutes > 0)); then
|
|
||||||
printf "%s%s%dm %ds" "$COMMAND_DURATION_ICON" "$COMMAND_DURATION_COLOR" "$minutes" "$seconds"
|
|
||||||
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
|
|
||||||
printf "%s%s%d.%01ds" "$COMMAND_DURATION_ICON" "$COMMAND_DURATION_COLOR" "$seconds" "$deciseconds"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
preexec_functions+=(_command_duration_pre_exec)
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
function _git-symbolic-ref {
|
function _git-symbolic-ref() {
|
||||||
git symbolic-ref -q HEAD 2> /dev/null
|
git symbolic-ref -q HEAD 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,63 +8,68 @@ function _git-symbolic-ref {
|
|||||||
# but this can be different when two branches are pointing to the
|
# but this can be different when two branches are pointing to the
|
||||||
# same commit. _git-branch is used to explicitly choose the checked-out
|
# same commit. _git-branch is used to explicitly choose the checked-out
|
||||||
# branch.
|
# branch.
|
||||||
function _git-branch {
|
function _git-branch() {
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
test -n "${VCS_STATUS_LOCAL_BRANCH}" && echo "${VCS_STATUS_LOCAL_BRANCH}" || return 1
|
if [[ -n "${VCS_STATUS_LOCAL_BRANCH:-}" ]]; then
|
||||||
|
echo "${VCS_STATUS_LOCAL_BRANCH}"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git symbolic-ref -q --short HEAD 2> /dev/null || return 1
|
git symbolic-ref -q --short HEAD 2> /dev/null || return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-tag {
|
function _git-tag() {
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
test -n "${VCS_STATUS_TAG}" && echo "${VCS_STATUS_TAG}"
|
if [[ -n "${VCS_STATUS_TAG:-}" ]]; then
|
||||||
|
echo "${VCS_STATUS_TAG}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git describe --tags --exact-match 2> /dev/null
|
git describe --tags --exact-match 2> /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-commit-description {
|
function _git-commit-description() {
|
||||||
git describe --contains --all 2> /dev/null
|
git describe --contains --all 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-short-sha {
|
function _git-short-sha() {
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
echo ${VCS_STATUS_COMMIT:0:7}
|
echo "${VCS_STATUS_COMMIT:0:7}"
|
||||||
else
|
else
|
||||||
git rev-parse --short HEAD
|
git rev-parse --short HEAD
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try the checked-out branch first to avoid collision with branches pointing to the same ref.
|
# Try the checked-out branch first to avoid collision with branches pointing to the same ref.
|
||||||
function _git-friendly-ref {
|
function _git-friendly-ref() {
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
_git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatus
|
_git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatus
|
||||||
else
|
else
|
||||||
_git-branch || _git-tag || _git-commit-description || _git-short-sha
|
_git-branch || _git-tag || _git-commit-description || _git-short-sha
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-num-remotes {
|
function _git-num-remotes() {
|
||||||
git remote | wc -l
|
git remote | wc -l
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-upstream {
|
function _git-upstream() {
|
||||||
local ref
|
local ref
|
||||||
ref="$(_git-symbolic-ref)" || return 1
|
ref="$(_git-symbolic-ref)" || return 1
|
||||||
git for-each-ref --format="%(upstream:short)" "${ref}"
|
git for-each-ref --format="%(upstream:short)" "${ref}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-upstream-remote {
|
function _git-upstream-remote() {
|
||||||
local upstream
|
local upstream branch
|
||||||
upstream="$(_git-upstream)" || return 1
|
upstream="$(_git-upstream)" || return 1
|
||||||
|
|
||||||
local branch
|
|
||||||
branch="$(_git-upstream-branch)" || return 1
|
branch="$(_git-upstream-branch)" || return 1
|
||||||
echo "${upstream%"/${branch}"}"
|
echo "${upstream%"/${branch}"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-upstream-branch {
|
function _git-upstream-branch() {
|
||||||
local ref
|
local ref
|
||||||
ref="$(_git-symbolic-ref)" || return 1
|
ref="$(_git-symbolic-ref)" || return 1
|
||||||
|
|
||||||
@@ -74,25 +79,27 @@ function _git-upstream-branch {
|
|||||||
git for-each-ref --format="%(upstream:strip=3)" "${ref}" 2> /dev/null || git for-each-ref --format="%(upstream)" "${ref}" | sed -e "s/.*\/.*\/.*\///"
|
git for-each-ref --format="%(upstream:strip=3)" "${ref}" 2> /dev/null || git for-each-ref --format="%(upstream)" "${ref}" | sed -e "s/.*\/.*\/.*\///"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-upstream-behind-ahead {
|
function _git-upstream-behind-ahead() {
|
||||||
git rev-list --left-right --count "$(_git-upstream)...HEAD" 2> /dev/null
|
git rev-list --left-right --count "$(_git-upstream)...HEAD" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-upstream-branch-gone {
|
function _git-upstream-branch-gone() {
|
||||||
[[ "$(git status -s -b | sed -e 's/.* //')" == "[gone]" ]]
|
[[ "$(git status -s -b | sed -e 's/.* //')" == "[gone]" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-hide-status {
|
function _git-hide-status() {
|
||||||
[[ "$(git config --get bash-it.hide-status)" == "1" ]]
|
[[ "$(git config --get bash-it.hide-status)" == "1" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-status {
|
function _git-status() {
|
||||||
local git_status_flags=
|
local git_status_flags=
|
||||||
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' || true
|
if [[ "${SCM_GIT_IGNORE_UNTRACKED:-}" == "true" ]]; then
|
||||||
git status --porcelain ${git_status_flags} 2> /dev/null
|
git_status_flags='-uno'
|
||||||
|
fi
|
||||||
|
git status --porcelain "${git_status_flags:---}" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-status-counts {
|
function _git-status-counts() {
|
||||||
_git-status | awk '
|
_git-status | awk '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
untracked=0;
|
untracked=0;
|
||||||
@@ -116,85 +123,51 @@ function _git-status-counts {
|
|||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
function _git-remote-info {
|
function _git-remote-info() {
|
||||||
|
local same_branch_name="" branch_prefix
|
||||||
# prompt handling only, reimplement because patching the routine below gets ugly
|
# prompt handling only, reimplement because patching the routine below gets ugly
|
||||||
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
|
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
|
||||||
[[ "${VCS_STATUS_REMOTE_NAME}" == "" ]] && return
|
[[ "${VCS_STATUS_REMOTE_NAME?}" == "" ]] && return
|
||||||
[[ "${VCS_STATUS_LOCAL_BRANCH}" == "${VCS_STATUS_REMOTE_BRANCH}" ]] && local same_branch_name=true
|
[[ "${VCS_STATUS_LOCAL_BRANCH?}" == "${VCS_STATUS_REMOTE_BRANCH?}" ]] && same_branch_name=true
|
||||||
local same_branch_name=
|
|
||||||
[[ "${VCS_STATUS_LOCAL_BRANCH}" == "${VCS_STATUS_REMOTE_BRANCH}" ]] && same_branch_name=true
|
|
||||||
# no multiple remote support in gitstatusd
|
# no multiple remote support in gitstatusd
|
||||||
if [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" || "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]]; then
|
if [[ "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "true" || "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "auto" ]]; then
|
||||||
if [[ "${same_branch_name}" != "true" ]]; then
|
if [[ ${same_branch_name:-} != "true" ]]; then
|
||||||
remote_info="${VCS_STATUS_REMOTE_NAME}/${VCS_STATUS_REMOTE_BRANCH}"
|
remote_info="${VCS_STATUS_REMOTE_NAME?}/${VCS_STATUS_REMOTE_BRANCH?}"
|
||||||
else
|
else
|
||||||
remote_info="${VCS_STATUS_REMOTE_NAME}"
|
remote_info="${VCS_STATUS_REMOTE_NAME?}"
|
||||||
fi
|
fi
|
||||||
elif [[ ${same_branch_name} != "true" ]]; then
|
elif [[ ${same_branch_name:-} != "true" ]]; then
|
||||||
remote_info="${VCS_STATUS_REMOTE_BRANCH}"
|
remote_info="${VCS_STATUS_REMOTE_BRANCH?}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${remote_info:-}" ]]; then
|
if [[ -n "${remote_info:-}" ]]; then
|
||||||
# no support for gone remote branches in gitstatusd
|
# no support for gone remote branches in gitstatusd
|
||||||
local branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX}"
|
branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}"
|
||||||
echo "${branch_prefix}${remote_info}"
|
echo "${branch_prefix}${remote_info:-}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
[[ "$(_git-upstream)" == "" ]] && return
|
[[ "$(_git-upstream)" == "" ]] && return
|
||||||
|
|
||||||
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true
|
|
||||||
local same_branch_name=
|
|
||||||
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true
|
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true
|
||||||
if [[ ("${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" && "$(_git-num-remotes)" -ge 2) ||
|
if [[ ("${SCM_GIT_SHOW_REMOTE_INFO}" == "auto" && "$(_git-num-remotes)" -ge 2) ||
|
||||||
"${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
|
"${SCM_GIT_SHOW_REMOTE_INFO}" == "true" ]]; then
|
||||||
if [[ "${same_branch_name}" != "true" ]]; then
|
if [[ ${same_branch_name:-} != "true" ]]; then
|
||||||
remote_info="\$(_git-upstream)"
|
# shellcheck disable=SC2016
|
||||||
|
remote_info='$(_git-upstream)'
|
||||||
else
|
else
|
||||||
remote_info="$(_git-upstream-remote)"
|
remote_info="$(_git-upstream-remote)"
|
||||||
fi
|
fi
|
||||||
elif [[ ${same_branch_name} != "true" ]]; then
|
elif [[ ${same_branch_name:-} != "true" ]]; then
|
||||||
remote_info="\$(_git-upstream-branch)"
|
# shellcheck disable=SC2016
|
||||||
|
remote_info='$(_git-upstream-branch)'
|
||||||
fi
|
fi
|
||||||
if [[ -n "${remote_info:-}" ]]; then
|
if [[ -n "${remote_info:-}" ]]; then
|
||||||
local branch_prefix
|
local branch_prefix
|
||||||
if _git-upstream-branch-gone; then
|
if _git-upstream-branch-gone; then
|
||||||
branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX}"
|
branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX:-}"
|
||||||
else
|
else
|
||||||
branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX}"
|
branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}"
|
||||||
fi
|
fi
|
||||||
echo "${branch_prefix}${remote_info}"
|
echo "${branch_prefix}${remote_info:-}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Unused by bash-it, present for API compatibility
|
|
||||||
function git_status_summary {
|
|
||||||
awk '
|
|
||||||
BEGIN {
|
|
||||||
untracked=0;
|
|
||||||
unstaged=0;
|
|
||||||
staged=0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
if (!after_first && $0 ~ /^##.+/) {
|
|
||||||
print $0
|
|
||||||
seen_header = 1
|
|
||||||
} else if ($0 ~ /^\?\? .+/) {
|
|
||||||
untracked += 1
|
|
||||||
} else {
|
|
||||||
if ($0 ~ /^.[^ ] .+/) {
|
|
||||||
unstaged += 1
|
|
||||||
}
|
|
||||||
if ($0 ~ /^[^ ]. .+/) {
|
|
||||||
staged += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
after_first = 1
|
|
||||||
}
|
|
||||||
END {
|
|
||||||
if (!seen_header) {
|
|
||||||
print
|
|
||||||
}
|
|
||||||
print untracked "\t" unstaged "\t" staged
|
|
||||||
}'
|
|
||||||
}
|
|
||||||
|
|||||||
8
themes/oh-my-posh/oh-my-posh.theme.bash
Normal file
8
themes/oh-my-posh/oh-my-posh.theme.bash
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
if _command_exists oh-my-posh; then
|
||||||
|
export POSH_THEME=${POSH_THEME:-https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v$(oh-my-posh --version)/themes/jandedobbeleer.omp.json}
|
||||||
|
eval "$(oh-my-posh --init --shell bash --config "${POSH_THEME}")"
|
||||||
|
else
|
||||||
|
_log_warning "The oh-my-posh binary was not found on your PATH. Falling back to your existing PS1, please see the docs for more info."
|
||||||
|
fi
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
function _p4-opened {
|
function _p4-opened {
|
||||||
timeout 2.0s p4 opened -s 2> /dev/null
|
timeout 2.0s p4 opened -s 2> /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user