testing out yash shell

This commit is contained in:
yosh 2023-07-25 14:27:43 -05:00
parent 0607468b86
commit 8184b44fe4
17 changed files with 500 additions and 1 deletions

View File

@ -2,7 +2,7 @@ unbind C-b
unbind M-a
set -g prefix M-a
bind M-a send-prefix
set -g default-command bash
set -g default-command yash
set -g base-index 1
set -g pane-base-index 1
set -g aggressive-resize on

View File

@ -0,0 +1,29 @@
# Completion script for the "doas" command.
function completion/doas {
typeset OPTIONS ARGOPT
OPTIONS=( #>#
"C:; specify a config file to parse"
"L; clear any persisted authentications, then exit"
"n; non-interactive mode, fail if rule doesn't have nopass"
"s; execute the shell from \$SHELL or /etc/passwd"
"u:; specify the user to execute the command as"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(C)
complete -f
;;
(u)
complete -u
;;
(*)
command -f completion//getoperands
command -f completion//reexecute
;;
esac
}

View File

@ -0,0 +1,346 @@
# (C) 2023 yosh
# Completion script for the xbps suite.
function completion/xbps::parse_help {
typeset IFS line word copt lopt
while IFS="" read -r line; do
# line must start with a blank
[[ "$line" == [[:blank:]]* ]] || continue
if [[ "$line" =~ ^[[:blank:]]{1,5}"-" ]]; then
[[ -n "${copt:-}" ]] && printf '%s\n' "$copt" && copt=""
IFS=" =,"
set -f
set -- $line
set +f
# if $1 is a short option, remove leading dash and shift. trim line.
[[ "$1" == "-"[a-zA-Z0-9] ]] && copt="${1#-}" && shift
# test if long option, will add space if short option exists. trim line.
[[ "$1" =~ ^"--"[a-zA-Z-]+$ ]] && copt="${copt:+$copt }$1" && line="${line#*$1}" && shift
# test opt args
if [[ "$1" == "<"*">" ]]; then copt="${copt/ /: }:" && shift
elif [[ "$1" == "["*"]" ]]; then copt="${copt/ /:: }::" && shift
elif [[ "$1" =~ ^[][,.A-Z]{2,}$ ]]; then copt="${copt/ /: }:" && shift; fi
# trim *anything* before the first instance of 2 spaces or ending chars
# this catches xbps-query's --cat=FILE PKG option and xbps-query --property
# also trim everything before first tab
line="${line#*[] ] }"
line="${line#* }"
# trim leading and trailing whitespace
line="${line#"${line%%[![:blank:]]*}"}"
line="${line%"${line##*[![:blank:]]}"}"
copt="$copt;${line:+ $line}"
elif [[ "$line" =~ ^[[:blank:]]{5,} ]]; then
# this only triggers if it starts with > 5 blanks but there's no --,
# which means it can only be an extension of a prev cmd description
# or a footer note, which can be detected by number of spaces
line="$(IFS=" "; printf ' %s' $line)"
[[ "$copt" == *";" ]] && line=" ${line# }"
[[ "$line" == " "[A-Z]* ]] && [[ "$copt" != *";" ]] && [[ "$copt" != *"." ]] && line=".$line"
copt="${copt% }$line"
fi
done <( "$1" --help 2>&1 )
printf '%s\n' "$copt"
}
function completion/xbps::installed_packages {
xbps-query -s "$1*" | sed 's/^... \([^ ]*\)-[^-]* .*/\1/'
}
function completion/xbps::all_packages {
xbps-query -Rs "$1*" | sed 's/^... \([^ ]*\)-[^-]* .*/\1/'
}
function completion/xbps::set_options {
typeset IFS='
'
OPTIONS=( $(command -f completion/xbps::parse_help "$1") )
}
function completion/xbps::query_words {
for word in "${WORDS[@]}"; do
for arg in "$@"; do
[[ "$word" == "$arg" ]] && return 0
done
done
return 1
}
function completion/xbps-alternatives {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-alternatives
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Cc]|--config|--rootdir)
complete -P "$PREFIX" -d
;;
(g|--group)
complete -P "$PREFIX" $(xbps-alternatives -l | grep -v '^ ')
;;
(*)
complete $(command -f completion/xbps::installed_packages "$TARGETWORD")
;;
esac
}
function completion/xbps-checkvers {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-checkvers
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([CDr]|--config|--distdir|--rootdir)
complete -P "$PREFIX" -d
;;
(*)
complete -f
esac
}
function completion/xbps-create {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-create
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(*)
complete -d
;;
esac
}
function completion/xbps-dgraph {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-dgraph
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Cr]|--config|--rootdir)
complete -P "$PREFIX" -d
;;
(c|--graph-config)
complete -P "$PREFIX" -f
;;
(*)
complete $(command -f completion/xbps::all_packages)
;;
esac
}
function completion/xbps-digest {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-digest
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(*)
complete -f
;;
esac
}
function completion/xbps-fetch {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-fetch
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(o)
complete -P "$PREFIX" -f
;;
(*)
;;
esac
}
function completion/xbps-install {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-install
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Ccr]|--config|--cachedir|--rootdir)
complete -P "$PREFIX" -d
;;
(*)
complete $(command -f completion/xbps::all_packages "$TARGETWORD")
;;
esac
}
function completion/xbps-pkgdb {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-pkgdb
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Cr]|--config|--rootdir)
complete -P "$PREFIX" -d
;;
(m|--mode)
complete -P "$PREFIX" -D "mark PKGNAME as if it was installed automatically" auto
complete -P "$PREFIX" -D "mark PKGNAME as if it was installed manually" manual
complete -P "$PREFIX" -D "hold PKGNAME. Held packages are not updated" hold
complete -P "$PREFIX" -D "unhold PKGNAME" unhold
complete -P "$PREFIX" -D "make PKGNAME only accept updates from the same repo used for installation" repolock
complete -P "$PREFIX" -D "allow PKGNAME to accept updates from any repo" repounlock
;;
(*)
complete $(command -f completion/xbps::installed_packages "$TARGETWORD")
;;
esac
}
function completion/xbps-query {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-query
command -f completion//parseoptions -e
case $ARGOPT in
("-")
command -f completion//completeoptions
;;
([Ccr]|--config|--cachedir|--rootdir)
complete -P "$PREFIX" -d
;;
(p|--property)
if [ -n "$PREFIX" ]; then
complete -P "$PREFIX" ""
else
PREFIX="${TARGETWORD%"${TARGETWORD##*,}"}"
complete -T -S ',' -P "$PREFIX" -D 'group and file alternatives provided by the package.' alternatives
complete -T -S ',' -P "$PREFIX" -D 'target architecture the package was build for.' architecture
complete -T -S ',' -P "$PREFIX" -D 'returns "yes" if the package was installed automatically.' automatic-install
complete -T -S ',' -P "$PREFIX" -D 'enabled options the package was built with.' build-options
complete -T -S ',' -P "$PREFIX" -D 'changelog URL for the package.' changelog
complete -T -S ',' -P "$PREFIX" -D 'configuration file(s) installed by the package.' conf_files
complete -T -S ',' -P "$PREFIX" -D 'other packages this package conflicts with.' conflicts
complete -T -S ',' -P "$PREFIX" -D 'hash of the package file.' filename-sha256
complete -T -S ',' -P "$PREFIX" -D 'size of the package file.' filename-size
complete -T -S ',' -P "$PREFIX" -D 'returns "yes" if the package is held and will not be updated.' hold
complete -T -S ',' -P "$PREFIX" -D 'home URL of the package project.' homepage
complete -T -S ',' -P "$PREFIX" -D 'date when the package was installed.' install-date
complete -T -S ',' -P "$PREFIX" -D 'post-install message provided by the package.' install-msg
complete -T -S ',' -P "$PREFIX" -D 'script used for installing the package.' install-script
complete -T -S ',' -P "$PREFIX" -D 'total size of files installed by the package.' installed_size
complete -T -S ',' -P "$PREFIX" -D 'license(s) for distributing the package.' license
complete -T -S ',' -P "$PREFIX" -D 'contact of the maintainer of the package.' maintainer
complete -T -S ',' -P "$PREFIX" -D 'hash of the plist package files metadata.' metafile-sha256
complete -T -S ',' -P "$PREFIX" -D 'name of the package.' pkgname
complete -T -S ',' -P "$PREFIX" -D 'version of the package.' pkgver
complete -T -S ',' -P "$PREFIX" -D 'returns "yes" if the package will not be removed automatically on update.' preserve
complete -T -S ',' -P "$PREFIX" -D 'abstract facility provided by the package.' provides
complete -T -S ',' -P "$PREFIX" -D 'post-remove message provided by the package.' remove-msg
complete -T -S ',' -P "$PREFIX" -D 'script used for removing the package.' remove-script
complete -T -S ',' -P "$PREFIX" -D 'other packages that the package replaces.' replaces
complete -T -S ',' -P "$PREFIX" -D 'returns "yes" if the package only accepts updates from original repository.' repolock
complete -T -S ',' -P "$PREFIX" -D 'repository where the package was installed from.' repository
complete -T -S ',' -P "$PREFIX" -D 'previous provided version this package replaces.' reverts
complete -T -S ',' -P "$PREFIX" -D 'other runtime dependency packages for the package.' run_depends
complete -T -S ',' -P "$PREFIX" -D 'shared libraries provided by the package.' shlib-provides
complete -T -S ',' -P "$PREFIX" -D 'shared libraries required by the package.' shlib-requires
complete -T -S ',' -P "$PREFIX" -D 'short description of the package.' short_desc
complete -T -S ',' -P "$PREFIX" -D 'commit hash of package last change from the void-packages repository.' source-revisions
complete -T -S ',' -P "$PREFIX" -D 'installation state of the package.' state
complete -T -S ',' -P "$PREFIX" -D 'list of categories the package is associated with.' tags
fi
;;
(o|--cat)
complete -P "$PREFIX" -f
;;
(*)
if command -f completion/xbps::query_words "-R" "--repository"; then complete $(command -f completion/xbps::all_packages "$TARGETWORD")
else complete $(command -f completion/xbps::installed_packages "$TARGETWORD"); fi
;;
esac
}
function completion/xbps-reconfigure {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-reconfigure
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Cr]|--config|--rootdir)
complete -P "$PREFIX" -d
;;
(*)
complete $(command -f completion/xbps::installed_packages "$TARGETWORD")
;;
esac
}
function completion/xbps-remove {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-remove
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([Ccr]|--config|--cachedir|--rootdir)
complete -P "$PREFIX" -d
;;
(*)
complete $(command -f completion/xbps::installed_packages "$TARGETWORD")
;;
esac
}
function completion/xbps-rindex {
typeset OPTIONS ARGOPT PREFIX
command -f completion/xbps::set_options xbps-rindex
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([crs]|--clean|--remove-obsoletes|--sign)
complete -P "$PREFIX" -d
;;
([aS]|--add|--sign-pkg)
complete -P "$PREFIX" -A '*.xbps' -df
;;
(--compression)
complete -P "$PREFIX" none gzip bzip2 lz4 xz zstd
;;
(*)
complete -f
;;
esac
}
# the rest will be created when xbps updates to 0.60, since that update will
# have more consistent --help naming schemes.

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1 @@
/home/yosh/.config/yash/completion/xbps

