-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
theme/liquidprompt: use
$THEME_CLOCK_FORMAT
Alsö: - `shfmt` - `shellcheck` - stop with the `cd`
- Loading branch information
1 parent
561e282
commit 843c69c
Showing
3 changed files
with
59 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ tmp/ | |
profiles/* | ||
# apart from the default one | ||
!profiles/default.bash_it | ||
|
||
/vendor/github.com/nojhan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# Wrapper to use liquidprompt with bashit | ||
# shellcheck shell=bash | ||
# shellcheck disable=SC2034 # expected behavior for themes | ||
# Wrapper to use liquidprompt with _Bash It_ | ||
|
||
targetdir="$BASH_IT/themes/liquidprompt/liquidprompt" | ||
gray="\[\e[1;90m\]" | ||
|
||
cwd="$PWD" | ||
if cd "$targetdir" &>/dev/null && git rev-parse --is-inside-work-tree &>/dev/null; then | ||
true | ||
else | ||
git clone https://github.com/nojhan/liquidprompt.git "$targetdir" && \ | ||
echo -e "Successfully cloned liquidprompt!\n More configuration in '$targetdir/liquid.theme'." | ||
## Download repository if needed | ||
__bash_it_theme_liquidprompt_path="github.com/nojhan/liquidprompt" | ||
__bash_it_theme_liquidprompt_dir="${BASH_IT?}/vendor/${__bash_it_theme_liquidprompt_path}" | ||
if [[ ! -d "${__bash_it_theme_liquidprompt_dir}" ]]; then | ||
git clone "https://${__bash_it_theme_liquidprompt_path}" "${__bash_it_theme_liquidprompt_dir}" \ | ||
&& echo -e "Successfully cloned liquidprompt!\n More configuration in '$__bash_it_theme_liquidprompt_dir/liquid.theme'." | ||
fi | ||
cd "$cwd" | ||
|
||
export LP_ENABLE_TIME=1 | ||
export LP_HOSTNAME_ALWAYS=1 | ||
export LP_USER_ALWAYS=1 | ||
export LP_MARK_LOAD="📈 " | ||
export LP_BATTERY_THRESHOLD=${LP_BATTERY_THRESHOLD:-75} | ||
export LP_LOAD_THRESHOLD=${LP_LOAD_THRESHOLD:-60} | ||
export LP_TEMP_THRESHOLD=${LP_TEMP_THRESHOLD:-80} | ||
## Configure theme | ||
LP_MARK_LOAD="📈 " | ||
: "${LP_ENABLE_TIME:=1}" | ||
: "${LP_HOSTNAME_ALWAYS:=1}" | ||
: "${LP_USER_ALWAYS:=1}" | ||
: "${LP_BATTERY_THRESHOLD:=75}" | ||
: "${LP_LOAD_THRESHOLD:=60}" | ||
: "${LP_TEMP_THRESHOLD:=80}" | ||
|
||
## Load theme | ||
# shellcheck source-path=SCRIPTDIR/../../vendor/github.com/nojhan/liquidprompt | ||
source "${__bash_it_theme_liquidprompt_dir}/liquidprompt" | ||
|
||
source "$targetdir/liquidprompt" | ||
prompt() { true; } | ||
export PS2=" ┃ " | ||
export LP_PS1_PREFIX="┌─" | ||
export LP_PS1_POSTFIX="\n└▪ " | ||
export LP_ENABLE_RUNTIME=0 | ||
## Override upstream defaults | ||
PS2=" ┃ " | ||
LP_PS1_PREFIX="┌─" | ||
LP_PS1_POSTFIX="\n└▪ " | ||
LP_ENABLE_RUNTIME=0 | ||
|
||
_lp_git_branch() | ||
{ | ||
(( LP_ENABLE_GIT )) || return | ||
function _lp_git_branch() { | ||
((${LP_ENABLE_GIT:-0})) || return | ||
|
||
\git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return | ||
command git rev-parse --is-inside-work-tree > /dev/null 2>&1 || return | ||
|
||
local branch | ||
# Recent versions of Git support the --short option for symbolic-ref, but | ||
# not 1.7.9 (Ubuntu 12.04) | ||
if branch="$(\git symbolic-ref -q HEAD)"; then | ||
_lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" | ||
else | ||
# In detached head state, use commit instead | ||
# No escape needed | ||
\git rev-parse --short -q HEAD 2>/dev/null | ||
fi | ||
local branch | ||
# Recent versions of Git support the --short option for symbolic-ref, but | ||
# not 1.7.9 (Ubuntu 12.04) | ||
if branch="$(command git symbolic-ref -q HEAD)"; then | ||
_lp_escape "$(command git rev-parse --short=5 -q HEAD 2> /dev/null):${branch#refs/heads/}" | ||
else | ||
# In detached head state, use commit instead | ||
# No escape needed | ||
command git rev-parse --short -q HEAD 2> /dev/null | ||
fi | ||
} | ||
|
||
_lp_time() { | ||
if (( LP_ENABLE_TIME )) && (( ! LP_TIME_ANALOG )); then | ||
LP_TIME="${gray}$(date +%d-%H:%M)${normal}" | ||
else | ||
LP_TIME="" | ||
fi | ||
function _lp_time() { | ||
if ((LP_ENABLE_TIME)) && ((!${LP_TIME_ANALOG:-0})); then | ||
LP_TIME="${gray?}\D{${THEME_CLOCK_FORMAT:-"%d-%H:%M"}}${normal?}" | ||
else | ||
LP_TIME="" | ||
fi | ||
} | ||
|
||
# Implementation using lm-sensors | ||
_lp_temp_sensors() | ||
{ | ||
local -i i | ||
for i in $(sensors -u | | ||
sed -n 's/^ temp[0-9][0-9]*_input: \([0-9]*\)\..*$/\1/p'); do | ||
(( $i > ${temperature:-0} )) && (( $i != 127 )) && temperature=i | ||
done | ||
function _lp_temp_sensors() { | ||
local -i i | ||
for i in $(sensors -u \ | ||
| sed -n 's/^ temp[0-9][0-9]*_input: \([0-9]*\)\..*$/\1/p'); do | ||
((i > ${temperature:-0})) && ((i != 127)) && temperature=i | ||
done | ||
} | ||
|
||
# Implementation using 'acpi -t' | ||
_lp_temp_acpi() | ||
{ | ||
local -i i | ||
for i in $(LANG=C acpi -t | | ||
sed 's/.* \(-\?[0-9]*\)\.[0-9]* degrees C$/\1/p'); do | ||
(( $i > ${temperature:-0} )) && (( $i != 127 )) && temperature=i | ||
done | ||
function _lp_temp_acpi() { | ||
local -i i | ||
for i in $(LANG=C acpi -t \ | ||
| sed 's/.* \(-\?[0-9]*\)\.[0-9]* degrees C$/\1/p'); do | ||
((i > ${temperature:-0})) && ((i != 127)) && temperature=i | ||
done | ||
} |