Move functions to function paths, load prompt last, add few options and hide segments when async fetching

This commit is contained in:
Alex 2020-05-28 12:14:05 +02:00
parent 4a53ea99ff
commit 9c2dfddf8b
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
9 changed files with 46 additions and 57 deletions

View File

@ -4,4 +4,4 @@ source "${ZDOTDIR}/custom/aliases.zsh"
source "${ZDOTDIR}/custom/dirstack.zsh" source "${ZDOTDIR}/custom/dirstack.zsh"
source "${ZDOTDIR}/custom/docker.zsh" source "${ZDOTDIR}/custom/docker.zsh"
source "${ZDOTDIR}/custom/gpg.zsh" source "${ZDOTDIR}/custom/gpg.zsh"
source "${ZDOTDIR}/custom/functions.zsh" fpath+="${ZDOTDIR}/custom/functions"

View File

@ -1,44 +0,0 @@
function gitsubrepo {
find * -maxdepth 1 -mindepth 1 -type d -name ".git" -exec sh -c '(DIR={}; DIR=${DIR%%.git} && cd $DIR && echo $DIR && git status -s)' \;
}
function osutab {
xinput set-prop 'UGTABLET 6 inch PenTablet Pen (0)' --type=float 153 3.5 0 -0.5 0 2.9 0 0 0 1
}
function ffmpeg-gif {
ffmpeg -hwaccel vdpau -ss $2 -to $3 -i $1 -r 60 -pix_fmt bgr8 -vf "mpdecimate,normalize,scale=480:-1:flags=spline,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -loop 0 $4
}
function ffmpeg-vid {
ffmpeg -hwaccel vdpau -ss $2 -to $3 -i $1 -r 60 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $4
}
function ffmpeg-compress {
ffmpeg -hwaccel vdpau -i $1 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2
}
function getnhentai {
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 media_id=$(print $pageinfo | jq -r '.id')
local types=($(print $pageinfo | jq -r '.types[]'))
local num_pages=$(print $pageinfo | jq '.pages')
local dir=$(print $pageinfo | jq -r '.title')
local urls=()
[ ! -z $2 ] && mkdir "$dir" && cd "$dir"
for i in {1..$num_pages}; do
local ctoi=$(($i - 1))
[[ ${types[$ctoi]} == p ]] && local type=png || local type=jpg
urls+=("https://i.nhentai.net/galleries/$media_id/$i.$type")
done
curl --retry 10 -\#L --remote-name-all ${urls}
for i in *; do
local sortname="$(printf "%.3i" "${i%%.*}").${i##*.}"
[ $sortname = $i ] || mv $i $sortname
done
[ ! -z $2 ] && cd ..
}
function man {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}

View File

@ -0,0 +1 @@
ffmpeg -hwaccel vdpau -i $1 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2

View File

@ -0,0 +1 @@
ffmpeg -hwaccel vdpau -ss $2 -to $3 -i $1 -r 60 -pix_fmt bgr8 -vf "mpdecimate,normalize,scale=480:-1:flags=spline,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -loop 0 $4

View File

@ -0,0 +1,18 @@
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 media_id=$(print $pageinfo | jq -r '.id')
local types=($(print $pageinfo | jq -r '.types[]'))
local num_pages=$(print $pageinfo | jq '.pages')
local dir=$(print $pageinfo | jq -r '.title')
local urls=()
[ ! -z $2 ] && mkdir "$dir" && cd "$dir"
for i in {1..$num_pages}; do
local ctoi=$(($i - 1))
[[ ${types[$ctoi]} == p ]] && local type=png || local type=jpg
urls+=("https://i.nhentai.net/galleries/$media_id/$i.$type")
done
curl --retry 10 -\#L --remote-name-all ${urls}
for i in *; do
local sortname="$(printf "%.3i" "${i%%.*}").${i##*.}"
[ $sortname = $i ] || mv $i $sortname
done
[ ! -z $2 ] && cd ..

View File

@ -0,0 +1 @@
find * -maxdepth 1 -mindepth 1 -type d -name ".git" -exec sh -c '(DIR={}; DIR=${DIR%%.git} && cd $DIR && echo $DIR && git status -s)' \;

1
custom/functions/osutab Normal file
View File

@ -0,0 +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

View File

@ -30,7 +30,7 @@ function prompt_c_covid_19() {
typeset -g _cprompts_covid=$(< $tmpfile) typeset -g _cprompts_covid=$(< $tmpfile)
fi fi
fi fi
p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}" [ -v _cprompts_covid ] && p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}"
} }
function cprompts:cache:async:covid() { function cprompts:cache:async:covid() {
typeset -g _cprompts_covid=$(curl -sL https://api.covid19api.com/country/${REPLY:-germany} | jq -e '. |= sort_by (.Date) | .[-1].Active') typeset -g _cprompts_covid=$(curl -sL https://api.covid19api.com/country/${REPLY:-germany} | jq -e '. |= sort_by (.Date) | .[-1].Active')
@ -72,7 +72,8 @@ function prompt_c_weather() {
typeset -g _cprompts_weather=($(< $tmpfile)) typeset -g _cprompts_weather=($(< $tmpfile))
fi fi
fi fi
p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}" [ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
} }
function cprompts:cache:async:weather() { function cprompts:cache:async:weather() {
local REPLY local REPLY

View File

@ -3,17 +3,17 @@ typeset -g CACHEPATH=/tmp
typeset -g HISTSIZE=1000 typeset -g HISTSIZE=1000
typeset -g SAVEHIST=1000 typeset -g SAVEHIST=1000
typeset -g ZLE_RPROMPT_INDENT=0 typeset -g ZLE_RPROMPT_INDENT=0
setopt appendhistory autocd extendedglob nomatch notify hist_ignore_all_dups hist_ignore_space nobeep # Pager and man stuff
typeset -g READNULLCMD=less
export LESS=-iRFXM
export LESS_TERMCAP_md=$'\e[01;31m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[01;32m'
zstyle -s ':custom:preferences' prompt REPLY setopt appendhistory autocd auto_param_slash c_bases extendedglob nomatch notify hist_ignore_all_dups hist_ignore_space share_history nobeep
if [[ $REPLY == "p9k" ]] && [[ -r "${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme" ]]; then
source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme
source ${ZDOTDIR}/powerlevel-config/all.zsh
else
autoload -Uz promptinit
promptinit
prompt clint
fi
if [[ -r "${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then if [[ -r "${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
source ${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source ${ZDOTDIR}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
@ -30,3 +30,13 @@ if [[ -r "${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then
typeset -g ZSH_AUTOSUGGEST_STRATEGY=(history completion) typeset -g ZSH_AUTOSUGGEST_STRATEGY=(history completion)
typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=true typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=true
fi fi
zstyle -s ':custom:preferences' prompt REPLY
if [[ $REPLY == "p9k" ]] && [[ -r "${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme" ]]; then
source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme
source ${ZDOTDIR}/powerlevel-config/all.zsh
else
autoload -Uz promptinit
promptinit
prompt clint
fi