View File

@ -0,0 +1,50 @@
# aliases
# man() { vim -R -c 'filetype plugin on' -c 'set ft=man' -c "Man $*"; }
chtsh() { IFS='+' curl cht.sh/"$*" ; }
# local
alias usv="SVDIR=${HOME}/.local/service sv"
# convenience
alias view='vim -R'
alias ls='lsd'
alias xdt='xdotool'
alias tearfree='xrandr --output HDMI-A-0 --set TearFree'
alias ts="stranslate"
alias ed="ed -p '* '"
alias diff='diff --color -u'
alias dotfiles='/usr/bin/git --git-dir=$HOME/.local/dotfiles --work-tree=$HOME'
# XDG aliases
alias startx='startx "$XDG_CONFIG_HOME/X11/xinitrc"'
# Prompt and nnn
_c=("\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]" "\[\]")
if [ "${NNNLVL:-0}" -ge 1 ]; then
alias nnn="echo don\'t nest nnn!"
export nnnsel="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection"
_prompt_flags="${_prompt_flags:-} ${_c[10]}nnn"
fi
YASH_PS1="${_c[16]}[${_c[14]}"'$USER'"${_c[16]}@${_c[11]}"'$(uname -n)'"${_c[16]}]${_prompt_flags:-}${_c[16]} ${_c[9]}*${_c[16]} ${_c[7]}"'${PWD/#~/\~}'"
${_c[10]}└─────${_c[17]} "
YASH_PS1S=''
YASH_PS1P='\fkt.'
PS1='[$USER@$(uname -n)] /${PWD##*/} $ '
PS1S="$YASH_PS1S"
PS1P="$YASH_PS1P"
unset _c
unset _prompt_flags
set -o emacs
set -o le-predict
# keybinds {{{
bindkey -e '\^L' clear-and-redraw-all
bindkey -a '\^L' clear-and-redraw-all
bindkey -v '\^L' clear-and-redraw-all
# }}}
# vim: ft=sh

