diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..fb04142 --- /dev/null +++ b/.zshenv @@ -0,0 +1,2 @@ +export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH +export EDITOR=vim diff --git a/custom.zsh b/custom.zsh index 2f7db87..a3d3241 100644 --- a/custom.zsh +++ b/custom.zsh @@ -1,3 +1,7 @@ +source "${ZDOTDIR}/custom/aliases.zsh" source "${ZDOTDIR}/custom/dirstack.zsh" +source "${ZDOTDIR}/custom/docker.zsh" +source "${ZDOTDIR}/custom/functions.zsh" +source "${ZDOTDIR}/custom/gpg.zsh" source "${ZDOTDIR}/custom/prependsudo.zsh" -source "${ZDOTDIR}/custom/others.zsh" +source "${ZDOTDIR}/custom/segments.zsh" diff --git a/custom/aliases.zsh b/custom/aliases.zsh new file mode 100644 index 0000000..c026551 --- /dev/null +++ b/custom/aliases.zsh @@ -0,0 +1,5 @@ +alias recordscreen='ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -crf 0 -vf "deflate,mpdecimate"' +alias ytdldown='youtube-dl --no-part --newline -ixcw --audio-format best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(album)s/%(track)s.%(ext)s"' +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias diff='diff --color=auto' diff --git a/custom/docker.zsh b/custom/docker.zsh new file mode 100644 index 0000000..6e9beaf --- /dev/null +++ b/custom/docker.zsh @@ -0,0 +1,5 @@ +export DOCKER_HOST=ssh://nbg-0 + +function build-n-push { + docker build ${1} --tag=localhost:5000/${2} --force-rm --compress && docker push localhost:5000/${2} # --squash can eat disk space quickly due to diffs not being taken in calculation +} diff --git a/custom/functions.zsh b/custom/functions.zsh new file mode 100644 index 0000000..7f7a7ad --- /dev/null +++ b/custom/functions.zsh @@ -0,0 +1,47 @@ +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 tonullpointer { + if [ -z ${1} ]; then + RANDFN=${RANDOM} + > /tmp/${RANDFN} + curl -F"file=@/tmp/${RANDFN}" http://0x0.st + rm /tmp/${RANDFN} + else + curl -F"file=@${1}" http://0x0.st + fi +} +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 { + for i in {1..$1}; do + curl -sSLO --fail https://i.nhentai.net/galleries/${2}/${i}.png || \ + curl -sSLO --fail https://i.nhentai.net/galleries/${2}/${i}.jpg; + done + for i in {1..9}.*; do + mv $i 0$i; + done +} +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 "$@" +} +function interval { + typeset -g CTIME=$(date +%s) + [[ $(( $CTIME - ${LASTCTIME:=0} )) -gt 60 ]] && typeset -g LASTCTIME=$CTIME || return +} diff --git a/custom/gpg.zsh b/custom/gpg.zsh new file mode 100644 index 0000000..f617493 --- /dev/null +++ b/custom/gpg.zsh @@ -0,0 +1,7 @@ +# GPG SSH +unset SSH_AGENT_PID +if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" +fi +export GPG_TTY=$TTY +gpg-connect-agent updatestartuptty /bye >/dev/null diff --git a/custom/others.zsh b/custom/others.zsh deleted file mode 100644 index 88036e6..0000000 --- a/custom/others.zsh +++ /dev/null @@ -1,90 +0,0 @@ -export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH -export EDITOR=vim -export DOCKER_HOST=ssh://nbg-0 - -# GPG SSH -unset SSH_AGENT_PID -if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" -fi -export GPG_TTY=$(tty) -gpg-connect-agent updatestartuptty /bye >/dev/null - -function build-n-push { - docker build ${1} --tag=localhost:5000/${2} --force-rm --compress && docker push localhost:5000/${2} # --squash can eat disk space quickly due to diffs not being taken in calculation -} -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 tonullpointer { - if [ -z ${1} ]; then - RANDFN=${RANDOM} - > /tmp/${RANDFN} - curl -F"file=@/tmp/${RANDFN}" http://0x0.st - rm /tmp/${RANDFN} - else - curl -F"file=@${1}" http://0x0.st - fi -} -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 { - for i in {1..$1}; do - curl -sSLO --fail https://i.nhentai.net/galleries/${2}/${i}.png || \ - curl -sSLO --fail https://i.nhentai.net/galleries/${2}/${i}.jpg; - done - for i in {1..9}.*; do - mv $i 0$i; - done -} -alias recordscreen='ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -crf 0 -vf "deflate,mpdecimate"' -alias ytdldown='youtube-dl --no-part --newline -ixcw --audio-format best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(album)s/%(track)s.%(ext)s"' -alias ls='ls --color=auto' -alias grep='grep --color=auto' -alias diff='diff --color=auto' -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 "$@" -} -function interval { - typeset -g CTIME=$(date +%s) - [[ $(( $CTIME - ${LASTCTIME:=0} )) -gt 60 ]] && typeset -g LASTCTIME=$CTIME || return -} -function prompt_docker_host() { - p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST}" -} -typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker' -function prompt_dbus_mpris() { - typeset -g LASTRESP=${RESP:=0} - typeset -g RESP="$(qdbus org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata 2>/dev/null)" - if [[ $RESP != $LASTRESP ]]; then - RFMT="$(print ${RESP} | grep -oP '(?<=^xesam:title: ).+')" - ARTIST="$(print ${RESP} | grep -oP '(?<=^xesam:artist: ).+')" - [ ! -z ${ARTIST} ] && RFMT="${ARTIST} - ${RFMT}" - fi - p10k segment -b purple -i '' -t "${RFMT}" -c "${RFMT}" -} -function prompt_new_mail() { - interval && local MAILS=$(find ~/Mail/*/Inbox/new -type f | wc -l) - p10k segment -b yellow -i '' -t "${MAILS}" -c "${MAILS/#%0}" -} -function prompt_pacman_upgrade() { - interval && local PACKAGES=$(pacman -Qu | wc -l) - p10k segment -b cyan -i '' -t "${PACKAGES}" -c "${PACKAGES/#%0}" -} -typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman' diff --git a/custom/segments.zsh b/custom/segments.zsh new file mode 100644 index 0000000..2c79e46 --- /dev/null +++ b/custom/segments.zsh @@ -0,0 +1,23 @@ +function prompt_docker_host() { + p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST}" +} +typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker' +function prompt_dbus_mpris() { + typeset -g _mpris_LASTRESP=${_mpris_RESP:=0} + typeset -g _mpris_RESP="$(qdbus org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata 2>/dev/null)" + if [[ $_mpris_RESP != $_mpris_LASTRESP ]]; then + typeset -g _mpris_RFMT="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:title: ).+')" + local ARTIST="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:artist: ).+')" + [ ! -z ${ARTIST} ] && _mpris_RFMT="${ARTIST} - ${_mpris_RFMT}" + fi + p10k segment -b purple -i '' -t "${_mpris_RFMT}" -c "${_mpris_RFMT}" +} +function prompt_new_mail() { + interval && typeset -g _new_mail_MAILS=$(find ~/Mail/*/Inbox/new -type f | wc -l) + p10k segment -b yellow -i '' -t "${_new_mail_MAILS}" -c "${_new_mail_MAILS/#%0}" +} +function prompt_pacman_upgrade() { + interval && typeset -g _upgrade_PACKAGES=$(pacman -Qu | wc -l) + p10k segment -b cyan -i '' -t "${_upgrade_PACKAGES}" -c "${_upgrade_PACKAGES/#%0}" +} +typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman'