diff --git a/bindings.zsh b/bindings.zsh index adc11dc..4709329 100644 --- a/bindings.zsh +++ b/bindings.zsh @@ -54,10 +54,3 @@ if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then add-zle-hook-widget -Uz zle-line-init zle_application_mode_start add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop fi - -function edit-buffer() { - BUFFER="${EDITOR:-vi} $BUFFER" - zle accept-line -} -zle -N edit-buffer -bindkey -- '^E' edit-buffer # Quick edit diff --git a/completions.zsh b/completions.zsh index 4484168..c778ee0 100644 --- a/completions.zsh +++ b/completions.zsh @@ -15,4 +15,4 @@ zstyle ':completion:*:approximate:*' max-errors 1 numeric zstyle ':completion:*:functions' ignored-patterns '_*' zstyle ':completion:*:descriptions' format '%U%B%d%b%u' zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' -autoload -Uz +X compinit && compinit +autoload -Uz compinit && compinit diff --git a/custom.zsh b/custom.zsh index 4497aa5..b393107 100644 --- a/custom.zsh +++ b/custom.zsh @@ -2,6 +2,7 @@ source "${ZDOTDIR}/custom/prependsudo.zsh" source "${ZDOTDIR}/custom/aliases.zsh" source "${ZDOTDIR}/custom/gpg.zsh" fpath+=("${ZDOTDIR}/custom/functions" "${ZDOTDIR}/custom/segments") -function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif}}() { +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}() { autoload -X } diff --git a/custom/aliases.zsh b/custom/aliases.zsh index 99ede65..469fd5b 100644 --- a/custom/aliases.zsh +++ b/custom/aliases.zsh @@ -1,12 +1,5 @@ -# Technically a alias on steroids -function mplay() { - busctl call --no-pager --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player OpenUri s "$1" -} -compdef _files mplay - 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' alias diff='diff --color=auto' -alias paste="curl -F'file=@-'" diff --git a/custom/functions/ffmpeg-compress b/custom/functions/ffmpeg-compress index 3b51559..f250570 100644 --- a/custom/functions/ffmpeg-compress +++ b/custom/functions/ffmpeg-compress @@ -1 +1 @@ -ffmpeg -hwaccel vdpau -i $1 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2 +ffmpeg -hwaccel cuda -i $1 -c:v h264 -crf 30 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2 diff --git a/custom/functions/getnhentai b/custom/functions/getnhentai index 182332a..9a76a88 100644 --- a/custom/functions/getnhentai +++ b/custom/functions/getnhentai @@ -1,4 +1,4 @@ -local pageinfo="$(curl -sL $1 | grep -oP '(?<=var gallery = new N.gallery\().*(?=\);)' | jq '{"pages": .num_pages,"id": .media_id, "types": [.images.pages[].t], "title": .title.pretty}')" +local pageinfo=$(print $(curl -sL $1 | grep -oP '(?<=window._gallery = JSON.parse\(").*(?="\);)') | jq '{"pages": .num_pages,"id": .media_id, "types": [.images.pages[].t], "title": .title.pretty}') local media_id=$(print $pageinfo | jq -r '.id') local types=($(print $pageinfo | jq -r '.types[]')) local num_pages=$(print $pageinfo | jq '.pages') diff --git a/custom/functions/osutab b/custom/functions/osutab index 81d2f29..f6fc52e 100644 --- a/custom/functions/osutab +++ b/custom/functions/osutab @@ -1 +1 @@ -xinput set-prop 'UGTABLET 6 inch PenTablet Pen (0)' --type=float 153 3.5 0 -0.5 0 2.9 0 0 0 1 +xinput --set-float-prop 'UGTABLET 6 inch PenTablet Pen (0)' 'Coordinate Transformation Matrix' 3.5 0 -0.5 0 2.9 0 0 0 1 diff --git a/custom/segments/cprompts:cache:async:rss b/custom/segments/cprompts:cache:async:rss index 678d8d5..15c90ca 100644 --- a/custom/segments/cprompts:cache:async:rss +++ b/custom/segments/cprompts:cache:async:rss @@ -6,7 +6,7 @@ for f in $feedpath/*; do for l in ${content[@]}; do local IFS=$'\t' local options=($l) - [[ ${options[6]:0:9} == "yt:video:" ]] && [ $options[1] -gt $(($epochtime[1]-14400)) ] && ((count++)) + [[ ${options[6]:0:9} == "yt:video:" ]] && [ $options[1] -gt $(($epochtime[1] - 14400)) ] && ((count++)) done done print $count > $tmpfile diff --git a/custom/segments/cprompts:cache:async:weather b/custom/segments/cprompts:cache:async:weather index 27f40eb..2c84b85 100644 --- a/custom/segments/cprompts:cache:async:weather +++ b/custom/segments/cprompts:cache:async:weather @@ -3,6 +3,6 @@ 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": .the_temp, "icon": .weather_state_abbr}') if [ ! -z $result ]; then local ico=$(print $result | jq -r '.icon') - typeset -g _cprompts_weather=($(print $result | jq -r '.temp') ${colors[$ico]} ${icons[$ico]:-?}) + typeset -g _cprompts_weather=($(jq -r '.temp' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]}) print ${_cprompts_weather%%.*} > $tmpfile fi diff --git a/custom/segments/prompt_c_covid_19 b/custom/segments/prompt_c_covid_19 index 1882dd2..ae23ed5 100644 --- a/custom/segments/prompt_c_covid_19 +++ b/custom/segments/prompt_c_covid_19 @@ -5,7 +5,7 @@ zstyle -s ':custom:prompts:covid' country REPLY local -a stats if [ ! -v _cprompts_covid ]; then zstat -A stats +mtime -- $tmpfile 2>/dev/null - if [ $stats[1] -lt $(($epochtime[1]-86400)) ]; then + if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then cprompts:cache:async:covid &! else typeset -g _cprompts_covid=$(< $tmpfile) diff --git a/custom/segments/prompt_c_mpv_mpris b/custom/segments/prompt_c_mpv_mpris index b58c0a1..29af2f0 100644 --- a/custom/segments/prompt_c_mpv_mpris +++ b/custom/segments/prompt_c_mpv_mpris @@ -1,6 +1,4 @@ -([ -v commands\[busctl\] ] && [ -v commands\[jq\] ]) || return -typeset -g _cprompts_mpv -local busout="$(busctl get-property -j --no-pager --timeout=300ms --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Metadata 2>/dev/null)" -[ -z $busout ] && return -_cprompts_mpv="$(print $busout | jq -er '(.data."xesam:title".data // empty)')" -[ -z $_cprompts_mpv ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv:0:20}$([ ${#_cprompts_mpv} -gt 20 ] && print ...)" +zsocket ~/.mpvsock +typeset -ga _cprompts_mpv=($REPLY) +_cprompts_mpv[2]="${${$(print -u $_cprompts_mpv[1] '{ "command": ["get_property", "media-title"] }' && read -Eu $_cprompts_mpv[1])#*\"data\"*:*\"}%%\"*}" +[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]:0:20}$([ ${#_cprompts_mpv[2]} -gt 20 ] && print ...)" diff --git a/custom/segments/prompt_c_sfeed b/custom/segments/prompt_c_sfeed index da949c6..e1ff140 100644 --- a/custom/segments/prompt_c_sfeed +++ b/custom/segments/prompt_c_sfeed @@ -1,14 +1,10 @@ +setopt local_options nomatch feedpath=~/.sfeed/feeds/ -tmpfile=$CACHEPATH/rss +local tmpfile=$CACHEPATH/rss [ -r $feedpath ] || return -local -a rss local -a cache -zstat -A rss +mtime -- $feedpath/* 2>/dev/null zstat -A cache +mtime -- $tmpfile 2>/dev/null -if [ -r $tmpfile ]; then - ([ ! -v _cprompts_sfeed ] || [ $rss[1] -gt $cache[1] ]) && cprompts:cache:async:rss &! - typeset -g _cprompts_sfeed=$(< $tmpfile) -else - cprompts:cache:async:rss &! -fi +([ ! -v _cprompts_sfeed ] || [ ${cache[1]:-0} -lt $(($epochtime[1] - 1800)) ]) && cprompts:cache:async:rss &! +[ -r $tmpfile ] || return +typeset -g _cprompts_sfeed=$(< $tmpfile) [ ${_cprompts_sfeed:-0} -ne 0 ] && p10k segment -b red -i '' -t "+${_cprompts_sfeed:-unknown}" diff --git a/custom/segments/prompt_c_weather b/custom/segments/prompt_c_weather index 11468e5..e7b67de 100644 --- a/custom/segments/prompt_c_weather +++ b/custom/segments/prompt_c_weather @@ -1,5 +1,5 @@ ([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return -local tmpfile=${CACHEPATH}/weather +local tmpfile=$CACHEPATH/weather local -a stats # Fancy stuff @@ -28,7 +28,7 @@ colors[sn]="white" if [ ! -v _cprompts_weather ]; then zstat -A stats +mtime -- $tmpfile 2>/dev/null - if [ $stats[1] -lt $(($epochtime[1]-21600)) ]; then + if [ ${stats[1]:-0} -lt $(($epochtime[1]-21600)) ]; then cprompts:cache:async:weather &! else typeset -g _cprompts_weather=($(< $tmpfile)) diff --git a/powerlevel10k b/powerlevel10k index 6b69030..6c9d097 160000 --- a/powerlevel10k +++ b/powerlevel10k @@ -1 +1 @@ -Subproject commit 6b69030bfb6fff74733f58aa493e7b2b41c8ae6b +Subproject commit 6c9d0977a6378239f4153f5d3700bc5f70b36c3d diff --git a/preferences.zsh b/preferences.zsh index ce18dc6..1653bf9 100644 --- a/preferences.zsh +++ b/preferences.zsh @@ -1,5 +1,5 @@ typeset -g HISTFILE=~/.histfile -typeset -g CACHEPATH=/tmp +typeset -g CACHEPATH=~/.cache typeset -g HISTSIZE=1000 typeset -g SAVEHIST=1000 typeset -g ZLE_RPROMPT_INDENT=0 diff --git a/zsh-syntax-highlighting b/zsh-syntax-highlighting index f8b1470..fb929ed 160000 --- a/zsh-syntax-highlighting +++ b/zsh-syntax-highlighting @@ -1 +1 @@ -Subproject commit f8b1470314be9fd25df90fa40d45c727c193ba96 +Subproject commit fb929edc30192407a9298aad64f55ca1b19a464e