From 4091206c792ad1f099ce947687e77b75a953f50b Mon Sep 17 00:00:00 2001 From: caskd Date: Tue, 31 Dec 2019 22:02:41 +0100 Subject: [PATCH] More youtube dl stuff, updates, using ZDOTDIR, smarter manual completions --- .zshrc | 9 ++++----- completions.zsh | 4 +++- custom.zsh | 7 +++---- custom/others.zsh | 23 +++++------------------ preferences.zsh | 6 +++--- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.zshrc b/.zshrc index 3b78712..3665f8d 100644 --- a/.zshrc +++ b/.zshrc @@ -1,4 +1,3 @@ -ZSHBASECFG=/home/caskd/.zsh if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi @@ -7,7 +6,7 @@ if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then logout fi -source "${ZSHBASECFG}/completions.zsh" -source "${ZSHBASECFG}/preferences.zsh" -source "${ZSHBASECFG}/bindings.zsh" -source "${ZSHBASECFG}/custom.zsh" +source "${ZDOTDIR}/completions.zsh" +source "${ZDOTDIR}/preferences.zsh" +source "${ZDOTDIR}/bindings.zsh" +source "${ZDOTDIR}/custom.zsh" diff --git a/completions.zsh b/completions.zsh index 42eec7e..413138a 100644 --- a/completions.zsh +++ b/completions.zsh @@ -1,5 +1,7 @@ zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zshcompcache +zstyle ':completion:*:manuals' separate-sections true +zstyle ':completion:*:manuals.*' insert-sections true zstyle ':completion:*' expand prefix suffix zstyle ':completion:*' file-sort modification zstyle ':completion:*' list-suffixes true @@ -12,6 +14,6 @@ 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' -zstyle :compinstall filename '${ZSHBASECFG}/completions.zsh' +zstyle :compinstall filename '${ZDOTDIR}/completions.zsh' autoload -Uz compinit compinit diff --git a/custom.zsh b/custom.zsh index ea279a1..2f7db87 100644 --- a/custom.zsh +++ b/custom.zsh @@ -1,4 +1,3 @@ -ZSHCUSTOMDIR="${ZSHBASECFG}/custom" -source "${ZSHCUSTOMDIR}/dirstack.zsh" -source "${ZSHCUSTOMDIR}/prependsudo.zsh" -source "${ZSHCUSTOMDIR}/others.zsh" +source "${ZDOTDIR}/custom/dirstack.zsh" +source "${ZDOTDIR}/custom/prependsudo.zsh" +source "${ZDOTDIR}/custom/others.zsh" diff --git a/custom/others.zsh b/custom/others.zsh index 978fe45..d2909d0 100644 --- a/custom/others.zsh +++ b/custom/others.zsh @@ -19,23 +19,12 @@ function docker-all { function build-n-push { docker build ${1} --tag=localhost:5000/${2} --force-rm=true --compress=true && docker push localhost:5000/${2} } -function manpdf { - man -Tpdf $1 | okular - & - disown -} function gitsubrepo { find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \; } -function gitcom { - git add -A && git commit -am "$1" && git push -# git diff HEAD^ --compact-summary | while read LINE; do echo "$LINE"; done -} 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 ignorekate { - printf ".*~\n*.kate-swp" >> .gitignore -} function tonullpointer { if [ -z ${1} ]; then RANDFN=${RANDOM} @@ -50,16 +39,14 @@ function convert2gif { ffmpeg -hwaccel vdpau -i $1 -r 60 -vf "scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ${1%.*}.gif } function youtube2gif { - if [ -z ${1} ] || [ -z ${2} ] || [ -z ${3} ]; then - echo "Usage: youtube2gif [resolution] [framerate] [bitrate]"; - else - ffmpeg -ss ${2} -t ${3} -hwaccel vdpau -i $(youtube-dl -gf "bestvideo[height<=${4-360}]" ${1}) -r ${5-60} -vf "scale=${4-360}:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -b:v ${6-1000} -loop 0 -f gif -; - fi + ffmpeg -ss ${2} -t ${3} -hwaccel vdpau -i $(youtube-dl -gf "bestvideo[height<=${4-360}]" ${1}) -r ${5-60} -vf "scale=${4-360}:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 -f gif -; +} +function youtubecrop { + ffmpeg -ss $2 -t $3 -hwaccel vdpau -i $(youtube-dl -gf "best[height<=360]" "${1}") -r 60 -loop 0 $4 } alias recordscreen='ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -c:v libx264 -crf 0 -preset ultrafast' -alias ytdldown='youtube-dl -xcw --audio-format best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(artist)s/%(album)s/%(title)s.%(ext)s"' - +alias ytdldown='youtube-dl --no-part --newline -xcw --audio-format best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(album)s/%(artist)s/%(track)s.%(ext)s"' alias ls='ls --color=auto' alias grep='grep --color=auto' alias diff='diff --color=auto' diff --git a/preferences.zsh b/preferences.zsh index a4b8f9f..d07eaa6 100644 --- a/preferences.zsh +++ b/preferences.zsh @@ -4,7 +4,7 @@ SAVEHIST=1000 setopt appendhistory autocd extendedglob nomatch notify hist_ignore_all_dups hist_ignore_space nobeep if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then - source ${ZSHBASECFG}/powerlevel10k/powerlevel10k.zsh-theme + source ${ZDOTDIR}/powerlevel10k/powerlevel10k.zsh-theme [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( os_icon @@ -44,8 +44,8 @@ else prompt clint fi -source ${ZSHBASECFG}/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh +source ${ZDOTDIR}/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh -source ${ZSHBASECFG}/zsh-autosuggestions/zsh-autosuggestions.zsh +source ${ZDOTDIR}/zsh-autosuggestions/zsh-autosuggestions.zsh ZSH_AUTOSUGGEST_STRATEGY=(history completion) ZSH_AUTOSUGGEST_USE_ASYNC=true