From 8f4bff3514f31b88762e3b3e48773907f85265f8 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 11:06:38 +0100 Subject: use XDG base directories, set directories in .zshenv --- config/essentials/zsh/aliases.zsh | 2 + config/essentials/zsh/zshrc | 99 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 config/essentials/zsh/zshrc (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 33648a2..cfad09e 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -7,6 +7,8 @@ alias -g nb='newsboat' alias -g sr='surfraw' alias -g ccu='calcurse' +alias arduino-cli='arduino-cli --config-file $XDG_CONFIG_HOME/arduino15/arduino-cli.yaml' + if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" # alias ls='ls -h --color --group-directories-first' diff --git a/config/essentials/zsh/zshrc b/config/essentials/zsh/zshrc new file mode 100644 index 0000000..dd52e5e --- /dev/null +++ b/config/essentials/zsh/zshrc @@ -0,0 +1,99 @@ +#!/bin/zsh + +if [ ! $(pgrep Xorg) ] && [ "tty1" = "$(basename $(tty))" ] +then + clear + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --noask --eval --quiet --agents ssh 2> /dev/null)" + clear + startx 2&> /dev/null + exit +fi + +autoload -U select-word-style +autoload -z edit-command-line +zle -N edit-command-line +zstyle ':compinstall' filename '/home/aluc/.zshrc' +zstyle ':completion:*' menu select +autoload -Uz compinit +compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION +autoload -Uz surround +zle -N delete-surround surround +zle -N add-surround surround +zle -N change-surround surround +compinit + +for f in \ + /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh \ + /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh \ + ~/.config/zsh/functions.zsh \ + ~/.config/zsh/aliases.zsh +do + test -f $f && source $f +done + +bindkey -v +bindkey -a cs change-surround +bindkey -a ds delete-surround +bindkey -a ys add-surround +bindkey -M visual S add-surround +bindkey "^A" beginning-of-line +bindkey "^E" end-of-line +bindkey '^I' expand-or-complete-prefix # necessary for completeinword +bindkey '^Y' autosuggest-accept +bindkey "^K" kill-line +bindkey "^P" up-line-or-history +bindkey "^N" down-line-or-history +bindkey "^V" quoted-insert +bindkey "^Xa" _expand_alias +bindkey "^Xe" edit-command-line +bindkey "^[." insert-last-word +bindkey "^['" quote-line + +# pacman synced rehash +zshcache_time="$(date +%s%N)" +autoload -Uz add-zsh-hook +rehash_precmd() { + if [[ -a /var/cache/zsh/pacman ]]; then + local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)" + if (( zshcache_time < paccache_time )); then + rehash + zshcache_time="$paccache_time" + fi + fi +} +add-zsh-hook -Uz precmd rehash_precmd + +# prompt +PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' +RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' + +setopt prompt_subst +parse_git_remote() { + b="$(git branch -v 2> /dev/null | grep "^*" | sed 's/.\+\[\([^ ]\+\).*$/\1/')" + if [ "$b" = "behind" ] + then + echo -n "↓ " + elif [ "$b" = "ahead" ] + then + echo -n "↑ " + fi +} +parse_git_branch() { + git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null +} +parse_git_status() { + git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' +} + +# Options +setopt correct +setopt nonomatch +setopt autocd +setopt completeinword +setopt extendedglob +setopt histignorealldups +setopt histreduceblanks +setopt interactivecomments +setopt notify +setopt cdablevars -- cgit v1.2.3 From f167c3cd20e874da6160ac4d9c45c3a0c3011635 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 11:18:41 +0100 Subject: renamed zshrc to .zshrc to make xdg base dir work --- config/essentials/zsh/.zshrc | 99 ++++++++++++++++++++++++++++++++++++++++++++ config/essentials/zsh/zshrc | 99 -------------------------------------------- config/home/.zshenv | 3 -- 3 files changed, 99 insertions(+), 102 deletions(-) create mode 100644 config/essentials/zsh/.zshrc delete mode 100644 config/essentials/zsh/zshrc (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc new file mode 100644 index 0000000..dd52e5e --- /dev/null +++ b/config/essentials/zsh/.zshrc @@ -0,0 +1,99 @@ +#!/bin/zsh + +if [ ! $(pgrep Xorg) ] && [ "tty1" = "$(basename $(tty))" ] +then + clear + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --noask --eval --quiet --agents ssh 2> /dev/null)" + clear + startx 2&> /dev/null + exit +fi + +autoload -U select-word-style +autoload -z edit-command-line +zle -N edit-command-line +zstyle ':compinstall' filename '/home/aluc/.zshrc' +zstyle ':completion:*' menu select +autoload -Uz compinit +compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION +autoload -Uz surround +zle -N delete-surround surround +zle -N add-surround surround +zle -N change-surround surround +compinit + +for f in \ + /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh \ + /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh \ + ~/.config/zsh/functions.zsh \ + ~/.config/zsh/aliases.zsh +do + test -f $f && source $f +done + +bindkey -v +bindkey -a cs change-surround +bindkey -a ds delete-surround +bindkey -a ys add-surround +bindkey -M visual S add-surround +bindkey "^A" beginning-of-line +bindkey "^E" end-of-line +bindkey '^I' expand-or-complete-prefix # necessary for completeinword +bindkey '^Y' autosuggest-accept +bindkey "^K" kill-line +bindkey "^P" up-line-or-history +bindkey "^N" down-line-or-history +bindkey "^V" quoted-insert +bindkey "^Xa" _expand_alias +bindkey "^Xe" edit-command-line +bindkey "^[." insert-last-word +bindkey "^['" quote-line + +# pacman synced rehash +zshcache_time="$(date +%s%N)" +autoload -Uz add-zsh-hook +rehash_precmd() { + if [[ -a /var/cache/zsh/pacman ]]; then + local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)" + if (( zshcache_time < paccache_time )); then + rehash + zshcache_time="$paccache_time" + fi + fi +} +add-zsh-hook -Uz precmd rehash_precmd + +# prompt +PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' +RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' + +setopt prompt_subst +parse_git_remote() { + b="$(git branch -v 2> /dev/null | grep "^*" | sed 's/.\+\[\([^ ]\+\).*$/\1/')" + if [ "$b" = "behind" ] + then + echo -n "↓ " + elif [ "$b" = "ahead" ] + then + echo -n "↑ " + fi +} +parse_git_branch() { + git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null +} +parse_git_status() { + git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' +} + +# Options +setopt correct +setopt nonomatch +setopt autocd +setopt completeinword +setopt extendedglob +setopt histignorealldups +setopt histreduceblanks +setopt interactivecomments +setopt notify +setopt cdablevars diff --git a/config/essentials/zsh/zshrc b/config/essentials/zsh/zshrc deleted file mode 100644 index dd52e5e..0000000 --- a/config/essentials/zsh/zshrc +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/zsh - -if [ ! $(pgrep Xorg) ] && [ "tty1" = "$(basename $(tty))" ] -then - clear - eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" - eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --noask --eval --quiet --agents ssh 2> /dev/null)" - clear - startx 2&> /dev/null - exit -fi - -autoload -U select-word-style -autoload -z edit-command-line -zle -N edit-command-line -zstyle ':compinstall' filename '/home/aluc/.zshrc' -zstyle ':completion:*' menu select -autoload -Uz compinit -compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION -autoload -Uz surround -zle -N delete-surround surround -zle -N add-surround surround -zle -N change-surround surround -compinit - -for f in \ - /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh \ - /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh \ - ~/.config/zsh/functions.zsh \ - ~/.config/zsh/aliases.zsh -do - test -f $f && source $f -done - -bindkey -v -bindkey -a cs change-surround -bindkey -a ds delete-surround -bindkey -a ys add-surround -bindkey -M visual S add-surround -bindkey "^A" beginning-of-line -bindkey "^E" end-of-line -bindkey '^I' expand-or-complete-prefix # necessary for completeinword -bindkey '^Y' autosuggest-accept -bindkey "^K" kill-line -bindkey "^P" up-line-or-history -bindkey "^N" down-line-or-history -bindkey "^V" quoted-insert -bindkey "^Xa" _expand_alias -bindkey "^Xe" edit-command-line -bindkey "^[." insert-last-word -bindkey "^['" quote-line - -# pacman synced rehash -zshcache_time="$(date +%s%N)" -autoload -Uz add-zsh-hook -rehash_precmd() { - if [[ -a /var/cache/zsh/pacman ]]; then - local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)" - if (( zshcache_time < paccache_time )); then - rehash - zshcache_time="$paccache_time" - fi - fi -} -add-zsh-hook -Uz precmd rehash_precmd - -# prompt -PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' -RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' - -setopt prompt_subst -parse_git_remote() { - b="$(git branch -v 2> /dev/null | grep "^*" | sed 's/.\+\[\([^ ]\+\).*$/\1/')" - if [ "$b" = "behind" ] - then - echo -n "↓ " - elif [ "$b" = "ahead" ] - then - echo -n "↑ " - fi -} -parse_git_branch() { - git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null -} -parse_git_status() { - git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' -} - -# Options -setopt correct -setopt nonomatch -setopt autocd -setopt completeinword -setopt extendedglob -setopt histignorealldups -setopt histreduceblanks -setopt interactivecomments -setopt notify -setopt cdablevars diff --git a/config/home/.zshenv b/config/home/.zshenv index 00aab62..d9b3157 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -41,9 +41,6 @@ export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java export PASSWORD_STORE_CLIP_TIME=5 - -source "$ZDOTDIR"/zshrc - # old # export RANGER_LOAD_DEFAULT_RC=FALSE # export VIMINIT="source ~/.config/vim/vimrc" -- cgit v1.2.3 From 604692c73c31d3ff3c0057b70a106e97490eea90 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 12:16:07 +0100 Subject: added fzps alias --- config/essentials/zsh/aliases.zsh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index f532a5f..f13d3bb 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -116,6 +116,12 @@ alias -g cfdef='$EDITOR config.def.h' alias -g ff='`fzffile`' alias -g fd='`fzfdir`' alias -g fdf='`fzfdirfile`' +alias fzps='ps aux | tail +2 | fzf --bind \ +"1:execute(echo -n {} | awk '\''{print \$1}'\'' | xclip -sel c -r),\ +2:execute(echo -n {} | awk '\''{print \$2}'\'' | xclip -sel c -r),\ +3:execute(echo -n {} | awk '\''{print \$7}'\'' | xclip -sel c -r),\ +4:execute(echo -n {} | awk '\''{print \$9}'\'' | xclip -sel c -r),\ +5:execute(echo -n {} | tr -s '\'' '\'' | cut -f 11- -d '\'' '\'' | xclip -sel c -r)"' alias -s conf="$EDITOR" alias -s txt="$EDITOR" -- cgit v1.2.3 From da57f48abb29a572782e4274a75f76284c20b421 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 22:36:53 +0100 Subject: updated ytclipo to vids directory --- config/essentials/zsh/aliases.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index f13d3bb..1d3a54b 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -87,7 +87,7 @@ alias vidlen='ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i' alias whatsmyip='curl "ifconfig.me"' alias icognito='unset HISTFILE' alias penv='python -m venv' -alias ytclipo='yt-dlp "$(xclip -sel c -o)" -f "b" -S "res:720" -P $HOME/movies -o "%(title)s.%(ext)s"' +alias ytclipo='yt-dlp "$(xclip -sel c -o)" -f "b" -S "res:720" -P $HOME/vids -o "%(title)s.%(ext)s"' alias -g '...'='../..' alias -g '....'='../../..' -- cgit v1.2.3 From 37da47f677c280d80c5959896ce16e826dae9c89 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 22:37:26 +0100 Subject: updated zsh files to ZDOTDIT/ --- config/essentials/zsh/aliases.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 1d3a54b..493248d 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -99,13 +99,13 @@ alias -g pi='ping archlinux.org -c4' alias -g sba='source bin/activate' alias -g smc='systemctl' alias -g smcu='systemctl --user' -alias zsr='source ~/.zshrc && rehash' +alias zsr='source ${ZDOTDIR:-$HOME}/.zshrc && rehash' alias -g wf='doas wipefs -a' alias -g dmci="doas make clean install" # quick config -alias -g ez='$EDITOR ~/.zshrc' -alias -g eza='$EDITOR ~/.config/zsh/aliases.zsh' +alias -g ez='$EDITOR ${ZDOTDIR:-$HOME}/.zshrc' +alias -g eza='$EDITOR ${ZDOTDIR}/aliases.zsh' alias -g eto='$EDITOR ~/sync/TODO' alias -g edw='$EDITOR ~/src/dwm/config.def.h' alias -g edm='$EDITOR ~/src/dmenu/config.def.h' -- cgit v1.2.3 From 8d73085ec9575fb00b14956be8ae66081e98e714 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 9 Mar 2023 22:52:50 +0100 Subject: changed ytclipo alias to a script --- bin/common/ytclipo | 17 +++++++++++++++++ config/essentials/zsh/aliases.zsh | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 bin/common/ytclipo (limited to 'config/essentials/zsh') diff --git a/bin/common/ytclipo b/bin/common/ytclipo new file mode 100755 index 0000000..ee5bf0f --- /dev/null +++ b/bin/common/ytclipo @@ -0,0 +1,17 @@ +#!/bin/sh + +# argument ($1) -> clipboard -> stdin +test -z "${inp:=${1:-"$(xclip -sel c -o)"}}" \ + && inp="$(cat /dev/stdin)" + +echo "inp: ${inp}" 1>&2 +# take last link from clipboard +# works when link is from yt-local +inp="$(echo -n "$inp" | awk -F 'https?://' '{print $NF}')" +echo "inp: ${inp}" 1>&2 + +yt-dlp "$inp" \ + -f "b" \ + -S "res:720" \ + -P "$HOME/vids" \ + -o "%(title)s.%(ext)s" diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 493248d..411ae73 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -87,7 +87,6 @@ alias vidlen='ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i' alias whatsmyip='curl "ifconfig.me"' alias icognito='unset HISTFILE' alias penv='python -m venv' -alias ytclipo='yt-dlp "$(xclip -sel c -o)" -f "b" -S "res:720" -P $HOME/vids -o "%(title)s.%(ext)s"' alias -g '...'='../..' alias -g '....'='../../..' -- cgit v1.2.3 From 49dd890eeb0572f3f7f0d078507a53073d1275ae Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Fri, 10 Mar 2023 01:47:55 +0100 Subject: added go to dotfiles dir alias and fixed others --- config/essentials/zsh/aliases.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 411ae73..79de6a1 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -111,10 +111,11 @@ alias -g edm='$EDITOR ~/src/dmenu/config.def.h' alias -g est='$EDITOR ~/src/st/config.def.h' alias -g esl='$EDITOR ~/src/slock/config.def.h' alias -g cfdef='$EDITOR config.def.h' +alias -g cdo='$HOME/src/dotfiles' -alias -g ff='`fzffile`' -alias -g fd='`fzfdir`' -alias -g fdf='`fzfdirfile`' +alias -g ff='"`fzffile`"' +alias -g fd='"`fzfdir`"' +alias -g fdf='"`fzfdirfile`"' alias fzps='ps aux | tail +2 | fzf --bind \ "1:execute(echo -n {} | awk '\''{print \$1}'\'' | xclip -sel c -r),\ 2:execute(echo -n {} | awk '\''{print \$2}'\'' | xclip -sel c -r),\ -- cgit v1.2.3 From fab8d61418e2652881a56b586588f3373df5f971 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 12 Mar 2023 15:10:14 +0100 Subject: added l1 alias --- config/essentials/zsh/aliases.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 79de6a1..d9553e5 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -22,6 +22,7 @@ if [ -x /usr/bin/dircolors ]; then fi alias -g l='ls -l' +alias -g l1='ls -1' alias -g ll='ls -la' alias -g la='ls -aF' alias -g lst='ls --tree' -- cgit v1.2.3