init
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
commit
ef9160c4a6
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/plugin/** linguist-language=Shell
|
9
LICENSE
Normal file
9
LICENSE
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright 2022 Ari Archer <ari.web.xyz@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
LICENSE_SPEEDENATOR
Normal file
21
LICENSE_SPEEDENATOR
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2012-2021 Erik Selberg and contributors (https://github.com/speedenator/agnoster-bash/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
20
README.md
Normal file
20
README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Baz plugin: agnoster-theme-baz-plugin
|
||||
|
||||
![Sreenshot](https://github.com/speedenator/agnoster-bash/raw/master/agnoster-bash-sshot.png)
|
||||
|
||||
> Baz plugin for for agnoster theme
|
||||
|
||||
This is a ported copy of <https://github.com/speedenator/agnoster-bash>
|
||||
ported to baz
|
||||
|
||||
# Credits
|
||||
|
||||
- The theme by [@speedenator](https://github.com/speedenator): <https://github.com/speedenator/agnoster-bash>
|
||||
|
||||
# Installation
|
||||
|
||||
- Using [baz plugin manager](https://ari-web.xyz/gh/baz):
|
||||
|
||||
```bash
|
||||
$ baz install git 'https://ari-web.xyz/gh/agnoster-theme-baz-plugin'
|
||||
```
|
8
baz.env
Normal file
8
baz.env
Normal file
|
@ -0,0 +1,8 @@
|
|||
export BAZP_NAME='agnoster-theme-baz-plugin'
|
||||
export BAZP_LICENSE='MIt'
|
||||
export BAZP_VER=1
|
||||
export BAZP_AUTHOR='Erik Selberg'
|
||||
export BAZP_SRC='plugin'
|
||||
export BAZP_METHOD='git'
|
||||
export BAZP_SOURCE='https://ari-web.xyz/gh/agnoster-theme-baz-plugin'
|
||||
export BAZP_DESCRIPTION='Baz plugin for agnoster theme'
|
1
plugin/environments/CURRENT_BG
Normal file
1
plugin/environments/CURRENT_BG
Normal file
|
@ -0,0 +1 @@
|
|||
NONE
|
1
plugin/environments/CURRENT_RBG
Normal file
1
plugin/environments/CURRENT_RBG
Normal file
|
@ -0,0 +1 @@
|
|||
NONE
|
1
plugin/environments/LEFT_SUBSEG
Normal file
1
plugin/environments/LEFT_SUBSEG
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
plugin/environments/PROMPT_COMMAND
Normal file
1
plugin/environments/PROMPT_COMMAND
Normal file
|
@ -0,0 +1 @@
|
|||
agnoster_theme
|
1
plugin/environments/RIGHT_SEPARATOR
Normal file
1
plugin/environments/RIGHT_SEPARATOR
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
plugin/environments/RIGHT_SUBSEG
Normal file
1
plugin/environments/RIGHT_SUBSEG
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
plugin/environments/SEGMENT_SEPARATOR
Normal file
1
plugin/environments/SEGMENT_SEPARATOR
Normal file
|
@ -0,0 +1 @@
|
|||
|
9
plugin/functions/__command_rprompt
Normal file
9
plugin/functions/__command_rprompt
Normal file
|
@ -0,0 +1,9 @@
|
|||
local times= n=$COLUMNS tz
|
||||
for tz in ZRH:Europe/Zurich PIT:US/Eastern \
|
||||
MTV:US/Pacific TOK:Asia/Tokyo; do
|
||||
[ $n -gt 40 ] || break
|
||||
times="$times ${tz%%:*}\e[30;1m:\e[0;36;1m"
|
||||
times="$times$(TZ=${tz#*:} date +%H:%M)\e[0m"
|
||||
n=$(( $n - 10 ))
|
||||
done
|
||||
[ -z "$times" ] || printf "%${n}s$times\\r" ''
|
10
plugin/functions/agnoster_theme
Normal file
10
plugin/functions/agnoster_theme
Normal file
|
@ -0,0 +1,10 @@
|
|||
RETVAL=$?
|
||||
PR=""
|
||||
PRIGHT=""
|
||||
CURRENT_BG=NONE
|
||||
PR="$(ansi_single $(text_effect reset))"
|
||||
build_prompt
|
||||
|
||||
# uncomment below to use right prompt
|
||||
# PS1='\[$(tput sc; printf "%*s" $COLUMNS "$PRIGHT"; tput rc)\]'$PR
|
||||
PS1=$PR
|
14
plugin/functions/ansi
Normal file
14
plugin/functions/ansi
Normal file
|
@ -0,0 +1,14 @@
|
|||
local seq
|
||||
declare -a mycodes=("${!1}")
|
||||
|
||||
debug "ansi: ${!1} all: $* aka ${mycodes[@]}"
|
||||
|
||||
seq=""
|
||||
for ((i = 0; i < ${#mycodes[@]}; i++)); do
|
||||
if [[ -n $seq ]]; then
|
||||
seq="${seq};"
|
||||
fi
|
||||
seq="${seq}${mycodes[$i]}"
|
||||
done
|
||||
debug "ansi debug:" '\\[\\033['${seq}'m\\]'
|
||||
echo -ne '\[\033['${seq}'m\]'
|
14
plugin/functions/ansi_r
Normal file
14
plugin/functions/ansi_r
Normal file
|
@ -0,0 +1,14 @@
|
|||
local seq
|
||||
declare -a mycodes2=("${!1}")
|
||||
|
||||
debug "ansi: ${!1} all: $* aka ${mycodes2[@]}"
|
||||
|
||||
seq=""
|
||||
for ((i = 0; i < ${#mycodes2[@]}; i++)); do
|
||||
if [[ -n $seq ]]; then
|
||||
seq="${seq};"
|
||||
fi
|
||||
seq="${seq}${mycodes2[$i]}"
|
||||
done
|
||||
debug "ansi debug:" '\\[\\033['${seq}'m\\]'
|
||||
echo -ne '\033['${seq}'m'
|
1
plugin/functions/ansi_single
Normal file
1
plugin/functions/ansi_single
Normal file
|
@ -0,0 +1 @@
|
|||
echo -ne '\[\033['$1'm\]'
|
11
plugin/functions/bg_color
Normal file
11
plugin/functions/bg_color
Normal file
|
@ -0,0 +1,11 @@
|
|||
case "$1" in
|
||||
black) echo 40;;
|
||||
red) echo 41;;
|
||||
green) echo 42;;
|
||||
yellow) echo 43;;
|
||||
blue) echo 44;;
|
||||
magenta) echo 45;;
|
||||
cyan) echo 46;;
|
||||
white) echo 47;;
|
||||
orange) echo 48\;5\;166;;
|
||||
esac
|
9
plugin/functions/build_prompt
Normal file
9
plugin/functions/build_prompt
Normal file
|
@ -0,0 +1,9 @@
|
|||
[[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir
|
||||
prompt_status
|
||||
#[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt
|
||||
[[ -z ${AG_NO_CONTEXT+x} ]] && prompt_context
|
||||
prompt_virtualenv
|
||||
prompt_dir
|
||||
prompt_git
|
||||
prompt_hg
|
||||
prompt_end
|
3
plugin/functions/debug
Normal file
3
plugin/functions/debug
Normal file
|
@ -0,0 +1,3 @@
|
|||
if [[ "${DEBUG:-0}" -ne 0 ]]; then
|
||||
>&2 echo -e $*
|
||||
fi
|
11
plugin/functions/fg_color
Normal file
11
plugin/functions/fg_color
Normal file
|
@ -0,0 +1,11 @@
|
|||
case "$1" in
|
||||
black) echo 30;;
|
||||
red) echo 31;;
|
||||
green) echo 32;;
|
||||
yellow) echo 33;;
|
||||
blue) echo 34;;
|
||||
magenta) echo 35;;
|
||||
cyan) echo 36;;
|
||||
white) echo 37;;
|
||||
orange) echo 38\;5\;166;;
|
||||
esac
|
2
plugin/functions/git_stash_dirty
Normal file
2
plugin/functions/git_stash_dirty
Normal file
|
@ -0,0 +1,2 @@
|
|||
stash=$(git stash list 2> /dev/null | tail -n 1)
|
||||
[[ -n $stash ]] && echo " ⚑"
|
2
plugin/functions/git_status_dirty
Normal file
2
plugin/functions/git_status_dirty
Normal file
|
@ -0,0 +1,2 @@
|
|||
dirty=$(git status -s 2> /dev/null | tail -n 1)
|
||||
[[ -n $dirty ]] && echo " ●"
|
5
plugin/functions/prompt_context
Normal file
5
plugin/functions/prompt_context
Normal file
|
@ -0,0 +1,5 @@
|
|||
local user=`whoami`
|
||||
|
||||
if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then
|
||||
prompt_segment black default "$user@\h"
|
||||
fi
|
1
plugin/functions/prompt_dir
Normal file
1
plugin/functions/prompt_dir
Normal file
|
@ -0,0 +1 @@
|
|||
prompt_segment blue black '\w'
|
1
plugin/functions/prompt_emacsdir
Normal file
1
plugin/functions/prompt_emacsdir
Normal file
|
@ -0,0 +1 @@
|
|||
PR="DIR \w DIR$PR"
|
7
plugin/functions/prompt_end
Normal file
7
plugin/functions/prompt_end
Normal file
|
@ -0,0 +1,7 @@
|
|||
if [[ -n $CURRENT_BG ]]; then
|
||||
declare -a codes=($(text_effect reset) $(fg_color $CURRENT_BG))
|
||||
PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR"
|
||||
fi
|
||||
declare -a reset=($(text_effect reset))
|
||||
PR="$PR $(ansi reset[@])"
|
||||
CURRENT_BG=''
|
15
plugin/functions/prompt_git
Normal file
15
plugin/functions/prompt_git
Normal file
|
@ -0,0 +1,15 @@
|
|||
local ref dirty
|
||||
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY='±'
|
||||
dirty=$(git_status_dirty)
|
||||
stash=$(git_stash_dirty)
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) \
|
||||
|| ref="➦ $(git describe --exact-match --tags HEAD 2> /dev/null)" \
|
||||
|| ref="➦ $(git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
|
||||
if [[ -n $dirty ]]; then
|
||||
prompt_segment yellow black
|
||||
else
|
||||
prompt_segment green black
|
||||
fi
|
||||
PR="$PR${ref/refs\/heads\// }$stash$dirty"
|
||||
fi
|
32
plugin/functions/prompt_hg
Normal file
32
plugin/functions/prompt_hg
Normal file
|
@ -0,0 +1,32 @@
|
|||
local rev st branch
|
||||
if $(hg id >/dev/null 2>&1); then
|
||||
if $(hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
# if working copy is clean
|
||||
prompt_segment green black $CURRENT_FG
|
||||
fi
|
||||
PR="$PR$(hg prompt "☿ {rev}@{branch}") $st"
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(hg id -b 2>/dev/null)
|
||||
if `hg st | grep -q "^\?"`; then
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif `hg st | grep -q "^[MA]"`; then
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
prompt_segment green black $CURRENT_FG
|
||||
fi
|
||||
PR="$PR☿ $rev@$branch $st"
|
||||
fi
|
||||
fi
|
1
plugin/functions/prompt_histdt
Normal file
1
plugin/functions/prompt_histdt
Normal file
|
@ -0,0 +1 @@
|
|||
prompt_segment black default "\! [\A]"
|
29
plugin/functions/prompt_right_segment
Normal file
29
plugin/functions/prompt_right_segment
Normal file
|
@ -0,0 +1,29 @@
|
|||
local bg fg
|
||||
declare -a codes
|
||||
|
||||
debug "Prompt right"
|
||||
debug "Prompting $1 $2 $3"
|
||||
|
||||
codes=("${codes[@]}" $(text_effect reset))
|
||||
if [[ -n $1 ]]; then
|
||||
bg=$(bg_color $1)
|
||||
codes=("${codes[@]}" $bg)
|
||||
debug "Added $bg as background to codes"
|
||||
fi
|
||||
if [[ -n $2 ]]; then
|
||||
fg=$(fg_color $2)
|
||||
codes=("${codes[@]}" $fg)
|
||||
debug "Added $fg as foreground to codes"
|
||||
fi
|
||||
|
||||
debug "Right Codes: "
|
||||
|
||||
declare -a intermediate2=($(fg_color $1) $(bg_color $CURRENT_RBG) )
|
||||
|
||||
debug "pre prompt " $(ansi_r intermediate2[@])
|
||||
PRIGHT="$PRIGHT$(ansi_r intermediate2[@])$RIGHT_SEPARATOR"
|
||||
debug "post prompt " $(ansi_r codes[@])
|
||||
PRIGHT="$PRIGHT$(ansi_r codes[@]) "
|
||||
|
||||
CURRENT_RBG=$1
|
||||
[[ -n $3 ]] && PRIGHT="$PRIGHT$3"
|
31
plugin/functions/prompt_segment
Normal file
31
plugin/functions/prompt_segment
Normal file
|
@ -0,0 +1,31 @@
|
|||
local bg fg
|
||||
declare -a codes
|
||||
|
||||
debug "Prompting $1 $2 $3"
|
||||
|
||||
codes=("${codes[@]}" $(text_effect reset))
|
||||
if [[ -n $1 ]]; then
|
||||
bg=$(bg_color $1)
|
||||
codes=("${codes[@]}" $bg)
|
||||
debug "Added $bg as background to codes"
|
||||
fi
|
||||
if [[ -n $2 ]]; then
|
||||
fg=$(fg_color $2)
|
||||
codes=("${codes[@]}" $fg)
|
||||
debug "Added $fg as foreground to codes"
|
||||
fi
|
||||
|
||||
debug "Codes: "
|
||||
|
||||
if [[ $CURRENT_BG != NONE && $1 != $CURRENT_BG ]]; then
|
||||
declare -a intermediate=($(fg_color $CURRENT_BG) $(bg_color $1))
|
||||
debug "pre prompt " $(ansi intermediate[@])
|
||||
PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR"
|
||||
debug "post prompt " $(ansi codes[@])
|
||||
PR="$PR$(ansi codes[@]) "
|
||||
else
|
||||
debug "no current BG, codes is $codes[@]"
|
||||
PR="$PR$(ansi codes[@]) "
|
||||
fi
|
||||
CURRENT_BG=$1
|
||||
[[ -n $3 ]] && PR="$PR$3"
|
7
plugin/functions/prompt_status
Normal file
7
plugin/functions/prompt_status
Normal file
|
@ -0,0 +1,7 @@
|
|||
local symbols
|
||||
symbols=()
|
||||
[[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))✘"
|
||||
[[ $UID -eq 0 ]] && symbols+="$(ansi_single $(fg_color yellow))⚡"
|
||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="$(ansi_single $(fg_color cyan))⚙"
|
||||
|
||||
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
|
5
plugin/functions/prompt_virtualenv
Normal file
5
plugin/functions/prompt_virtualenv
Normal file
|
@ -0,0 +1,5 @@
|
|||
if [[ -n $VIRTUAL_ENV ]]; then
|
||||
color=cyan
|
||||
prompt_segment $color $PRIMARY_FG
|
||||
prompt_segment $color white "$(basename $VIRTUAL_ENV)"
|
||||
fi
|
1
plugin/functions/rightprompt
Normal file
1
plugin/functions/rightprompt
Normal file
|
@ -0,0 +1 @@
|
|||
printf "%*s" $COLUMNS "$PRIGHT"
|
5
plugin/functions/text_effect
Normal file
5
plugin/functions/text_effect
Normal file
|
@ -0,0 +1,5 @@
|
|||
case "$1" in
|
||||
reset) echo 0;;
|
||||
bold) echo 1;;
|
||||
underline) echo 4;;
|
||||
esac
|
Loading…
Reference in a new issue