Update lots of things, rename custom prompts, move active prompts out of tree and update commits

This commit is contained in:
Alex D. 2020-09-26 19:17:43 +02:00
parent 961bc66584
commit 13467890d6
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
23 changed files with 59 additions and 66 deletions

View File

@ -1,2 +0,0 @@
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export EDITOR=vim

View File

@ -3,6 +3,6 @@ source "${ZDOTDIR}/custom/aliases.zsh"
source "${ZDOTDIR}/custom/gpg.zsh"
fpath+=("${ZDOTDIR}/custom/functions" "${ZDOTDIR}/custom/segments")
compdef _files mplay
function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{gbooru,mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif},prettygitlog,paste,mplay,qff}() {
function {prompt_c_{covid_19,docker_host,mpv,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{gbooru,mangareader,nhentai},gitsubrepo,osutab,prettygitlog,paste,mplay,qff,recordscreen,{send,format}irc}() {
autoload -X
}

View File

@ -1,4 +1,3 @@
alias recordscreen='ffmpeg -hwaccel vdpau -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -c:v libx264rgb -crf 0 -preset ultrafast -movflags +faststart -tune zerolatency'
alias ytdldown='youtube-dl --no-part --newline -ixcw -R infinite -f bestaudio/best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(album)s/%(track_number)s - %(track)s.%(ext)s"'
alias ls='ls --color=auto'
alias grep='grep --color=auto'

View File

@ -1 +1 @@
ffmpeg -hwaccel cuda -i $1 -c:v h264 -crf 30 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2
ffmpeg -hwaccel vdpau -i $1 -c:v h264 -crf 30 -movflags +faststart $2

View File

@ -0,0 +1,9 @@
local -A colormap
while read LINE; do
NICK="${${${=LINE#:}[1]%\!*}#:}"
CHAN="${${=LINE#:}[3]}"
RANDS=($RANDOM $RANDOM)
[ -z $colormap["$NICK"] ] && colormap["$NICK"]=${(%)$(<<< %F\{$(( $RANDS[1] % 6 + 1 ))\} )}
[ -z $colormap["$CHAN"] ] && colormap["$CHAN"]=${(%)$(<<< %F\{$(( $RANDS[2] % 6 + 1 ))\} )}
<<< "${colormap["$CHAN"]}${(l:10:)${CHAN}:0:10}${(%)$(<<< %F\{default\})} | ${colormap["$NICK"]}${(l:14:)${NICK}:0:14}${(%)$(<<< %F\{default\})} | ${${=LINE#:}[4,-1]#:}";
done

View File

@ -2,8 +2,13 @@ local -a urls
local -a fetch
local page=0
while [ ${page} -eq 0 ] || [ ${#fetch} -eq 100 ]; do
<<< "Fetching page $page"
fetch=($(curl -sZSGL "https://gelbooru.com/index.php?q=index&s=post&page=dapi&json=1&pid=$page&tags=${1}" | jq -r ".[].file_url"))
urls+=($fetch)
page=$(($page + 1))
done
[ ${#urls} -gt 0 ] && curl -L\# --remote-name-all $urls
if [[ $2 == "mpv" ]]; then
[ ${#urls} -gt 0 ] && mpv --loop $urls
else
[ ${#urls} -gt 0 ] && curl -RL\#C - --remote-name-all $urls
fi

View File

@ -1 +1,4 @@
busctl call --no-pager --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player OpenUri s "$1"
local REPLY
zsocket ~/.mpvsock 2>/dev/null || return
print -u $REPLY "loadfile $@"
exec {REPLY}>&-

View File

@ -0,0 +1 @@
ffmpeg -hwaccel vdpau -y -filter_threads 4 -v warning -thread_queue_size 8 -f pulse -i default -video_size 1920x1080 -framerate 60 -thread_queue_size 8 -f x11grab -i :0 -c:v h264 -crf 30 -preset ultrafast -movflags +faststart -tune zerolatency $1

2
custom/functions/sendirc Normal file
View File

@ -0,0 +1,2 @@
([ -z $1 ] || [ -z $2 ]) && return
printf "PRIVMSG %s :%s\r\n" "$1" "${argv[2,-1]}"

View File

@ -1,10 +1,13 @@
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/sudo/sudo.plugin.zsh
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
local rootcmd
[ -v commands\[sudo\] ] && rootcmd=sudo
[ -v commands\[doas\] ] && rootcmd=doas
if [[ $BUFFER == $rootcmd\ * ]]; then
LBUFFER="${LBUFFER#$rootcmd }"
else
LBUFFER="sudo $LBUFFER"
LBUFFER="$rootcmd $LBUFFER"
fi
}
zle -N sudo-command-line

View File

@ -1,8 +1,8 @@
local REPLY
zstyle -s ':custom:prompts:weather' location REPLY
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": {"min": .min_temp, "max": .max_temp}, "icon": .weather_state_abbr}')
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "icon": .weather_state_abbr}')
if [ ! -z $result ]; then
local ico=$(print $result | jq -r '.icon')
typeset -g _cprompts_weather=($(jq -r '.temp.min' <<< $result) $(jq -r '.temp.max' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
typeset -g _cprompts_weather=($(( int(rint($(jq -r '.temp' <<< $result))) )) ${colors[$ico]:-white} ${icons[${ico:-X}]})
print ${_cprompts_weather} > $tmpfile
fi

View File

@ -0,0 +1,5 @@
ROOT=~/IRC
[ -r $ROOT ] || return
for i in $ROOT/*/channels/*; do
if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then
done

View File

@ -0,0 +1,6 @@
local REPLY
zstyle -s ':custom:prompts:mpv' socket REPLY
[ -S $REPLY ] && zsocket $REPLY 2>/dev/null || return
_cprompts_mpv[2]="${${$(print -u $REPLY '{ "command": ["get_property", "media-title"] }' && read -eEu $REPLY)#*\"data\"([^[:print:]])#:([^[:print:]])#\"}%%(\"~\\\")*}"
exec {REPLY}>&-
[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]}"

View File

@ -1,6 +0,0 @@
local REPLY
zsocket ~/.mpvsock 2>/dev/null || return
typeset -ga _cprompts_mpv=($REPLY)
_cprompts_mpv[2]="${${$(print -u $_cprompts_mpv[1] '{ "command": ["get_property", "media-title"] }' && read -Eu $_cprompts_mpv[1])#*\"data\"([^[:print:]])#:([^[:print:]])#\"}%%(\"~\\\")*}"
exec {REPLY}>&-
[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]:0:20}$([ ${#_cprompts_mpv[2]} -gt 20 ] && print ...)"

View File

@ -1,4 +1,6 @@
local new_mails=(~/Mail/*/Inbox/new/*(.N))
local REPLY
zstyle -s ':custom:prompts:mail' glob REPLY
local new_mails=(${~REPLY}(.N))
typeset -g _cprompts_mail_count=${#new_mails}
[[ ${_cprompts_mail_count} -gt 0 ]] || return
p10k segment -b yellow -i '' -t "${_cprompts_mail_count:-unknown}"

View File

@ -1,6 +1,7 @@
[ -v commands\[sqlite3\] ] || return
local newsboatdb=~/.newsboat/cache.db
local REPLY
zstyle -s ':custom:prompts:newsboat' database REPLY
if [ ! -v _cprompts_newsboat ]; then
typeset -g _cprompts_newsboat="$(sqlite3 ${newsboatdb} --ascii 'SELECT COUNT(id) FROM rss_item WHERE unread == 1 AND guid GLOB "yt:video:*"')"
typeset -g _cprompts_newsboat="$(sqlite3 $REPLY --ascii 'SELECT COUNT(id) FROM rss_item WHERE unread == 1 AND guid GLOB "yt:video:*"')"
fi
p10k segment -b red -i '' -t "${_cprompts_newsboat}"

View File

@ -2,7 +2,7 @@
local -a stats
zstat -A stats +mtime -- todo.txt 2>/dev/null
if [ ! -v _cprompts_todo ] || [ $_cprompts_todo[4] -ne $stats[1] ]; then
local todofi=(${(f@)${mapfile[todo.txt]}})
local todofi=(${(f@)$(< todo.txt)})
local t_nf=0
local t_f=0
local colors=(red yellow green)

View File

@ -28,10 +28,10 @@ colors[sn]="white"
if [ ! -v _cprompts_weather ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [ ${stats[1]:-0} -lt $(($epochtime[1]-21600)) ]; then
if [ ${stats[1]:-0} -lt $(($epochtime[1]-3600)) ]; then
cprompts:cache:async:weather &!
else
typeset -g _cprompts_weather=($(< $tmpfile))
fi
fi
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[3]:-white} -i ${_cprompts_weather[4]:-\?} -t "${_cprompts_weather[1]:-unknown} - ${_cprompts_weather[2]:-unknown}"
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"

View File

@ -4,7 +4,6 @@ source ${ZDOTDIR}/powerlevel-config/dir.zsh
source ${ZDOTDIR}/powerlevel-config/disk.zsh
source ${ZDOTDIR}/powerlevel-config/misc.zsh
source ${ZDOTDIR}/powerlevel-config/prompt-char.zsh
source ${ZDOTDIR}/powerlevel-config/prompt-elements.zsh
source ${ZDOTDIR}/powerlevel-config/separators.zsh
source ${ZDOTDIR}/powerlevel-config/status.zsh
source ${ZDOTDIR}/powerlevel-config/time.zsh

View File

@ -1,34 +0,0 @@
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
os_icon
time
battery
disk_usage
ssh
root_indicator
vim_shell
newline
vi_mode
status
dir
dir_writable
)
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
if [ ! -v SSH_CONNECTION ]; then
zmodload zsh/mapfile # Required by the todo segment, is way faster
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=(
c_mpv_mpris
c_todo
c_new_mail
c_sfeed
# c_newsboat
# c_mumble
c_weather
c_covid_19
)
fi
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=(
newline
command_execution_time
background_jobs
vcs
)

@ -1 +1 @@
Subproject commit 6c9d0977a6378239f4153f5d3700bc5f70b36c3d
Subproject commit 71b39f0da9236acb1323f2833e7cec3ef3eda365

View File

@ -16,25 +16,25 @@ export LESS_TERMCAP_us=$'\e[01;32m'
setopt appendhistory autocd auto_param_slash c_bases extendedglob nomatch notify hist_ignore_all_dups hist_ignore_space share_history nobeep
if [[ -r "${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
source ${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
typeset -g ZSH_HIGHLIGHT_HIGHLIGHTERS=(
main
brackets
pattern
cursor
)
source ${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
if [[ -r "${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then
source ${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh
typeset -g ZSH_AUTOSUGGEST_STRATEGY=(history completion)
typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=true
source ${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh
fi
zstyle -s ':custom:preferences' prompt REPLY
if [[ $REPLY == "p9k" ]] && [[ -r "${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme" ]]; then
source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme
zstyle -s ':custom:preferences' prompt _cur_prompt
if [[ $_cur_prompt == "p9k" ]] && [[ -r "${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme" ]]; then
source ${ZDOTDIR}/powerlevel-config/all.zsh
source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme
else
autoload -Uz promptinit
promptinit

@ -1 +1 @@
Subproject commit fb929edc30192407a9298aad64f55ca1b19a464e
Subproject commit 62c5575848f1f0a96161243d18497c247c9f52df