62
.yash_profile Normal file
View File

@ -0,0 +1,62 @@
# load global profile
. /etc/profile
# xdg yash loadpath
export YASH_LOADPATH="$XDG_CONFIG_HOME/yash:$YASH_LOADPATH"
export HISTFILE="$XDG_CONFIG_HOME/yash/history"
# xdg support shit {{{
export INPUTRC="$XDG_CONFIG_HOME/inputrc"
export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc"
export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority"
export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle"
export VIMINIT="set nocp | source $XDG_CONFIG_HOME/vim/vimrc"
export WINEPREFIX="$XDG_DATA_HOME/wine"
export PASSAGE_DIR="$XDG_DATA_HOME/passage/store"
export PASSAGE_IDENTITIES_FILE="$XDG_DATA_HOME/passage/identities"
export PENTADACTYL_INIT="source $XDG_CONFIG_HOME/pentadactyl/pentadactylrc"
export PENTADACTYL_RUINTIME="$XDG_CONFIG_HOME/pentadactyl"
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export SRB2WADDIR="$XDG_DATA_HOME/srb2kart/wads"
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonstartup.py"
# }}}
# other config {{{
export PATH="$HOME/.local/bin:$HOME/.local/scripts:$PATH"
export MANPATH="$XDG_DATA_HOME/man:"
export EDITOR="vim"
export VISUAL="vim"
export QT_STYLE_OVERRIDE=kvantum
# }}}
# program options {{{
# misc {{{
export JAVA_HOME="/usr/lib/jvm/openjdk17"
export LESS='-Ri'
# }}}
# fzf {{{
export FZF_DEFAULT_COMMAND="fd -t f --strip-cwd-prefix"
export FZF_DEFAULT_OPTS='
--color "fg:7,bg:-1,hl:12,fg+:11,bg+:0,hl+:13,info:9,border:0,prompt:4,pointer:10,marker:2,spinner:13,header:7"
--border -e
--bind ctrl-space:print-query+abort
'
# }}}
# nnn {{{
export NNN_OPTS="aAeQ"
export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
export NNN_COLORS='#0d0d0d0d0d0d0d0d'
BLK="0B" CHR="0B" DIR="0d" EXE="0a" REG="07" HARDLINK="0e" SYMLINK="0e" MISSING="08" ORPHAN="09" FIFO="03" SOCK="0B" OTHER="06"
export NNN_FCOLORS="$BLK$CHR$DIR$EXE$REG$HARDLINK$SYMLINK$MISSING$ORPHAN$FIFO$SOCK$OTHER"
_nc='c:-!magick convert "$nnn" png:- | xclip -sel clipboard -t image/png*'
_nm='h:-!hx "$nnn"*;o:-fzopen;d:dragdrop;p:preview-tui'
export NNN_PLUG="$_nc;$_nm"
# }}}
# }}}
# vim: ft=sh