From 8aa0d0ff6187aeba7ffaab5f3503e4c388d22ada Mon Sep 17 00:00:00 2001 From: Uyanide Date: Tue, 26 May 2026 15:01:41 +0200 Subject: [PATCH] update --- assets/yazi-catppuccin | 2 +- .../.config/zsh/conf.d/02-completions.zsh | 6 +- .../shell/.config/zsh/conf.d/03-plugins.zsh | 16 +- config/shell/.config/zsh/conf.d/10-done.zsh | 74 ++--- config/shell/.config/zsh/conf.d/10-env.zsh | 24 +- config/shell/.config/zsh/conf.d/10-oops.zsh | 84 ++--- config/shell/.config/zsh/conf.d/10-sshs.zsh | 22 +- config/shell/.config/zsh/conf.d/60-alias.zsh | 302 +++++++++--------- config/shell/.config/zsh/conf.d/60-fetch.zsh | 56 ++-- 9 files changed, 293 insertions(+), 293 deletions(-) diff --git a/assets/yazi-catppuccin b/assets/yazi-catppuccin index fc69d64..41f24ed 160000 --- a/assets/yazi-catppuccin +++ b/assets/yazi-catppuccin @@ -1 +1 @@ -Subproject commit fc69d6472d29b823c4980d23186c9c120a0ad32c +Subproject commit 41f24ed142e34109a9a65a5dfe58c1b4eb6d2fd9 diff --git a/config/shell/.config/zsh/conf.d/02-completions.zsh b/config/shell/.config/zsh/conf.d/02-completions.zsh index ad26881..6c8369b 100644 --- a/config/shell/.config/zsh/conf.d/02-completions.zsh +++ b/config/shell/.config/zsh/conf.d/02-completions.zsh @@ -1,5 +1,5 @@ if [ -d "$HOME/.zfunc" ]; then - fpath=($HOME/.zfunc $fpath) + fpath=($HOME/.zfunc $fpath) fi if [ -d "$HOME/.zsh/completions" ]; then @@ -9,9 +9,9 @@ fi # Cache compinit: only regenerate dump once daily autoload -Uz compinit if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+24) ]]; then - compinit + compinit else - compinit -C + compinit -C fi zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' diff --git a/config/shell/.config/zsh/conf.d/03-plugins.zsh b/config/shell/.config/zsh/conf.d/03-plugins.zsh index dfcd972..2fcdc6c 100644 --- a/config/shell/.config/zsh/conf.d/03-plugins.zsh +++ b/config/shell/.config/zsh/conf.d/03-plugins.zsh @@ -2,19 +2,19 @@ _uy_antidote_dir="${XDG_DATA_HOME:-$HOME/.local/share}/antidote" # Find antidote: system package → user-local clone → auto-bootstrap if [[ -f /usr/share/zsh-antidote/antidote.zsh ]]; then - source /usr/share/zsh-antidote/antidote.zsh + source /usr/share/zsh-antidote/antidote.zsh elif [[ -f "$_uy_antidote_dir/antidote.zsh" ]]; then - source "$_uy_antidote_dir/antidote.zsh" + source "$_uy_antidote_dir/antidote.zsh" elif (( $+commands[git] )); then - git clone --depth=1 https://github.com/mattmc3/antidote.git "$_uy_antidote_dir" - source "$_uy_antidote_dir/antidote.zsh" + git clone --depth=1 https://github.com/mattmc3/antidote.git "$_uy_antidote_dir" + source "$_uy_antidote_dir/antidote.zsh" fi if (( $+functions[antidote] )); then - _uy_zsh_plugins="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_plugins.txt" - if [[ -f "$_uy_zsh_plugins" ]]; then - antidote load "$_uy_zsh_plugins" - fi + _uy_zsh_plugins="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_plugins.txt" + if [[ -f "$_uy_zsh_plugins" ]]; then + antidote load "$_uy_zsh_plugins" + fi fi unset _uy_antidote_dir _uy_zsh_plugins diff --git a/config/shell/.config/zsh/conf.d/10-done.zsh b/config/shell/.config/zsh/conf.d/10-done.zsh index 8bf8933..5917523 100644 --- a/config/shell/.config/zsh/conf.d/10-done.zsh +++ b/config/shell/.config/zsh/conf.d/10-done.zsh @@ -10,56 +10,56 @@ zmodload zsh/datetime : ${uy_done_exclude:='^(nvim|helix|hx|vim|vi|nano|less|more|man|ssh|top|htop|btop)$'} uy_done_get_focused_window_id() { - (( $+commands[jq] )) || return - niri msg --json focused-window 2>/dev/null | jq -r '.id // empty' + (( $+commands[jq] )) || return + niri msg --json focused-window 2>/dev/null | jq -r '.id // empty' } uy_done_preexec() { - uy_done_cmd="$1" - uy_done_start=$EPOCHSECONDS - uy_done_window_id=$(uy_done_get_focused_window_id) + uy_done_cmd="$1" + uy_done_start=$EPOCHSECONDS + uy_done_window_id=$(uy_done_get_focused_window_id) } uy_done_precmd() { - local exit_status=$? - [[ -n "$uy_done_start" ]] || return + local exit_status=$? + [[ -n "$uy_done_start" ]] || return - local elapsed=$(( EPOCHSECONDS - uy_done_start )) - unset uy_done_start + local elapsed=$(( EPOCHSECONDS - uy_done_start )) + unset uy_done_start - (( elapsed >= uy_done_min_cmd_duration )) || return + (( elapsed >= uy_done_min_cmd_duration )) || return - # skip excluded commands - local cmd_name="${uy_done_cmd%% *}" - [[ "$cmd_name" =~ $uy_done_exclude ]] && return + # skip excluded commands + local cmd_name="${uy_done_cmd%% *}" + [[ "$cmd_name" =~ $uy_done_exclude ]] && return - # skip if window is still focused - local current_id - current_id=$(uy_done_get_focused_window_id) - [[ -n "$uy_done_window_id" && "$uy_done_window_id" = "$current_id" ]] && return + # skip if window is still focused + local current_id + current_id=$(uy_done_get_focused_window_id) + [[ -n "$uy_done_window_id" && "$uy_done_window_id" = "$current_id" ]] && return - # humanize duration - local title duration="" urgency=low - local minutes=$(( elapsed / 60 )) seconds=$(( elapsed % 60 )) - local hours=$(( elapsed / 3600 )) - (( hours > 0 )) && duration+="${hours}h " - (( minutes > 0 )) && duration+="$(( minutes % 60 ))m " - duration+="${seconds}s" + # humanize duration + local title duration="" urgency=low + local minutes=$(( elapsed / 60 )) seconds=$(( elapsed % 60 )) + local hours=$(( elapsed / 3600 )) + (( hours > 0 )) && duration+="${hours}h " + (( minutes > 0 )) && duration+="$(( minutes % 60 ))m " + duration+="${seconds}s" - local wd="${PWD/#$HOME/~}" - if (( exit_status == 0 )); then - title="Done in $duration" - else - title="Failed ($exit_status) after $duration" - urgency=critical - fi + local wd="${PWD/#$HOME/~}" + if (( exit_status == 0 )); then + title="Done in $duration" + else + title="Failed ($exit_status) after $duration" + urgency=critical + fi - notify-send \ - --hint=int:transient:1 \ - --urgency="$urgency" \ - --icon=utilities-terminal \ - --app-name=zsh \ - "$title" "$wd/ $uy_done_cmd" & + notify-send \ + --hint=int:transient:1 \ + --urgency="$urgency" \ + --icon=utilities-terminal \ + --app-name=zsh \ + "$title" "$wd/ $uy_done_cmd" & } autoload -Uz add-zsh-hook diff --git a/config/shell/.config/zsh/conf.d/10-env.zsh b/config/shell/.config/zsh/conf.d/10-env.zsh index 8ca0d1e..76d4622 100644 --- a/config/shell/.config/zsh/conf.d/10-env.zsh +++ b/config/shell/.config/zsh/conf.d/10-env.zsh @@ -1,29 +1,29 @@ # MANPAGER if (( $+commands[bat] )); then - export MANPAGER="sh -c 'col -bx | bat -l man -p'" - export MANROFFOPT=-c + export MANPAGER="sh -c 'col -bx | bat -l man -p'" + export MANROFFOPT=-c fi # Editor for _uy_app in nvim helix vim vi nano; do - if (( $+commands[$_uy_app] )); then - export EDITOR=$_uy_app - export VISUAL=$_uy_app - break - fi + if (( $+commands[$_uy_app] )); then + export EDITOR=$_uy_app + export VISUAL=$_uy_app + break + fi done unset _uy_app if (( $+commands[helix] )) && ! (( $+commands[hx] )); then - alias hx=helix + alias hx=helix fi # GPG if (( $+commands[gpg] )); then - export GPG_TTY=$(tty) + export GPG_TTY=$(tty) fi # Catppuccin Mocha — autosuggestions color @@ -39,12 +39,12 @@ fi # fnm if (( $+commands[fnm] )); then - eval "$(fnm env --shell zsh --use-on-cd)" + eval "$(fnm env --shell zsh --use-on-cd)" fi # bat if (( $+commands[bat] )); then - export BAT_THEME="Catppuccin Mocha" - export BAT_STYLE="default,-numbers" + export BAT_THEME="Catppuccin Mocha" + export BAT_STYLE="default,-numbers" fi diff --git a/config/shell/.config/zsh/conf.d/10-oops.zsh b/config/shell/.config/zsh/conf.d/10-oops.zsh index 24da9ee..4677018 100644 --- a/config/shell/.config/zsh/conf.d/10-oops.zsh +++ b/config/shell/.config/zsh/conf.d/10-oops.zsh @@ -1,54 +1,54 @@ # Remove the last command from history (both memory and file). # The alias has a leading space so "oops" itself is not recorded (HIST_IGNORE_SPACE). uy_oops_confirm() { - # Flush current session to file so we operate on the latest state - fc -W + # Flush current session to file so we operate on the latest state + fc -W - if [[ ! -f "$HISTFILE" || ! -s "$HISTFILE" ]]; then - print -P "%F{yellow}History is empty, nothing to delete.%f" - return 1 - fi + if [[ ! -f "$HISTFILE" || ! -s "$HISTFILE" ]]; then + print -P "%F{yellow}History is empty, nothing to delete.%f" + return 1 + fi - # Read the last entry (may span multiple lines if it ends with \) - local -a entry - local line - while IFS= read -r line; do - entry+=("$line") - # EXTENDED_HISTORY continuation lines end with a literal backslash - [[ "$line" == *'\' ]] || break - done < <(tail -n 50 "$HISTFILE" | tac) - # entry is reversed (last line first), flip it back - local -a ordered - for (( i=${#entry[@]}; i>=1; i-- )); do - ordered+=("${entry[$i]}") - done + # Read the last entry (may span multiple lines if it ends with \) + local -a entry + local line + while IFS= read -r line; do + entry+=("$line") + # EXTENDED_HISTORY continuation lines end with a literal backslash + [[ "$line" == *'\' ]] || break + done < <(tail -n 50 "$HISTFILE" | tac) + # entry is reversed (last line first), flip it back + local -a ordered + for (( i=${#entry[@]}; i>=1; i-- )); do + ordered+=("${entry[$i]}") + done - if (( ${#ordered[@]} == 0 )); then - print -P "%F{yellow}Could not parse last history entry.%f" - return 1 - fi + if (( ${#ordered[@]} == 0 )); then + print -P "%F{yellow}Could not parse last history entry.%f" + return 1 + fi - print -P "About to permanently delete the last command from history:" - for line in "${ordered[@]}"; do - print -P " %F{red}${line}%f" - done + print -P "About to permanently delete the last command from history:" + for line in "${ordered[@]}"; do + print -P " %F{red}${line}%f" + done - local reply - echo -n "Proceed? [Y/n] " - read -r reply + local reply + echo -n "Proceed? [Y/n] " + read -r reply - if [[ -z "$reply" || "$reply" == [yY]* ]]; then - # Delete the last N lines (the full entry) from the file - local n=${#ordered[@]} - head -n -"$n" "$HISTFILE" > "$HISTFILE.tmp" && mv "$HISTFILE.tmp" "$HISTFILE" - # Reload history from the updated file - fc -R - print -P "%F{green}Deleted ($n line(s) removed).%f" - else - # Reload anyway to stay in sync - fc -R - print -P "%F{yellow}Cancelled.%f" - fi + if [[ -z "$reply" || "$reply" == [yY]* ]]; then + # Delete the last N lines (the full entry) from the file + local n=${#ordered[@]} + head -n -"$n" "$HISTFILE" > "$HISTFILE.tmp" && mv "$HISTFILE.tmp" "$HISTFILE" + # Reload history from the updated file + fc -R + print -P "%F{green}Deleted ($n line(s) removed).%f" + else + # Reload anyway to stay in sync + fc -R + print -P "%F{yellow}Cancelled.%f" + fi } alias oops=' uy_oops_confirm' diff --git a/config/shell/.config/zsh/conf.d/10-sshs.zsh b/config/shell/.config/zsh/conf.d/10-sshs.zsh index f338f7e..bf56012 100644 --- a/config/shell/.config/zsh/conf.d/10-sshs.zsh +++ b/config/shell/.config/zsh/conf.d/10-sshs.zsh @@ -3,17 +3,17 @@ if [[ "${UY_ENABLE_GPG_AGENT_SSH:-0}" = "1" ]] && (( $+commands[gpg-init] )) && (( $+commands[gpgconf] )); then - : # GPG agent handles SSH — nothing to do + : # GPG agent handles SSH — nothing to do elif [[ "${UY_USING_SSH_AGENT:-0}" = "1" ]]; then - sshs() { - if ! ssh-add -l &>/dev/null; then - if [[ -n "${uy_ssh_keys[*]}" ]]; then - ssh-add "${uy_ssh_keys[@]}" - else - ssh-add - fi - fi - ssh "$@" - } + sshs() { + if ! ssh-add -l &>/dev/null; then + if [[ -n "${uy_ssh_keys[*]}" ]]; then + ssh-add "${uy_ssh_keys[@]}" + else + ssh-add + fi + fi + ssh "$@" + } fi diff --git a/config/shell/.config/zsh/conf.d/60-alias.zsh b/config/shell/.config/zsh/conf.d/60-alias.zsh index d40400c..d5a56e9 100644 --- a/config/shell/.config/zsh/conf.d/60-alias.zsh +++ b/config/shell/.config/zsh/conf.d/60-alias.zsh @@ -1,95 +1,95 @@ # fzf if (( $+commands[fzf] )); then - source <(fzf --zsh) + source <(fzf --zsh) - # use fd if available (search cwd only, skip vcs/cache junk) - if (( $+commands[fd] )); then - export FD_CMD="fd" - elif (( $+commands[fdfind] )); then - export FD_CMD="fdfind" - fi - if [[ -n "$FD_CMD" ]]; then - export FZF_DEFAULT_COMMAND="$FD_CMD --type f --hidden --exclude .git" - export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" - export FZF_ALT_C_COMMAND="$FD_CMD --type d --hidden --exclude .git" - fi + # use fd if available (search cwd only, skip vcs/cache junk) + if (( $+commands[fd] )); then + export FD_CMD="fd" + elif (( $+commands[fdfind] )); then + export FD_CMD="fdfind" + fi + if [[ -n "$FD_CMD" ]]; then + export FZF_DEFAULT_COMMAND="$FD_CMD --type f --hidden --exclude .git" + export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + export FZF_ALT_C_COMMAND="$FD_CMD --type d --hidden --exclude .git" + fi - # C-y to copy fzf's output - if (( $+commands[wl-copy] )); then - export FZF_DEFAULT_OPTS="--bind \"ctrl-y:execute-silent(echo -n {+} | wl-copy)+abort\"" - fi + # C-y to copy fzf's output + if (( $+commands[wl-copy] )); then + export FZF_DEFAULT_OPTS="--bind \"ctrl-y:execute-silent(echo -n {+} | wl-copy)+abort\"" + fi - # fz: fuzzy find a file and preview - if (( $+commands[bat] )); then - alias fz="fzf --preview 'bat --style=numbers --color=always {}'" - else - alias fz="fzf --preview 'cat -n {}'" - fi + # fz: fuzzy find a file and preview + if (( $+commands[bat] )); then + alias fz="fzf --preview 'bat --style=numbers --color=always {}'" + else + alias fz="fzf --preview 'cat -n {}'" + fi - # fe: fuzzy find a file and edit using $EDITOR - fe() { - local file - file=$(fz --header "[edit with $EDITOR]") - [[ -n "$file" ]] && $EDITOR "$file" - } + # fe: fuzzy find a file and edit using $EDITOR + fe() { + local file + file=$(fz --header "[edit with $EDITOR]") + [[ -n "$file" ]] && $EDITOR "$file" + } - # fkp: fuzzy find a process and kill - fkp() { - local pids - pids=$(ps -ef | fzf -m --header-lines 1 --preview 'pstree -p $(echo {} | awk "{print \$2}")' --header "[kill process]" | awk '{print $2}') - echo "$pids" | xargs -r kill -${1:-9} - } + # fkp: fuzzy find a process and kill + fkp() { + local pids + pids=$(ps -ef | fzf -m --header-lines 1 --preview 'pstree -p $(echo {} | awk "{print \$2}")' --header "[kill process]" | awk '{print $2}') + echo "$pids" | xargs -r kill -${1:-9} + } - # fks: fuzzy find a TCP process and kill - if (( $+commands[ss] )); then - fks() { - local pids - # Call sudo separately since one cannot enter password in fzf's window - pids=$(sudo ss -lptn) - pids=$(echo "$pids" | fzf -m --header-lines 1 --header "[kill process]" | grep -oP 'pid=\K\d+') - echo "$pids" | xargs -r sudo kill -${1:-9} - } - fi + # fks: fuzzy find a TCP process and kill + if (( $+commands[ss] )); then + fks() { + local pids + # Call sudo separately since one cannot enter password in fzf's window + pids=$(sudo ss -lptn) + pids=$(echo "$pids" | fzf -m --header-lines 1 --header "[kill process]" | grep -oP 'pid=\K\d+') + echo "$pids" | xargs -r sudo kill -${1:-9} + } + fi - if (( $+commands[yay] )); then - # fyq: fuzzy yay local query - alias fyq="yay -Qq | fzf --preview 'yay -Qi {}' --preview-window='right,70%,wrap'" + if (( $+commands[yay] )); then + # fyq: fuzzy yay local query + alias fyq="yay -Qq | fzf --preview 'yay -Qi {}' --preview-window='right,70%,wrap'" - # fyi: fuzzy yay install - fyi() { - local pkg - pkg=$(yay -Sl | awk '{print $1"/"$2}' | fzf -m --preview 'yay -Si {}' --preview-window='right,70%,wrap' --header "[install package]" "$@") - # yay supports "repo/package" format - [[ -n "$pkg" ]] && yay -S ${=pkg} - } + # fyi: fuzzy yay install + fyi() { + local pkg + pkg=$(yay -Sl | awk '{print $1"/"$2}' | fzf -m --preview 'yay -Si {}' --preview-window='right,70%,wrap' --header "[install package]" "$@") + # yay supports "repo/package" format + [[ -n "$pkg" ]] && yay -S ${=pkg} + } - # fyr: fuzzy yay remove - fyr() { - local pkg - pkg=$(yay -Qq | fzf -m --preview 'yay -Qi {}' --preview-window='right,70%,wrap' --header "[remove package]" "$@") - [[ -n "$pkg" ]] && yay -Rn ${=pkg} - } - fi + # fyr: fuzzy yay remove + fyr() { + local pkg + pkg=$(yay -Qq | fzf -m --preview 'yay -Qi {}' --preview-window='right,70%,wrap' --header "[remove package]" "$@") + [[ -n "$pkg" ]] && yay -Rn ${=pkg} + } + fi fi # cd (zoxide) if (( $+commands[zoxide] )); then - eval "$(zoxide init zsh)" - alias cd=z + eval "$(zoxide init zsh)" + alias cd=z fi # ls if (( $+commands[eza] )); then - alias ll="eza -lh --group-directories-first --icons=auto" - alias la="eza -lh --group-directories-first --icons=auto --all" - alias lt="eza --tree --level=2 --long --icons --git" + alias ll="eza -lh --group-directories-first --icons=auto" + alias la="eza -lh --group-directories-first --icons=auto --all" + alias lt="eza --tree --level=2 --long --icons --git" else - alias ls="ls --color=auto" - alias ll="ls -lh --group-directories-first --color=auto" - alias la="ls -lah --group-directories-first --color=auto" + alias ls="ls --color=auto" + alias ll="ls -lh --group-directories-first --color=auto" + alias la="ls -lah --group-directories-first --color=auto" fi # directories @@ -110,29 +110,29 @@ alias diff="diff --color=auto" # copy copy() { - if [[ $# -eq 2 && -d "$1" ]]; then - command cp -r "${1%/}" "$2" - else - command cp "$@" - fi + if [[ $# -eq 2 && -d "$1" ]]; then + command cp -r "${1%/}" "$2" + else + command cp "$@" + fi } # wget if (( $+commands[wget] )); then - alias wget="wget -c " + alias wget="wget -c " fi # pacman if (( $+commands[expac] )); then - alias big="expac -H M '%m\t%n' | sort -h | nl" + alias big="expac -H M '%m\t%n' | sort -h | nl" fi # clock if (( $+commands[tty-clock] )); then - alias clock="tty-clock -c -C 4" + alias clock="tty-clock -c -C 4" fi # journalctl @@ -142,8 +142,8 @@ alias jctl="journalctl -p 3 -xb" # nohup nh() { - nohup "$@" >/dev/null 2>&1 & - disown + nohup "$@" >/dev/null 2>&1 & + disown } # ffmpeg @@ -154,92 +154,92 @@ alias ffprobe="ffprobe -hide_banner" # git if (( $+commands[git] )); then - gcp() { - git add -A || return 1 - if [[ $# -eq 0 ]]; then - git commit -m "👐 foo:)" || return 1 - else - git commit -m "$*" || return 1 - fi - git push - } + gcp() { + git add -A || return 1 + if [[ $# -eq 0 ]]; then + git commit -m "👐 foo:)" || return 1 + else + git commit -m "$*" || return 1 + fi + git push + } - if (( $+commands[wl-paste] )); then - # Get a git repo URL from clipboard, prompting if invalid - uy_git_repo_from_clipboard() { - local repo - repo=$(wl-paste) - if [[ ! "$repo" =~ '^(http|https|git|ssh)://|^git@' ]]; then - echo "Error: Clipboard does not contain a valid git repository URL." >&2 - echo "Error: Clipboard content: $repo" >&2 - read "repo?Enter a valid git repository URL: " - if [[ ! "$repo" =~ '^(http|https|git|ssh)://|^git@' ]]; then - echo "Error: Invalid git repository URL." >&2 - return 1 - fi - fi - print -r -- "$repo" - } + if (( $+commands[wl-paste] )); then + # Get a git repo URL from clipboard, prompting if invalid + uy_git_repo_from_clipboard() { + local repo + repo=$(wl-paste) + if [[ ! "$repo" =~ '^(http|https|git|ssh)://|^git@' ]]; then + echo "Error: Clipboard does not contain a valid git repository URL." >&2 + echo "Error: Clipboard content: $repo" >&2 + read "repo?Enter a valid git repository URL: " + if [[ ! "$repo" =~ '^(http|https|git|ssh)://|^git@' ]]; then + echo "Error: Invalid git repository URL." >&2 + return 1 + fi + fi + print -r -- "$repo" + } - gcl() { - local repo - repo=$(uy_git_repo_from_clipboard) || return 1 - git clone "$repo" - } + gcl() { + local repo + repo=$(uy_git_repo_from_clipboard) || return 1 + git clone "$repo" + } - pingo() { - builtin cd "$HOME/Repositories/Uni" || return 1 - local repo - repo=$(uy_git_repo_from_clipboard) || return 1 - local dir_name="${repo:t:r}" - local course="${${dir_name%%[^[:lower:]]*}:u}" - mkdir -p "$course" - builtin cd "$course" || return 1 - if [[ ! -d "$dir_name" ]]; then - git clone "$repo" || return 1 - fi - builtin cd "$dir_name" - local app="$1" - if [[ -n "$app" ]] && (( $+commands[$app] )); then - echo "Opening project with $app" - # nohup "$app" . >/dev/null 2>&1 & - # disown - if [[ ${XDG_CURRENT_DESKTOP:-} = "niri" ]]; then - niri msg action spawn -- "$app" "$HOME/Repositories/Uni/$course/$dir_name" - else - nohup "$app" . >/dev/null 2>&1 & - disown - fi - fi - } - fi + pingo() { + builtin cd "$HOME/Repositories/Uni" || return 1 + local repo + repo=$(uy_git_repo_from_clipboard) || return 1 + local dir_name="${repo:t:r}" + local course="${${dir_name%%[^[:lower:]]*}:u}" + mkdir -p "$course" + builtin cd "$course" || return 1 + if [[ ! -d "$dir_name" ]]; then + git clone "$repo" || return 1 + fi + builtin cd "$dir_name" + local app="$1" + if [[ -n "$app" ]] && (( $+commands[$app] )); then + echo "Opening project with $app" + # nohup "$app" . >/dev/null 2>&1 & + # disown + if [[ ${XDG_CURRENT_DESKTOP:-} = "niri" ]]; then + niri msg action spawn -- "$app" "$HOME/Repositories/Uni/$course/$dir_name" + else + nohup "$app" . >/dev/null 2>&1 & + disown + fi + fi + } + fi fi # jj if (( $+commands[jj] )); then - jjc() { - jj describe -m "$*" - jj new - } + jjc() { + jj describe -m "$*" + jj new + } - jjp() { - default_branch() { - git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|.*/||' \ - || git remote show origin | awk '/HEAD branch/ {print $NF}' || echo "master" - } - local branch pos - branch=${1:-$(default_branch)} - pos=${2:-@-} - jj bookmark move "$branch" --to "$pos" - jj git push - } + jjp() { + default_branch() { + git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|.*/||' \ + || git remote show origin | awk '/HEAD branch/ {print $NF}' || echo "master" + } + local branch pos + branch=${1:-$(default_branch)} + pos=${2:-@-} + jj bookmark move "$branch" --to "$pos" + jj git push + } fi # Global aliases (can be used as part of a command) # wl-paste if (( $+commands[wl-paste] )); then - alias -g C="| wl-copy" + alias -g C="| wl-copy" fi # Redirects diff --git a/config/shell/.config/zsh/conf.d/60-fetch.zsh b/config/shell/.config/zsh/conf.d/60-fetch.zsh index ebf9bd4..a30e290 100644 --- a/config/shell/.config/zsh/conf.d/60-fetch.zsh +++ b/config/shell/.config/zsh/conf.d/60-fetch.zsh @@ -1,15 +1,15 @@ # Detect logo capability if [[ -z "$uy_fetch_logo_type" ]]; then - if (( $+commands[kgp-query] )) && kgp-query 2>/dev/null; then - uy_fetch_logo_type=kitty - elif (( $+commands[sixel-query] )) && sixel-query 2>/dev/null; then - uy_fetch_logo_type=sixel - elif (( $+commands[kgp-query] )) || (( $+commands[sixel-query] )); then - uy_fetch_logo_type=logo - else - uy_fetch_logo_type=auto - fi + if (( $+commands[kgp-query] )) && kgp-query 2>/dev/null; then + uy_fetch_logo_type=kitty + elif (( $+commands[sixel-query] )) && sixel-query 2>/dev/null; then + uy_fetch_logo_type=sixel + elif (( $+commands[kgp-query] )) || (( $+commands[sixel-query] )); then + uy_fetch_logo_type=logo + else + uy_fetch_logo_type=auto + fi fi : ${uy_fetch_color:="38;2;137;180;250"} @@ -18,37 +18,37 @@ fi case "$uy_fetch_logo_type" in symbols) - uy_fetch_args=(--logo-type raw --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/42x.symbols" --color "$uy_fetch_color") - uy_fetch_args_brief=(--logo-type raw --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/28x.symbols" --color "$uy_fetch_color") - ;; + uy_fetch_args=(--logo-type raw --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/42x.symbols" --color "$uy_fetch_color") + uy_fetch_args_brief=(--logo-type raw --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/28x.symbols" --color "$uy_fetch_color") + ;; logo) - uy_fetch_args=(--logo-type builtin) - uy_fetch_args_brief=(--logo-type small) - ;; + uy_fetch_args=(--logo-type builtin) + uy_fetch_args_brief=(--logo-type small) + ;; sixel) - uy_fetch_args=(--logo-type raw --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/42x.sixel" --color "$uy_fetch_color") - uy_fetch_args_brief=(--logo-type raw --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/28x.sixel" --color "$uy_fetch_color") - ;; + uy_fetch_args=(--logo-type raw --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/42x.sixel" --color "$uy_fetch_color") + uy_fetch_args_brief=(--logo-type raw --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/28x.sixel" --color "$uy_fetch_color") + ;; *) # kitty, auto, etc. - uy_fetch_args=(--logo-type "$uy_fetch_logo_type" --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/ros.png" --color "$uy_fetch_color") - uy_fetch_args_brief=(--logo-type "$uy_fetch_logo_type" --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/ros.png" --color "$uy_fetch_color") - ;; + uy_fetch_args=(--logo-type "$uy_fetch_logo_type" --logo-width 42 --logo "$HOME/.config/fastfetch/logo_ros/ros.png" --color "$uy_fetch_color") + uy_fetch_args_brief=(--logo-type "$uy_fetch_logo_type" --logo-width 28 --logo "$HOME/.config/fastfetch/logo_ros/ros.png" --color "$uy_fetch_color") + ;; esac # Functions if (( $+commands[fastfetch] )); then - ff() { fastfetch -c "$HOME/.config/fastfetch/config.jsonc" "${uy_fetch_args[@]}" "$@"; } + ff() { fastfetch -c "$HOME/.config/fastfetch/config.jsonc" "${uy_fetch_args[@]}" "$@"; } - if [[ -f "$HOME/.config/fastfetch/brief.jsonc" ]]; then - ffb() { fastfetch -c "$HOME/.config/fastfetch/brief.jsonc" "${uy_fetch_args_brief[@]}" "$@"; } - else - ffb() { ff "$@"; } - fi + if [[ -f "$HOME/.config/fastfetch/brief.jsonc" ]]; then + ffb() { fastfetch -c "$HOME/.config/fastfetch/brief.jsonc" "${uy_fetch_args_brief[@]}" "$@"; } + else + ffb() { ff "$@"; } + fi fi # Auto-fetch on startup if [[ -z "$uy_no_fetch" ]] && (( $+functions[ffb] )); then - ffb + ffb fi