diff --git a/custom.zsh b/custom.zsh index bf0a5f7..6b554cb 100644 --- a/custom.zsh +++ b/custom.zsh @@ -4,4 +4,4 @@ source "${ZDOTDIR}/custom/aliases.zsh" source "${ZDOTDIR}/custom/dirstack.zsh" source "${ZDOTDIR}/custom/docker.zsh" source "${ZDOTDIR}/custom/gpg.zsh" -source "${ZDOTDIR}/custom/functions.zsh" +fpath+="${ZDOTDIR}/custom/functions" diff --git a/custom/functions.zsh b/custom/functions.zsh deleted file mode 100644 index b8a4d35..0000000 --- a/custom/functions.zsh +++ /dev/null @@ -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 "$@" -} diff --git a/custom/functions/ffmpeg-compress b/custom/functions/ffmpeg-compress new file mode 100644 index 0000000..3b51559 --- /dev/null +++ b/custom/functions/ffmpeg-compress @@ -0,0 +1 @@ +ffmpeg -hwaccel vdpau -i $1 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2 diff --git a/custom/functions/ffmpeg-gif b/custom/functions/ffmpeg-gif new file mode 100644 index 0000000..5f2bc5d --- /dev/null +++ b/custom/functions/ffmpeg-gif @@ -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 diff --git a/custom/functions/getnhentai b/custom/functions/getnhentai new file mode 100644 index 0000000..182332a --- /dev/null +++ b/custom/functions/getnhentai @@ -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 .. diff --git a/custom/functions/gitsubrepo b/custom/functions/gitsubrepo new file mode 100644 index 0000000..e290ce8 --- /dev/null +++ b/custom/functions/gitsubrepo @@ -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)' \; diff --git a/custom/functions/osutab b/custom/functions/osutab new file mode 100644 index 0000000..81d2f29 --- /dev/null +++ b/custom/functions/osutab @@ -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 diff --git a/custom/segments.zsh b/custom/segments.zsh index 7a134fe..515bf5e 100644 --- a/custom/segments.zsh +++ b/custom/segments.zsh @@ -30,7 +30,7 @@ function prompt_c_covid_19() { typeset -g _cprompts_covid=$(< $tmpfile) 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() { 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)) 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() { local REPLY diff --git a/preferences.zsh b/preferences.zsh index ce49fe0..ce18dc6 100644 --- a/preferences.zsh +++ b/preferences.zsh @@ -3,17 +3,17 @@ typeset -g CACHEPATH=/tmp typeset -g HISTSIZE=1000 typeset -g SAVEHIST=1000 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 -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 +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 @@ -30,3 +30,13 @@ if [[ -r "${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then typeset -g ZSH_AUTOSUGGEST_STRATEGY=(history completion) typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=true 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