Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2022-06-18 23:04:43 +03:00
commit ef9160c4a6
Signed by untrusted user who does not match committer: ari
GPG key ID: A50D5B4B599AF8A2
36 changed files with 292 additions and 0 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
/plugin/** linguist-language=Shell

9
LICENSE Normal file
View 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
View 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
View 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
View 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'

View file

@ -0,0 +1 @@
NONE

View file

@ -0,0 +1 @@
NONE

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@
agnoster_theme

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View 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" ''

View 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
View 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
View 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'

View file

@ -0,0 +1 @@
echo -ne '\[\033['$1'm\]'

11
plugin/functions/bg_color Normal file
View 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

View 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
View file

@ -0,0 +1,3 @@
if [[ "${DEBUG:-0}" -ne 0 ]]; then
>&2 echo -e $*
fi

11
plugin/functions/fg_color Normal file
View 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

View file

@ -0,0 +1,2 @@
stash=$(git stash list 2> /dev/null | tail -n 1)
[[ -n $stash ]] && echo " ⚑"

View file

@ -0,0 +1,2 @@
dirty=$(git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo " ●"

View file

@ -0,0 +1,5 @@
local user=`whoami`
if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then
prompt_segment black default "$user@\h"
fi

View file

@ -0,0 +1 @@
prompt_segment blue black '\w'

View file

@ -0,0 +1 @@
PR="DIR \w DIR$PR"

View 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=''

View 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

View 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

View file

@ -0,0 +1 @@
prompt_segment black default "\! [\A]"

View 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"

View 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"

View 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"

View 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

View file

@ -0,0 +1 @@
printf "%*s" $COLUMNS "$PRIGHT"

View file

@ -0,0 +1,5 @@
case "$1" in
reset) echo 0;;
bold) echo 1;;
underline) echo 4;;
esac