diff options
Diffstat (limited to 'fedora')
55 files changed, 7655 insertions, 1821 deletions
diff --git a/fedora/.config/bash/autocomplete.bash b/fedora/.config/bash/autocomplete.bash index 0aeeedd..3ee6183 100644 --- a/fedora/.config/bash/autocomplete.bash +++ b/fedora/.config/bash/autocomplete.bash @@ -147,7 +147,7 @@ expand_alias_and_accept_line() { # Bind Space to our function so pressing space triggers alias-expansion behavior. # Use bind -x to call expand_alias_space (it will both expand and insert space when appropriate). # WARNING: this overrides normal space key behavior; our function handles insertion. -bind -x '" "':expand_alias_space +# bind -x '" "':expand_alias_space # optional: bind Ctrl-Space to the same (a bypass key like zsh had) # Many terminals send "\C-@" for ctrl-space; try both common sequences: @@ -169,7 +169,7 @@ _bash_accept_line() { # (This is a conservative behavior to avoid interfering unexpectedly.) return 0 } -bind -x '"\C-m":_bash_accept_line' +#bind -x '"\C-m":_bash_accept_line' # ---------- helper: background starter ---------- background() { diff --git a/fedora/.config/bash/bash_profile b/fedora/.config/bash/bash_profile index 068e3f5..326174d 100644 --- a/fedora/.config/bash/bash_profile +++ b/fedora/.config/bash/bash_profile @@ -1,34 +1,114 @@ -#!/bin/sh +#!/bin/bash umask 022 -####################################################### -# EXPORTS -####################################################### +################################################### +### --- LANG --- ### +################################################### +export LANG=ko_KR.UTF-8 +export LC_CTYPE=ko_KR.UTF-8 + +################################################### +### --- DEFAULT PROGRAMS --- ### +################################################### +if command -v nvim >/dev/null 2>&1; then + export EDITOR="nvim" +elif command -v vim >/dev/null 2>&1; then + export EDITOR="vim" +else + export EDITOR="vi" +fi +# export FILE_MANAGER="lf $(lf -version)" +export KEYTIMEOUT=10 +export SUDO_EDITOR=$EDITOR +export TERM="xterm-256color" +export VISUAL=$EDITOR +export TERM="xterm-256color" +export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | . $MYGVIMRC' +export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | . $MYVIMRC' +################################################### +### --- XDG ENV PATHES --- ### +################################################### +### --- XDG DEFAULT --- ### export XDG_CACHE_HOME="$HOME/.cache" export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" + +### --- XDG CUSTOMS --- ### +export XDG_DOTFILES_DIR="$HOME/.dotfiles" +export XDG_SCRIPTS_HOME="$HOME/.local/bin" +export XDG_SOURCES_HOME="$HOME/.local/src" +export XDG_DESKTOP_DIR="$HOME/Desktop" +export XDG_DOCUMENTS_DIR="$HOME/Documents" +export XDG_DOWNLOAD_DIR="$HOME/Downloads" +export XDG_MUSIC_DIR="$HOME/Music" +export XDG_PICTURES_DIR="$HOME/Pictures" +export XDG_PUBLICSHARE_DIR="$HOME/Public" +export XDG_TEMPLATES_DIR="$HOME/Templates" +export XDG_VIDEOS_DIR="$HOME/Videos" + +####################################################### +# EXPORTS +####################################################### + export CLICOLOR=1 -export EDITOR="vim" export HISTFILE="${XDG_DATA_HOME:-${HOME}/.local/share}/history/sh_history" export INPUTRC="${XDG_CONFIG_HOME:-${HOME}/.config}/shell/inputrc" -export LESS="R" -export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" -export LESS_TERMCAP_md="$(printf '%b' '[1;36m')" -export LESS_TERMCAP_me="$(printf '%b' '[0m')" -export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" -export LESS_TERMCAP_se="$(printf '%b' '[0m')" -export LESS_TERMCAP_us="$(printf '%b' '[1;32m')" -export LESS_TERMCAP_ue="$(printf '%b' '[0m')" -export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null" + +### --- MANPAGER --- ### +([ -x "$(command -v batcat)" ] || [ -x "$(command -v batman)" ]) && { + export MANPAGER="sh -c 'col -bx | bat -l man -p'" + export MANROFFOPT="-c" +} || { + export MANPAGER='less -s' + export LESS="R" + export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" + export LESS_TERMCAP_md="$(printf '%b' '[1;36m')" + export LESS_TERMCAP_me="$(printf '%b' '[0m')" + export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" + export LESS_TERMCAP_se="$(printf '%b' '[0m')" + export LESS_TERMCAP_us="$(printf '%b' '[1;32m')" + export LESS_TERMCAP_ue="$(printf '%b' '[0m')" + export LESSOPEN="| lesspipe.sh %s" +} + export LS_COLORS="no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.xml=00;31:" export LS_OPTIONS="--color=auto" -export TERM="xterm-256color" -export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | source $MYGVIMRC' -export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' -export VISUAL=$EDITOR + +### --- PASSWORD STORE --- ### +export PASSWORD_STORE_DIR="$XDG_DATA_HOME/.password-store" +export PASSWORD_STORE_CLIP_TIME=180 # Specifies the number of seconds to wait before restoring the clipboard, by default 45 seconds. +# export PASSWORD_STORE_GENERATED_LENGTH=18 # by default 25. +# export PASSWORD_STORE_CHARACTER_SET='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,.<>?' +# export PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,.<>?' +export PASSWORD_STORE_ENABLE_EXTENSIONS="true" +# export PASSWORD_STORE_EXTENSIONS_DIR="$PASSWORD_STORE_DIR/.extensions" +# export BASH_COMPLETION_USER_DIR=$XDG_DATA_HOME/bash-completion/completions + +### --- TMUX --- ### +export TMUX_TMPDIR="$XDG_RUNTIME_DIR" + +### --- VIM --- ### +# export GVIMINIT='let $MYGVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/gvimrc" : "$XDG_CONFIG_HOME/nvim/init.lua" | so $MYGVIMRC' +# export VIMINIT='let $MYVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/vimrc" : "$XDG_CONFIG_HOME/nvim/init.lua" | so $MYVIMRC' + +### --- ZSH --- ### +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export ZPLUGINDIR="$XDG_SCRIPTS_HOME/zsh" + +################################################### +### --- ENV PATH --- ### +################################################### +# Add all directories in each subdirectory to $PATH +export PATH="$(find ~/.local/bin -path '*/.git*' -prune -o \( -type f -o -type l \) -perm -u=x -exec dirname {} \; | sort -u | paste -sd ':' -):$PATH" +export PATH="$(find ~/.local/share/.password-store -type d -name '.extensions' | paste -sd ':' -):$PATH" +export PATH="$ASDF_DATA_DIR/shims:$PATH" +command -v asdf >/dev/null 2>&1 && export PATH="$(find -L ~/.local/share/asdf/installs -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -):$PATH" +command -v npm >/dev/null 2>&1 && export PATH="$(find -L ~/.local/share/npm -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -):$PATH" + +unsetopt PROMPT_SP 2>/dev/null ####################################################### # Source global/local definitions @@ -38,3 +118,7 @@ export VISUAL=$EDITOR [ -f /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion [ -f /etc/bash/bashrc ] && . /etc/bash/bashrc [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/bash/bashrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/bash/bashrc" +for file in "${XDG_CONFIG_HOME:-${HOME}/.config}/bash/completions"/*.bash; do + [ -f "$file" ] && . "$file" +done +[ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f bmshortcuts >/dev/null 2>&1
\ No newline at end of file diff --git a/fedora/.config/bash/bashrc b/fedora/.config/bash/bashrc index 2c60286..ec1cc46 100644 --- a/fedora/.config/bash/bashrc +++ b/fedora/.config/bash/bashrc @@ -32,7 +32,6 @@ bind "set show-all-if-ambiguous on" ####################################################### # Set command prompt ####################################################### -alias cpu="grep 'cpu ' /proc/stat | awk '{usage=(\$2+\$4)*100/(\$2+\$4+\$5)} END {print usage}' | awk '{printf(\"%.1f\n\", \$1)}'" function __setprompt { local LAST_COMMAND=$? # Must come first! @@ -164,6 +163,18 @@ bind '"\C-g":"lfcd\n"' eval "$(dircolors)" +[ -f "$HOME/.config/bash/git.bash" ] && . "$HOME/.config/bash/git.bash" +[ -f "$HOME/.config/bash/p10k.bash" ] && . "$HOME/.config/bash/p10k.bash" +[ -f "$HOME/.config/bash/autocomplete.bash" ] && . "$HOME/.config/bash/autocomplete.bash" +[ -f "$HOME/.config/bash/scripts.bash" ] && . "$HOME/.config/bash/scripts.bash" +[ -f "$HOME/.config/bash/keymaps.bash" ] && . "$HOME/.config/bash/keymaps.bash" +[ -f "$HOME/.config/bash/plugins.bash" ] && . "$HOME/.config/bash/plugins.bash" +[ -f "$HOME/.config/bash/packages.bash" ] && . "$HOME/.config/bash/packages.bash" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/git-aliasrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/git-aliasrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" [ -f "${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/bash-preexec" ] && . "${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/bash-preexec" [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/rootshortcutrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/rootshortcutrc" [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/rootzshnameddirrc" ] && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/rootzshnameddirrc" diff --git a/fedora/.config/bash/completions/bat.bash b/fedora/.config/bash/completions/bat.bash new file mode 100644 index 0000000..fa0f712 --- /dev/null +++ b/fedora/.config/bash/completions/bat.bash @@ -0,0 +1,249 @@ +# shellcheck disable=SC2207 + +# Requires https://github.com/scop/bash-completion + +# Macs have bash3 for which the bash-completion package doesn't include +# _init_completion. This is a minimal version of that function. +__bat_init_completion() +{ + COMPREPLY=() + _get_comp_words_by_ref "$@" cur prev words cword +} + +__bat_escape_completions() +{ + # Do not escape if completing a quoted value. + [[ $cur == [\"\']* ]] && return 0 + if (( + BASH_VERSINFO[0] > 5 || \ + BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3 + )); then + # bash >= 5.3 has "compopt -o fullquote", which exactly does + # what this function tries to do. + compopt -o fullquote + elif (( + BASH_VERSINFO[0] > 4 || \ + BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] > 0 + )); then + # printf -v to an array index is available in bash >= 4.1. + # Use it if available, as -o filenames is semantically + # incorrect if we are not actually completing filenames, and it + # has side effects (e.g. adds trailing slash to candidates + # matching present dirs). + local i + for i in ${!COMPREPLY[*]}; do + printf -v "COMPREPLY[i]" %q "${COMPREPLY[i]}" + done + + # We can use "compopt -o noquote" available in bash >= 4.3 to + # prevent further quoting by the shell, which would be + # unexpectedly applied when a quoted result matches a filename. + if (( + BASH_VERSINFO[0] > 4 || \ + BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3 + )); then + compopt -o noquote + fi + else + compopt -o filenames + fi +} + +_bat() { + local cur prev words split=false + if declare -F _init_completion >/dev/null 2>&1; then + _init_completion -s || return 0 + else + __bat_init_completion -n "=" || return 0 + _split_longopt && split=true + fi + + if [[ ${words[1]-} == cache ]]; then + case $prev in + --source | --target) + _filedir -d + return 0 + ;; + esac + COMPREPLY=($(compgen -W " + --build + --clear + --source + --target + --blank + --help + " -- "$cur")) + return 0 + fi + + case $prev in + -l | --language) + local IFS=$'\n' + COMPREPLY=($(compgen -W "$( + "$1" --list-languages | while IFS=: read -r lang _; do + printf "%s\n" "$lang" + done + )" -- "$cur")) + __bat_escape_completions + return 0 + ;; + -H | --highlight-line | \ + --diff-context | \ + --tabs | \ + --terminal-width | \ + -m | --map-syntax | \ + --ignored-suffix | \ + --list-themes | \ + --squeeze-limit | \ + --line-range | \ + -L | --list-languages | \ + --lessopen | \ + --no-paging | \ + --diagnostic | \ + --acknowledgements | \ + -h | --help | \ + -V | --version | \ + --cache-dir | \ + --config-dir | \ + --config-file | \ + --generate-config-file) + # argument required but no completion available, or option + # causes an exit + return 0 + ;; + --file-name) + _filedir + return 0 + ;; + --wrap) + COMPREPLY=($(compgen -W "auto never character" -- "$cur")) + return 0 + ;; + --binary) + COMPREPLY=($(compgen -W "no-printing as-text" -- "$cur")) + return 0 + ;; + --nonprintable-notation) + COMPREPLY=($(compgen -W "unicode caret" -- "$cur")) + return 0 + ;; + --strip-ansi) + COMPREPLY=($(compgen -W "auto never always" -- "$cur")) + return 0 + ;; + --completion) + COMPREPLY=($(compgen -W "bash fish zsh ps1" -- "$cur")) + return 0 + ;; + --color | --decorations | --paging) + COMPREPLY=($(compgen -W "auto never always" -- "$cur")) + return 0 + ;; + --italic-text) + COMPREPLY=($(compgen -W "always never" -- "$cur")) + return 0 + ;; + --pager) + COMPREPLY=($(compgen -c -- "$cur")) + return 0 + ;; + --theme) + local IFS=$'\n' + COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --list-themes)" -- "$cur")) + __bat_escape_completions + return 0 + ;; + --theme-dark | \ + --theme-light) + local IFS=$'\n' + COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur")) + __bat_escape_completions + return 0 + ;; + --style) + # shellcheck disable=SC2034 + local -a styles=( + default + full + auto + plain + changes + header + header-filename + header-filesize + grid + rule + numbers + snip + ) + # shellcheck disable=SC2016 + if declare -F _comp_delimited >/dev/null 2>&1; then + # bash-completion > 2.11 + _comp_delimited , -W '"${styles[@]}"' + else + COMPREPLY=($(compgen -W '${styles[@]}' -- "$cur")) + fi + return 0 + esac + + $split && return 0 + + if [[ $cur == -* ]]; then + # --unbuffered excluded intentionally (no-op) + COMPREPLY=($(compgen -W " + --show-all + --nonprintable-notation + --binary + --plain + --language + --highlight-line + --file-name + --diff + --diff-context + --tabs + --wrap + --chop-long-lines + --terminal-width + --number + --color + --italic-text + --decorations + --force-colorization + --paging + --no-paging + --pager + --map-syntax + --ignored-suffix + --theme + --theme-dark + --theme-light + --list-themes + --squeeze-blank + --squeeze-limit + --strip-ansi + --style + --line-range + --list-languages + --lessopen + --completion + --diagnostic + --acknowledgements + --set-terminal-title + --help + --version + --cache-dir + --config-dir + --config-file + --generate-config-file + --no-config + --no-custom-assets + --no-lessopen + " -- "$cur")) + return 0 + fi + + _filedir + + ## Completion of the 'cache' command itself is removed for better UX + ## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802 +} && complete -F _bat bat diff --git a/fedora/.config/bash/completions/rg.bash b/fedora/.config/bash/completions/rg.bash new file mode 100644 index 0000000..12d1039 --- /dev/null +++ b/fedora/.config/bash/completions/rg.bash @@ -0,0 +1,783 @@ +_rg() { + local i cur prev opts cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="" + opts="" + + for i in ${COMP_WORDS[@]}; do + case "${i}" in + rg) + cmd="rg" + ;; + *) + ;; + esac + done + + case "${cmd}" in + rg) + opts="--regexp -e --file -f --after-context -A --before-context -B --binary --no-binary --block-buffered --no-block-buffered --byte-offset -b --no-byte-offset --case-sensitive -s --color --colors --column --no-column --context -C --context-separator --no-context-separator --count -c --count-matches --crlf --no-crlf --debug --dfa-size-limit --encoding -E --no-encoding --engine --field-context-separator --field-match-separator --files --files-with-matches -l --files-without-match --fixed-strings -F --no-fixed-strings --follow -L --no-follow --generate --glob -g --glob-case-insensitive --no-glob-case-insensitive --heading --no-heading --help -h --hidden -. --no-hidden --hostname-bin --hyperlink-format --iglob --ignore-case -i --ignore-file --ignore-file-case-insensitive --no-ignore-file-case-insensitive --include-zero --no-include-zero --invert-match -v --no-invert-match --json --no-json --line-buffered --no-line-buffered --line-number -n --no-line-number -N --line-regexp -x --max-columns -M --max-columns-preview --no-max-columns-preview --max-count -m --max-depth -d --max-filesize --mmap --no-mmap --multiline -U --no-multiline --multiline-dotall --no-multiline-dotall --no-config --no-ignore --ignore --no-ignore-dot --ignore-dot --no-ignore-exclude --ignore-exclude --no-ignore-files --ignore-files --no-ignore-global --ignore-global --no-ignore-messages --ignore-messages --no-ignore-parent --ignore-parent --no-ignore-vcs --ignore-vcs --no-messages --messages --no-require-git --require-git --no-unicode --unicode --null -0 --null-data --one-file-system --no-one-file-system --only-matching -o --path-separator --passthru --pcre2 -P --no-pcre2 --pcre2-version --pre --no-pre --pre-glob --pretty -p --quiet -q --regex-size-limit --replace -r --search-zip -z --no-search-zip --smart-case -S --sort --sortr --stats --no-stats --stop-on-nonmatch --text -a --no-text --threads -j --trace --trim --no-trim --type -t --type-not -T --type-add --type-clear --type-list --unrestricted -u --version -V --vimgrep --with-filename -H --no-filename -I --word-regexp -w --auto-hybrid-regex --no-auto-hybrid-regex --no-pcre2-unicode --pcre2-unicode --sort-files --no-sort-files <PATTERN> <PATH>..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) + return 0 + fi + case "${prev}" in + + --regexp) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -e) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --file) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -f) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --after-context) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -A) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --before-context) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -B) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --binary) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-binary) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --block-buffered) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-block-buffered) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --byte-offset) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -b) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-byte-offset) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --case-sensitive) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -s) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --color) + COMPREPLY=($(compgen -W "never auto always ansi" -- "${cur}")) + return 0 + ;; + --colors) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --column) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-column) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --context) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -C) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --context-separator) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-context-separator) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --count) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -c) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --count-matches) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --crlf) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-crlf) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --debug) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --dfa-size-limit) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --encoding) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -E) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-encoding) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --engine) + COMPREPLY=($(compgen -W "default pcre2 auto" -- "${cur}")) + return 0 + ;; + --field-context-separator) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --field-match-separator) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --files) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --files-with-matches) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -l) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --files-without-match) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --fixed-strings) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -F) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-fixed-strings) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --follow) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -L) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-follow) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --generate) + COMPREPLY=($(compgen -W "man complete-bash complete-zsh complete-fish complete-powershell" -- "${cur}")) + return 0 + ;; + --glob) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -g) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --glob-case-insensitive) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-glob-case-insensitive) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --heading) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-heading) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --help) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -h) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --hidden) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -.) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-hidden) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --hostname-bin) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --hyperlink-format) + COMPREPLY=($(compgen -W "default none cursor file grep+ kitty macvim textmate vscode vscode-insiders vscodium" -- "${cur}")) + return 0 + ;; + --iglob) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-case) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -i) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-file) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-file-case-insensitive) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-file-case-insensitive) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --include-zero) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-include-zero) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --invert-match) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -v) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-invert-match) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --json) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-json) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --line-buffered) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-line-buffered) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --line-number) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -n) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-line-number) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -N) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --line-regexp) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -x) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-columns) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -M) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-columns-preview) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-max-columns-preview) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-count) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -m) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-depth) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -d) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-filesize) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --mmap) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-mmap) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --multiline) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -U) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-multiline) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --multiline-dotall) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-multiline-dotall) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-config) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-dot) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-dot) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-exclude) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-exclude) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-files) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-files) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-global) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-global) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-messages) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-messages) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-parent) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-parent) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-ignore-vcs) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --ignore-vcs) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-messages) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --messages) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-require-git) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --require-git) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-unicode) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --unicode) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --null) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -0) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --null-data) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --one-file-system) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-one-file-system) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --only-matching) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --path-separator) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --passthru) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pcre2) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -P) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-pcre2) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pcre2-version) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pre) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-pre) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pre-glob) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pretty) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -p) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --quiet) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -q) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --regex-size-limit) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --replace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -r) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --search-zip) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -z) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-search-zip) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --smart-case) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -S) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --sort) + COMPREPLY=($(compgen -W "none path modified accessed created" -- "${cur}")) + return 0 + ;; + --sortr) + COMPREPLY=($(compgen -W "none path modified accessed created" -- "${cur}")) + return 0 + ;; + --stats) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-stats) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --stop-on-nonmatch) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --text) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -a) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-text) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -j) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --trace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --trim) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-trim) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --type) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -t) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --type-not) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -T) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --type-add) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --type-clear) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --type-list) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --unrestricted) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -u) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --version) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -V) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --vimgrep) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --with-filename) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -H) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-filename) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -I) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --word-regexp) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -w) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --auto-hybrid-regex) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-auto-hybrid-regex) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-pcre2-unicode) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --pcre2-unicode) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --sort-files) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --no-sort-files) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + esac + COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) + return 0 + ;; + esac +} + +complete -F _rg -o bashdefault -o default rg diff --git a/fedora/.config/bash/completions/ya.bash b/fedora/.config/bash/completions/ya.bash new file mode 100644 index 0000000..b24e3e5 --- /dev/null +++ b/fedora/.config/bash/completions/ya.bash @@ -0,0 +1,647 @@ +_ya() { + local i cur prev opts cmd + COMPREPLY=() + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + cur="$2" + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + prev="$3" + cmd="" + opts="" + + for i in "${COMP_WORDS[@]:0:COMP_CWORD}" + do + case "${cmd},${i}" in + ",$1") + cmd="ya" + ;; + ya,emit) + cmd="ya__emit" + ;; + ya,emit-to) + cmd="ya__emit__to" + ;; + ya,help) + cmd="ya__help" + ;; + ya,pack) + cmd="ya__pack" + ;; + ya,pkg) + cmd="ya__pkg" + ;; + ya,pub) + cmd="ya__pub" + ;; + ya,pub-to) + cmd="ya__pub__to" + ;; + ya,sub) + cmd="ya__sub" + ;; + ya__help,emit) + cmd="ya__help__emit" + ;; + ya__help,emit-to) + cmd="ya__help__emit__to" + ;; + ya__help,help) + cmd="ya__help__help" + ;; + ya__help,pack) + cmd="ya__help__pack" + ;; + ya__help,pkg) + cmd="ya__help__pkg" + ;; + ya__help,pub) + cmd="ya__help__pub" + ;; + ya__help,pub-to) + cmd="ya__help__pub__to" + ;; + ya__help,sub) + cmd="ya__help__sub" + ;; + ya__help__pkg,add) + cmd="ya__help__pkg__add" + ;; + ya__help__pkg,delete) + cmd="ya__help__pkg__delete" + ;; + ya__help__pkg,install) + cmd="ya__help__pkg__install" + ;; + ya__help__pkg,list) + cmd="ya__help__pkg__list" + ;; + ya__help__pkg,upgrade) + cmd="ya__help__pkg__upgrade" + ;; + ya__pkg,add) + cmd="ya__pkg__add" + ;; + ya__pkg,delete) + cmd="ya__pkg__delete" + ;; + ya__pkg,help) + cmd="ya__pkg__help" + ;; + ya__pkg,install) + cmd="ya__pkg__install" + ;; + ya__pkg,list) + cmd="ya__pkg__list" + ;; + ya__pkg,upgrade) + cmd="ya__pkg__upgrade" + ;; + ya__pkg__help,add) + cmd="ya__pkg__help__add" + ;; + ya__pkg__help,delete) + cmd="ya__pkg__help__delete" + ;; + ya__pkg__help,help) + cmd="ya__pkg__help__help" + ;; + ya__pkg__help,install) + cmd="ya__pkg__help__install" + ;; + ya__pkg__help,list) + cmd="ya__pkg__help__list" + ;; + ya__pkg__help,upgrade) + cmd="ya__pkg__help__upgrade" + ;; + *) + ;; + esac + done + + case "${cmd}" in + ya) + opts="-V -h --version --help emit emit-to pkg pack pub pub-to sub help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__emit) + opts="-h --help <NAME> [ARGS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__emit__to) + opts="-h --help <RECEIVER> <NAME> [ARGS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help) + opts="emit emit-to pkg pack pub pub-to sub help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__emit) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__emit__to) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__help) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pack) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg) + opts="add delete install list upgrade" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg__add) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg__delete) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg__install) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg__list) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pkg__upgrade) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pub) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__pub__to) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__help__sub) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pack) + opts="-a -d -i -l -u -h --add --delete --install --list --upgrade --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --add) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -a) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --delete) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -d) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg) + opts="-h --help add delete install list upgrade help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__add) + opts="-h --help [IDS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__delete) + opts="-h --help [IDS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help) + opts="add delete install list upgrade help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__add) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__delete) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__help) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__install) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__list) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__help__upgrade) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__install) + opts="-h --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__list) + opts="-h --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pkg__upgrade) + opts="-h --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pub) + opts="-h --str --json --list --help <KIND>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --str) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --json) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --list) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__pub__to) + opts="-h --str --json --list --help <RECEIVER> <KIND>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --str) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --json) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --list) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + ya__sub) + opts="-h --help <KINDS>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + esac +} + +if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then + complete -F _ya -o nosort -o bashdefault -o default ya +else + complete -F _ya -o bashdefault -o default ya +fi diff --git a/fedora/.config/bash/completions/yazi.bash b/fedora/.config/bash/completions/yazi.bash new file mode 100644 index 0000000..ae2d3a1 --- /dev/null +++ b/fedora/.config/bash/completions/yazi.bash @@ -0,0 +1,66 @@ +_yazi() { + local i cur prev opts cmd + COMPREPLY=() + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + cur="$2" + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + prev="$3" + cmd="" + opts="" + + for i in "${COMP_WORDS[@]:0:COMP_CWORD}" + do + case "${cmd},${i}" in + ",$1") + cmd="yazi" + ;; + *) + ;; + esac + done + + case "${cmd}" in + yazi) + opts="-V -h --cwd-file --chooser-file --clear-cache --client-id --local-events --remote-events --debug --version --help [ENTRIES]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --cwd-file) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --chooser-file) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --client-id) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --local-events) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --remote-events) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + esac +} + +if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then + complete -F _yazi -o nosort -o bashdefault -o default yazi +else + complete -F _yazi -o bashdefault -o default yazi +fi diff --git a/fedora/.config/bash/completions/zoxide.bash b/fedora/.config/bash/completions/zoxide.bash new file mode 100644 index 0000000..1c2ed84 --- /dev/null +++ b/fedora/.config/bash/completions/zoxide.bash @@ -0,0 +1,243 @@ +_zoxide() { + local i cur prev opts cmd + COMPREPLY=() + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + cur="$2" + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + prev="$3" + cmd="" + opts="" + + for i in "${COMP_WORDS[@]:0:COMP_CWORD}" + do + case "${cmd},${i}" in + ",$1") + cmd="zoxide" + ;; + zoxide,add) + cmd="zoxide__add" + ;; + zoxide,edit) + cmd="zoxide__edit" + ;; + zoxide,import) + cmd="zoxide__import" + ;; + zoxide,init) + cmd="zoxide__init" + ;; + zoxide,query) + cmd="zoxide__query" + ;; + zoxide,remove) + cmd="zoxide__remove" + ;; + zoxide__edit,decrement) + cmd="zoxide__edit__decrement" + ;; + zoxide__edit,delete) + cmd="zoxide__edit__delete" + ;; + zoxide__edit,increment) + cmd="zoxide__edit__increment" + ;; + zoxide__edit,reload) + cmd="zoxide__edit__reload" + ;; + *) + ;; + esac + done + + case "${cmd}" in + zoxide) + opts="-h -V --help --version add edit import init query remove" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__add) + opts="-s -h -V --score --help --version <PATHS>..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --score) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -s) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__edit) + opts="-h -V --help --version decrement delete increment reload" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__edit__decrement) + opts="-h -V --help --version <PATH>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__edit__delete) + opts="-h -V --help --version <PATH>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__edit__increment) + opts="-h -V --help --version <PATH>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__edit__reload) + opts="-h -V --help --version" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__import) + opts="-h -V --from --merge --help --version <PATH>" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --from) + COMPREPLY=($(compgen -W "autojump z" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__init) + opts="-h -V --no-cmd --cmd --hook --help --version bash elvish fish nushell posix powershell tcsh xonsh zsh" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --cmd) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --hook) + COMPREPLY=($(compgen -W "none prompt pwd" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__query) + opts="-a -i -l -s -h -V --all --interactive --list --score --exclude --help --version [KEYWORDS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --exclude) + COMPREPLY=() + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o plusdirs + fi + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + zoxide__remove) + opts="-h -V --help --version [PATHS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + esac +} + +if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then + complete -F _zoxide -o nosort -o bashdefault -o default zoxide +else + complete -F _zoxide -o bashdefault -o default zoxide +fi diff --git a/fedora/.config/bash/keymaps.bash b/fedora/.config/bash/keymaps.bash index cf355ad..15bd7e2 100644 --- a/fedora/.config/bash/keymaps.bash +++ b/fedora/.config/bash/keymaps.bash @@ -11,101 +11,131 @@ PROMPT_COMMAND='echo -ne "\e[5 q"' # ---------- helper: pre_cmd ---------- pre_cmd() { - local txt="$1" - if [[ -z "${READLINE_LINE+set}" ]]; then - printf '%s ' "$txt" - return - fi - local left=${READLINE_LINE:0:READLINE_POINT} - local right=${READLINE_LINE:READLINE_POINT} - READLINE_LINE="${left}${txt} ${right}" - READLINE_POINT=$(( READLINE_POINT + ${#txt} + 1 )) + local last_cmd + last_cmd=$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//') + + if [[ $last_cmd != sudo* ]]; then + READLINE_LINE="sudo $last_cmd" + READLINE_POINT=${#READLINE_LINE} + fi } # ---------- Clipboard detection ---------- _detect_clipboard_setup() { - if command -v pbcopy >/dev/null 2>&1 && command -v pbpaste >/dev/null 2>&1; then - clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } - clippaste() { pbaste; } - return 0 - fi - if command -v wl-copy >/dev/null 2>&1 && command -v wl-paste >/dev/null 2>&1; then - clipcopy() { cat "${1:-/dev/stdin}" | wl-copy; } - clippaste() { wl-paste --no-newline; } - return 0 - fi - if command -v xclip >/dev/null 2>&1; then - clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard; } - clippaste() { xclip -selection clipboard -out; } - return 0 - fi - if command -v xsel >/dev/null 2>&1; then - clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } - clippaste() { xsel --clipboard --output; } - return 0 - fi - if command -v clip.exe >/dev/null 2>&1; then - clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } - clippaste() { powershell.exe -noprofile -command Get-Clipboard 2>/dev/null; } - return 0 - fi - if command -v tmux >/dev/null 2>&1 && [ -n "${TMUX:-}" ]; then - clipcopy() { tmux load-buffer -; } - clippaste() { tmux save-buffer -; } - return 0 - fi - return 1 + if command -v pbcopy >/dev/null 2>&1 && command -v pbpaste >/dev/null 2>&1; then + clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } + clippaste() { pbaste; } + return 0 + fi + if command -v wl-copy >/dev/null 2>&1 && command -v wl-paste >/dev/null 2>&1; then + clipcopy() { cat "${1:-/dev/stdin}" | wl-copy; } + clippaste() { wl-paste --no-newline; } + return 0 + fi + if command -v xclip >/dev/null 2>&1; then + clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard; } + clippaste() { xclip -selection clipboard -out; } + return 0 + fi + if command -v xsel >/dev/null 2>&1; then + clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } + clippaste() { xsel --clipboard --output; } + return 0 + fi + if command -v clip.exe >/dev/null 2>&1; then + clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } + clippaste() { powershell.exe -noprofile -command Get-Clipboard 2>/dev/null; } + return 0 + fi + if command -v tmux >/dev/null 2>&1 && [ -n "${TMUX:-}" ]; then + clipcopy() { tmux load-buffer -; } + clippaste() { tmux save-buffer -; } + return 0 + fi + return 1 } _detect_clipboard_setup || true paste_clipboard_to_readline() { - if ! command -v clippaste >/dev/null 2>&1; then - _detect_clipboard_setup || { printf 'No clipboard helper found\n' >&2; return 1; } - fi - local clip - clip=$(clippaste 2>/dev/null) || return 1 - clip="${clip%$'\n'}" - if [[ -z "${READLINE_LINE+set}" ]]; then - printf '%s' "$clip" - return - fi - local left=${READLINE_LINE:0:READLINE_POINT} - local right=${READLINE_LINE:READLINE_POINT} - READLINE_LINE="${left}${clip}${right}" - READLINE_POINT=$(( READLINE_POINT + ${#clip} )) + if ! command -v clippaste >/dev/null 2>&1; then + _detect_clipboard_setup || { + printf 'No clipboard helper found\n' >&2 + return 1 + } + fi + local clip + clip=$(clippaste 2>/dev/null) || return 1 + clip="${clip%$'\n'}" + if [[ -z "${READLINE_LINE+set}" ]]; then + printf '%s' "$clip" + return + fi + local left=${READLINE_LINE:0:READLINE_POINT} + local right=${READLINE_LINE:READLINE_POINT} + READLINE_LINE="${left}${clip}${right}" + READLINE_POINT=$((READLINE_POINT + ${#clip})) } copy_readline_to_clipboard() { - if [[ -z "${READLINE_LINE+set}" ]]; then - printf 'No current line to copy\n' >&2 - return 1 - fi - if ! command -v clipcopy >/dev/null 2>&1; then - _detect_clipboard_setup || { printf 'No clipboard helper found\n' >&2; return 1; } - fi - printf '%s' "${READLINE_LINE}" | clipcopy + if [[ -z "${READLINE_LINE+set}" ]]; then + printf 'No current line to copy\n' >&2 + return 1 + fi + if ! command -v clipcopy >/dev/null 2>&1; then + _detect_clipboard_setup || { + printf 'No clipboard helper found\n' >&2 + return 1 + } + fi + printf '%s' "${READLINE_LINE}" | clipcopy } # ---------- basic utilities ---------- -clear_tree_2() { clear; tree -L 2 2>/dev/null || true; } -clear_tree_3() { clear; tree -L 3 2>/dev/null || true; } +clear_tree_2() { + clear + tree -L 2 2>/dev/null || true +} +clear_tree_3() { + clear + tree -L 3 2>/dev/null || true +} insert_current_date() { - local txt="$(date -I)" - if [[ -z "${READLINE_LINE+set}" ]]; then printf '%s' "$txt"; return; fi - local left=${READLINE_LINE:0:READLINE_POINT}; local right=${READLINE_LINE:READLINE_POINT} - READLINE_LINE="${left}${txt}${right}"; READLINE_POINT=$(( READLINE_POINT + ${#txt} )) + local txt="$(date -I)" + if [[ -z "${READLINE_LINE+set}" ]]; then + printf '%s' "$txt" + return + fi + local left=${READLINE_LINE:0:READLINE_POINT} + local right=${READLINE_LINE:READLINE_POINT} + READLINE_LINE="${left}${txt}${right}" + READLINE_POINT=$((READLINE_POINT + ${#txt})) } insert_unix_timestamp() { - local txt="$(date +%s)" - if [[ -z "${READLINE_LINE+set}" ]]; then printf '%s' "$txt"; return; fi - local left=${READLINE_LINE:0:READLINE_POINT}; local right=${READLINE_LINE:READLINE_POINT} - READLINE_LINE="${left}${txt}${right}"; READLINE_POINT=$(( READLINE_POINT + ${#txt} )) + local txt="$(date +%s)" + if [[ -z "${READLINE_LINE+set}" ]]; then + printf '%s' "$txt" + return + fi + local left=${READLINE_LINE:0:READLINE_POINT} + local right=${READLINE_LINE:READLINE_POINT} + READLINE_LINE="${left}${txt}${right}" + READLINE_POINT=$((READLINE_POINT + ${#txt})) +} +git_status_clear() { + clear + git status 2>/dev/null || git status --short 2>/dev/null || true +} +tmux_left_pane() { + tmux select-pane -L 2>/dev/null || true + tmux resize-pane -Z 2>/dev/null || true } -git_status_clear() { clear; git status 2>/dev/null || git status --short 2>/dev/null || true; } -tmux_left_pane() { tmux select-pane -L 2>/dev/null || true; tmux resize-pane -Z 2>/dev/null || true; } vi_append_clip_selection() { paste_clipboard_to_readline; } copybuffer() { copy_readline_to_clipboard; } -background_start() { local cmd="$1"; shift || return 0; for arg in "$@"; do "$cmd" "$arg" &>/dev/null & done; } +background_start() { + local cmd="$1" + shift || return 0 + for arg in "$@"; do "$cmd" "$arg" &>/dev/null & done +} # ---------- pre_cmd widgets ---------- man_command_line() { pre_cmd "man"; } @@ -114,15 +144,14 @@ sudo_command_line() { pre_cmd "sudo"; } # ---------- wrappers (u-prefix REMOVED) ---------- bc() { command -v bc >/dev/null 2>&1 && /usr/bin/env bc "$@" || printf 'bc: not found\n' >&2; } cdi() { command -v cdi >/dev/null 2>&1 && cdi "$@" || printf 'cdi: not found\n' >&2; } -lastvim() { command -v lastnvim >/dev/null 2>&1 && lastvim "$@" || printf 'lastvim: not found\n' >&2; } +lastfiles() { command -v lastfiles >/dev/null 2>&1 && lastfiles "$@" || printf 'lastfiles: not found\n' >&2; } htop() { command -v htop >/dev/null 2>&1 && htop "$@" || printf 'htop: not found\n' >&2; } sessionizer() { command -v sessionizer >/dev/null 2>&1 && sessionizer "$@" || printf 'sessionizer: not found\n' >&2; } upd() { command -v upd >/dev/null 2>&1 && upd "$@" || printf 'upd: not found\n' >&2; } -cht() { command -v cht >/dev/null 2>&1 && cht "$@" || printf 'cht: not found\n' >&2; } # from '^ucht' -> 'cht' +cht() { command -v cht >/dev/null 2>&1 && cht "$@" || printf 'cht: not found\n' >&2; } # from '^ucht' -> 'cht' ali() { command -v ali >/dev/null 2>&1 && ali "$@" || printf 'ali: not found\n' >&2; } fD() { command -v fD >/dev/null 2>&1 && fD "$@" || printf 'fD: not found\n' >&2; } -rgafiles() { command -v rgafiles >/dev/null 2>&1 && rgafiles "$@" || printf 'rgafiles: not found\n' >&2; } -lastvim_l() { command -v lastnvim >/dev/null 2>&1 && lastvim -l || printf 'lastvim: not found\n' >&2; } +lastfiles_l() { command -v lastfiles >/dev/null 2>&1 && lastfiles -l || printf 'lastfiles: not found\n' >&2; } # ---------- Readline key bindings (bind -x) ---------- # basic movement @@ -133,68 +162,57 @@ bind '"\C-e": end-of-line' bind -x '"\C-x\C-e":clear_tree_2' bind -x '"\C-x\C-w":clear_tree_3' bind -x '"\C-x\C-s":git_status_clear' -bind -x '"\C-x\C-x\C-t":insert_current_date' # ^X^X^T (alternate: C-x C-t) +bind -x '"\C-x\C-x\C-t":insert_current_date' # ^X^X^T (alternate: C-x C-t) bind -x '"\C-x\C-t":insert_current_date' bind -x '"\C-x\C-x\C-u":insert_unix_timestamp' # ^X^X^U bind -x '"\C-x\C-u":insert_unix_timestamp' # clipboard binds -bind -x '"\C-x\C-p":paste_clipboard_to_readline' # ^X^P -bind -x '"\C-x\C-y":copy_readline_to_clipboard' # ^X^Y +bind -x '"\C-x\C-p":paste_clipboard_to_readline' # ^X^P +bind -x '"\C-x\C-y":copy_readline_to_clipboard' # ^X^Y # edit in editor edit_command_line() { - local tmp content - tmp=$(mktemp /tmp/bash-edit.XXXXXX) || return - printf '%s' "${READLINE_LINE:-}" > "$tmp" - "${EDITOR:-vim}" "$tmp" - content=$(<"$tmp") - READLINE_LINE="$content" - READLINE_POINT=${#content} - rm -f "$tmp" + local tmp content + tmp=$(mktemp /tmp/bash-edit.XXXXXX) || return + printf '%s' "${READLINE_LINE:-}" >"$tmp" + "${EDITOR:-vim}" "$tmp" + content=$(<"$tmp") + READLINE_LINE="$content" + READLINE_POINT=${#content} + rm -f "$tmp" } -bind -x '"\C-x\C-v":edit_command_line' # ^X^V +bind -x '"\C-x\C-v":edit_command_line' # ^X^V # man & sudo insertion -bind -x '"\C-x\C-m":man_command_line' # ^X^M +bind -x '"\C-x\C-m":man_command_line' # ^X^M stty -ixon 2>/dev/null || true -bind -x '"\C-s":sudo_command_line' # ^S (stty -ixon to avoid flow control) +bind -x '"\C-s":sudo_command_line' # ^S (stty -ixon to avoid flow control) # tmux left pane (bind ESC + backslash) -bind -x $'\e\\':tmux_left_pane +#bind -x '\e\\':tmux_left_pane # ---------- mappings of the original bindkey -s lines (u removed) ---------- -bind -x '"\C-b":__bc' # will call function __bc below +bind -x '"\C-b":__bc' # will call function __bc below __bc() { bc -lq "$@"; } bind -x '"\C-d":cdi' bind -x '"\C-f":fzffiles' -bind -x '"\C-g":lf' -bind -x '"\C-n":lastnvim' +bind -x '"\C-n":lastfiles' bind -x '"\C-o":tmo' bind -x '"\C-p":fzfpass' bind -x '"\C-q":htop' bind -x '"\C-t":sessionizer' -bind -x '"\C-y":lfcd' -bind -x '"\C-z":upd' +bind -x '"\C-z":pd' # ^_ (Ctrl-_) mapped to cht (from '^ucht' -> 'cht') bind -x $'"\C-_":cht' # ^X^... sequences (Ctrl-X then key) bind -x '"\C-x\C-a":ali' -bind -x '"\C-x\C-b":gitopenbranch' bind -x '"\C-x\C-d":fD' bind -x '"\C-x\C-f":gitfiles' bind -x '"\C-x\C-g":rgafiles' bind -x '"\C-x\C-l":gloac' -bind -x '"\C-x\C-n":lastnvim_l' +bind -x '"\C-x\C-n":lastfiles_l' bind -x '"\C-x\C-q":fpkill' -bind -x '"\C-x\C-r":fgst' -bind -x '"\C-x\C-t":gitstagedfiles' -bind -x '"\C-x\C-u":gitupdate' -bind -x '"\C-x\C-_":fzffns' # ^X^_ -bind -x '"\C-x\C-x\C-b":rbackup' -bind -x '"\C-x\C-x\C-p":pcyr' -bind -x '"\C-x\C-x\C-r":rbackup' # rbackup -r not directly supported via bind -x args; call rbackup then ask user for flags if needed -bind -x '"\C-x\C-x\C-s":sshadd' -bind -x '"\C-x\C-x\C-y":yay_remaps' +bind -x '"\C-x\C-_":fzffns' # ^X^_ diff --git a/fedora/.config/bash/scripts.bash b/fedora/.config/bash/scripts.bash index fa0abbc..400265d 100644 --- a/fedora/.config/bash/scripts.bash +++ b/fedora/.config/bash/scripts.bash @@ -1,97 +1,64 @@ #!/bin/bash -# Use the best version of pico installed -edit() { - if [ "$(type -t jpico)" = "file" ]; then - # Use JOE text editor http://joe-editor.sourceforge.net/ - jpico -nonotice -linums -nobackups "$@" - elif [ "$(type -t nano)" = "file" ]; then - nano -c "$@" - elif [ "$(type -t pico)" = "file" ]; then - pico "$@" +########################################################################################### +########################################################################################### +### --- APACHE --- ### +# View Apache logs +apachelog() { + if [ -f /etc/httpd/conf/httpd.conf ]; then + cd /var/log/httpd && ls -xAh && multitail --no-repeat -c -s 2 /var/log/httpd/*_log else - vim "$@" + cd /var/log/apache2 && ls -xAh && multitail --no-repeat -c -s 2 /var/log/apache2/*.log fi } -sedit() { - if [ "$(type -t jpico)" = "file" ]; then - # Use JOE text editor http://joe-editor.sourceforge.net/ - sudo jpico -nonotice -linums -nobackups "$@" - elif [ "$(type -t nano)" = "file" ]; then - sudo nano -c "$@" - elif [ "$(type -t pico)" = "file" ]; then - sudo pico "$@" +# Edit the Apache configuration +apacheconfig() { + if [ -f /etc/httpd/conf/httpd.conf ]; then + sedit /etc/httpd/conf/httpd.conf + elif [ -f /etc/apache2/apache2.conf ]; then + sedit /etc/apache2/apache2.conf else - sudo vim "$@" + echo "Error: Apache config file could not be found." + echo "Searching for possible locations:" + sudo updatedb && locate httpd.conf && locate apache2.conf fi } -# Extracts any archive(s) (if unp isn't installed) -extract() { - for archive in $*; do - if [ -f $archive ]; then - case $archive in - *.tar.bz2) tar xvjf $archive ;; - *.tar.gz) tar xvzf $archive ;; - *.bz2) bunzip2 $archive ;; - *.rar) rar x $archive ;; - *.gz) gunzip $archive ;; - *.tar) tar xvf $archive ;; - *.tbz2) tar xvjf $archive ;; - *.tgz) tar xvzf $archive ;; - *.zip) unzip $archive ;; - *.Z) uncompress $archive ;; - *.7z) 7z x $archive ;; - *) echo "don't know how to extract '$archive'..." ;; - esac - else - echo "'$archive' is not a valid file!" - fi - done -} - -# Searches for text in all files in the current folder -ftext() { - # -i case-insensitive - # -I ignore binary files - # -H causes filename to be printed - # -r recursive search - # -n causes line number to be printed - # optional: -F treat search term as a literal, not a regular expression - # optional: -l only print filenames and not the matching lines ex. grep -irl "$1" * - grep -iIHrn --color=always "$1" . | less -r -} - -# Copy file with a progress bar -cpf() { - set -e - strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | - awk '{ - count += $NF - if (count % 10 == 0) { - percent = count / total_size * 100 - printf "%3d%% [", percent - for (i=0;i<=percent;i++) - printf "=" - printf ">" - for (i=percent;i<100;i++) - printf " " - printf "]\r" - } - } - END { print "" }' total_size=$(stat -c '%s' "${1}") count=0 -} +########################################################################################### +########################################################################################### +### --- BASH --- ### +# Automatically install the needed support files for this .bashrc file +install_bashrc_support() { + local dtype + dtype=$(distribution) -# Copy and go to the directory -cpg() { - if [ -d "$2" ]; then - cp $1 $2 && cd $2 + if [ $dtype == "redhat" ]; then + sudo yum install multitail tree joe + elif [ $dtype == "suse" ]; then + sudo zypper install multitail + sudo zypper install tree + sudo zypper install joe + elif [ $dtype == "debian" ]; then + sudo apt-get install multitail tree joe + elif [ $dtype == "gentoo" ]; then + sudo emerge multitail + sudo emerge tree + sudo emerge joe + elif [ $dtype == "mandriva" ]; then + sudo urpmi multitail + sudo urpmi tree + sudo urpmi joe + elif [ $dtype == "slackware" ]; then + echo "No install support for Slackware" else - cp $1 $2 + echo "Unknown distribution" fi } +########################################################################################### +########################################################################################### +### --- CD --- ### # Move and go to the directory mvg() { if [ -d "$2" ]; then @@ -106,7 +73,7 @@ mc() { mkdir -p $1 && cd $1 } -# Goes up a specified number of directories (i.e. up 4) +# Go up a specified number of directories (i.e. up 4) up() { local d="" limit=$1 @@ -134,6 +101,79 @@ pwdtail() { pwd | awk -F/ '{nlast = NF -1;print $nlast"/"$NF}' } +########################################################################################### +########################################################################################### +### --- COMMAND OUTPUT --- ### +alias ilco=insert_last_command_output +insert_last_command_output() { + local last_cmd + last_cmd=$(history | tail -n 2 | head -n 1 | sed 's/^[ ]*[0-9]\+[ ]*//') + eval "$last_cmd" +} + +########################################################################################### +########################################################################################### +### --- COPY --- ### +# Copy file with a progress bar +cpf() { + set -e + strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | + awk '{ + count += $NF + if (count % 10 == 0) { + percent = count / total_size * 100 + printf "%3d%% [", percent + for (i=0;i<=percent;i++) + printf "=" + printf ">" + for (i=percent;i<100;i++) + printf " " + printf "]\r" + } + } + END { print "" }' total_size=$(stat -c '%s' "${1}") count=0 +} + +# Copy and go to the directory +cpg() { + if [ -d "$2" ]; then + cp $1 $2 && cd $2 + else + cp $1 $2 + fi +} + +########################################################################################### +########################################################################################### +### --- CREATE --- ### +alias mc=mkcd +mkcd() { mkdir -p "$1" && cd "$1" || return; } + +mkdt() { + mkdir -p "${1:+$1/}$(date +%F)" +} + +########################################################################################### +########################################################################################### +### --- CURSOR --- ### +# vi-mode cursor change +function update_cursor { + if [[ $READLINE_LINE == * ]]; then + if [[ $READLINE_POINT -eq 0 ]]; then + echo -ne '\e[6 q' # insert mode + else + echo -ne '\e[2 q' # command mode + fi + fi +} + +# vi-command, vi-insert 모드 hook 등록 +bind -m vi-insert '":": "\C-o update_cursor"' +bind -m vi-command '":": "\C-o update_cursor"' + +########################################################################################### +########################################################################################### +### --- DISTRIBUTION --- ### # Show the current distribution distribution() { local dtype @@ -206,34 +246,64 @@ ver() { fi } -# Automatically install the needed support files for this .bashrc file -install_bashrc_support() { - local dtype - dtype=$(distribution) +########################################################################################### +########################################################################################### +### --- EDIT --- ### +edit() { + if [ "$(type -t jpico)" = "file" ]; then + # Use JOE text editor http://joe-editor.sourceforge.net/ + jpico -nonotice -linums -nobackups "$@" + elif [ "$(type -t nano)" = "file" ]; then + nano -c "$@" + elif [ "$(type -t pico)" = "file" ]; then + pico "$@" + else + vim "$@" + fi +} - if [ $dtype == "redhat" ]; then - sudo yum install multitail tree joe - elif [ $dtype == "suse" ]; then - sudo zypper install multitail - sudo zypper install tree - sudo zypper install joe - elif [ $dtype == "debian" ]; then - sudo apt-get install multitail tree joe - elif [ $dtype == "gentoo" ]; then - sudo emerge multitail - sudo emerge tree - sudo emerge joe - elif [ $dtype == "mandriva" ]; then - sudo urpmi multitail - sudo urpmi tree - sudo urpmi joe - elif [ $dtype == "slackware" ]; then - echo "No install support for Slackware" +sedit() { + if [ "$(type -t jpico)" = "file" ]; then + # Use JOE text editor http://joe-editor.sourceforge.net/ + sudo jpico -nonotice -linums -nobackups "$@" + elif [ "$(type -t nano)" = "file" ]; then + sudo nano -c "$@" + elif [ "$(type -t pico)" = "file" ]; then + sudo pico "$@" else - echo "Unknown distribution" + sudo vim "$@" fi } +########################################################################################### +########################################################################################### +### --- EXTRACT --- ### +extract() { + for archive in $*; do + if [ -f $archive ]; then + case $archive in + *.tar.bz2) tar xvjf $archive ;; + *.tar.gz) tar xvzf $archive ;; + *.bz2) bunzip2 $archive ;; + *.rar) rar x $archive ;; + *.gz) gunzip $archive ;; + *.tar) tar xvf $archive ;; + *.tbz2) tar xvjf $archive ;; + *.tgz) tar xvzf $archive ;; + *.zip) unzip $archive ;; + *.Z) uncompress $archive ;; + *.7z) 7z x $archive ;; + *) echo "don't know how to extract '$archive'..." ;; + esac + else + echo "'$archive' is not a valid file!" + fi + done +} + +########################################################################################### +########################################################################################### +### --- NETWORK --- ### # Show current network information netinfo() { echo "--------------- Network Information ---------------" @@ -262,28 +332,18 @@ function whatsmyip() { wget http://smart-ip.net/myip -O - -q } -# View Apache logs -apachelog() { - if [ -f /etc/httpd/conf/httpd.conf ]; then - cd /var/log/httpd && ls -xAh && multitail --no-repeat -c -s 2 /var/log/httpd/*_log - else - cd /var/log/apache2 && ls -xAh && multitail --no-repeat -c -s 2 /var/log/apache2/*.log - fi -} +########################################################################################### +########################################################################################### +### --- PASS --- ### +pass_otp() { pass otp uri -q "$1"; } +pass_otp_insert() { pass otp insert "$1"; } -# Edit the Apache configuration -apacheconfig() { - if [ -f /etc/httpd/conf/httpd.conf ]; then - sedit /etc/httpd/conf/httpd.conf - elif [ -f /etc/apache2/apache2.conf ]; then - sedit /etc/apache2/apache2.conf - else - echo "Error: Apache config file could not be found." - echo "Searching for possible locations:" - sudo updatedb && locate httpd.conf && locate apache2.conf - fi -} +alias cpqr=pass_qr +pass_qr() { qrencode -o "$1.png" -t png -Sv 40 <"$1.pgp"; } +########################################################################################### +########################################################################################### +### --- PHP --- ### # Edit the PHP configuration file phpconfig() { if [ -f /etc/php.ini ]; then @@ -303,6 +363,23 @@ phpconfig() { fi } +########################################################################################### +########################################################################################### +### --- SEARCH --- ### +ftext() { + # -i case-insensitive + # -I ignore binary files + # -H causes filename to be printed + # -r recursive search + # -n causes line number to be printed + # optional: -F treat search term as a literal, not a regular expression + # optional: -l only print filenames and not the matching lines ex. grep -irl "$1" * + grep -iIHrn --color=always "$1" . | less -r +} + +########################################################################################### +########################################################################################### +### --- SQL --- ### # Edit the MySQL configuration file mysqlconfig() { if [ -f /etc/my.cnf ]; then @@ -324,16 +401,33 @@ mysqlconfig() { fi } -# For some reason, rot13 pops up everywhere -rot13() { - if [ $# -eq 0 ]; then - tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' - else - echo $* | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' +########################################################################################### +########################################################################################### +### --- STOW --- ### +alias dstw=dotfiles_stw +dotfiles_stw() { + "${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/$(whereami)/.local/bin/stw" +} + +########################################################################################### +########################################################################################### +### --- SUDO --- ### +pre_cmd() { + local prepend_command="$1" + local buffer="${READLINE_LINE:-}" + + if [ -z "$buffer" ]; then + buffer=$(history | tail -n 2 | head -n 1 | sed 's/^[ ]*[0-9]\+[ ]*//') fi + + READLINE_LINE="$prepend_command $buffer" + READLINE_POINT=${#READLINE_LINE} } +bind -x '"\es":pre_cmd sudo' -# Trim leading and trailing spaces (for scripts) +########################################################################################### +########################################################################################### +### --- TRIM --- ### trim() { local var=$@ var='${var#"${var%%[![:space:]]*}"}' # remove leading whitespace characters diff --git a/fedora/.config/shell/aliasrc b/fedora/.config/shell/aliasrc index 6b35701..a219759 100644 --- a/fedora/.config/shell/aliasrc +++ b/fedora/.config/shell/aliasrc @@ -2,385 +2,743 @@ # balias - blank aliases (completed without space) # ialias - ignored aliases (not completed) -# sudo not required for some system commands -for command in blkid lsblk mount umount dnf poweroff reboot shutdown su updatedb; do - alias $command="sudo $command" -done -unset command - -case "$(readlink -f /sbin/init)" in -*systemd*) - # journal - alias -g jctl='journalctl -xe' - alias -g jctlou='sudo journalctl -b -n 200 -f' - alias -g rpi='systemctl --user restart wireplumber pipewire pipewire-pulse pipewire-jack' - alias -g sctl='systemctl' - alias -g sctlss='systemctl status' - alias -g sctle='systemctl enable' - alias -g sctld='systemctl disable' - alias -g sctlr='systemctl restart' - alias -g sctls='systemctl start' - alias -g sctlt='systemctl stop' - alias -g sctldr='systemctl daemon-reload' - alias -g tctl='timedatectl' - ;; -esac - -# Go back -alias ...='../..' -alias ....='../../..' -alias .....='../../../..' - -# bash -alias sbp="source ~/.config/bash/bash_profile" -alias sbs="source ~/.config/bash/bashrc" - -# cd -alias cf='cd "$(dirname "$(readlink -f health.lua)")"' -alias pd='cd -' - -# chmod -alias che='find . -type f -exec chmod +x {};' -alias chfd='find . -type d -exec chmod 755 {}; -o -type f -exec chmod 644 {};' -alias cx='chmod a+x' -alias 000='chmod -R 000' -alias 600='chmod -R 600' -alias 644='chmod -R 644' -alias 666='chmod -R 666' -alias 755='chmod -R 755' -alias 777='chmod -R 777' - -# copy -alias CC='$(fc -l -n -1) | xclip -selection clipboard' -ialias cp='cp -iv' -alias pwdc='pwd | xclip -selection clipboard' - -# count -alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null" - -# curl -ialias curl='curl --silent --show-error' -balias clh='curl localhost:' -balias clh8='curl localhost:8080' -balias clh9='curl localhost:9080' -balias c100='curl 192.168.99.100:' - -# date -alias da="date '+%Y-%m-%d %A %T %Z'" - -# delete -alias _fd='find . -type f -name "._*" -print0 | xargs -0 rm -f' -alias _fp='find . -type f -name "._*" -print' - -# diff -ialias diff='diff --color' - -# disk -alias diskspace="du -S | sort -n -r |more" -alias folders="du -h --max-depth=1" -alias folderssort="find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn" -alias tree="tree -CAhF --dirsfirst" -alias treed="tree -CAFd" -alias mountedinfo="df -hT" - -# docker -alias dk='docker' -alias dkp='docker ps' -alias dkpa='docker ps -a' -alias dkpaq='docker ps -a -q' -alias dkb='docker build -t' -alias dkbnc='docker build --no-cache -t' -alias dkr='docker run --rm' -alias dkrti='docker run --rm -ti' -alias dkrd='docker run -d' -alias dkrp8='docker run --rm -p 8080:8080' -alias dkrp9='docker run --rm -p 9080:9080' -alias dks='docker start' -alias dkt='docker stop' -alias dktt='docker stop $(docker ps -q)' -alias dkk='docker kill' -alias dkkk='docker kill $(docker ps -q)' -alias dkrm='docker rm' -alias dkri='docker rmi' -alias dke='docker exec -ti' -alias dkl='docker logs -f' -alias dki='docker images' -alias dkpu='docker pull' -alias dkph='docker push' -alias dkin='docker inspect' -alias dkn='docker network' -alias dkc='docker-compose' -alias dkcu='docker-compose up' -alias dkclean='docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi' - -# find -balias fdn='find . -name "' -alias f="find . | grep " - -# grep -ialias -g grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' -alias grepi='grep -i' -alias grepr='grep -r' -alias grepri='grep -ri' -alias grepw='grep -R -i --include="*"' -alias grepb='grep -R -i --include="*" --exclude-dir="zsh"' -alias -g Gg='| grep' -alias -g Gi='| grep -i' -alias -g GH='| grep HTTP' - -# hash -alias h='hash -rf' - -# hexdump -alias hx='hexdump -C' - -# history -alias h="history | grep " - -# ip -ialias ip='ip -color=auto' -alias whatsmyip='curl -s ifconfig.me | xargs' -alias ipview="netstat -anpl | grep :80 | awk '{print $5}' | cut -d':' -f1 | sort | uniq -c | sort -n | sed -e 's/^ *//' -e 's/ *$//'" - -# killall -alias ka='killall' -alias k9='kill -9' -alias k15='kill -15' - -# logs -alias logs="sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f" - -# ls: eza or built-in -[ -x "$(command -v eza)" ] && { - ialias l='eza --icons --group-directories-first' - ialias la='eza --icons -aa --group-directories-first' - ialias lh='eza --icons -aa --group-directories-first' - ialias ll='eza -gl --icons --group-directories-first' - ialias lla='eza -glaa --icons --group-directories-first' - ialias lm='eza -glA --group-directories-first | more' - ialias lr='eza --icons -R --group-directories-first' - ialias ls='eza --icons -A --group-directories-first' - ialias lsb='eza --icons -b --group-directories-first' - ialias lsby='eza --icons -B --group-directories-first' - ialias lld='eza --icons -Dl --group-directories-first' - ialias llda='eza --icons -aaDl --group-directories-first' - ialias llf='eza --icons -fl' - ialias llfa='eza --icons -aafl' - ialias llsa='eza --icons -l -s=accessed' - ialias llsaa='eza --icons -aal -s=accessed' - ialias llsc='eza --icons -l -s=created' - ialias llsca='eza --icons -aal -s=created' - ialias llse='eza --icons -l -s=extension' - ialias llsea='eza --icons -aal -s=extension' - ialias llsm='eza --icons -l -s=modified' - ialias llsma='eza --icons -aal -s=modified' - ialias llsn='eza --icons -l -s=name' - ialias llsna='eza --icons -aal -s=name' - ialias llss='eza --icons -l -s=size' - ialias llssa='eza --icons -aal -s=size' - ialias llst='eza --icons -l -s=type' - ialias llsta='eza --icons -aal -s=type' - ialias lt='eza --icons -T -L' - ialias ltd='eza --icons -TD -L' - ialias ltdr='eza --icons -TDr -L' - ialias ltr='eza --icons -Tr -L' -} || { - ialias l='/usr/bin/ls -h --color=always --group-directories-first' - ialias la='/usr/bin/ls -alh --color=always --group-directories-first' - ialias ll='/usr/bin/ls -lh --color=always --group-directories-first' - ialias lla='/usr/bin/ls -aFls --color=always --group-directories-first' - ialias llf='/usr/bin/ls -Fls --color=always --group-directories-first' - ialias lm='/usr/bin/ls -alh --color=always --group-directories-first | more' - ialias lr='/usr/bin/ls -hlR --color=always --group-directories-first' - ialias lra='/usr/bin/ls -ahlR --color=always --group-directories-first' - ialias ls='/usr/bin/ls -AFh --color=always --group-directories-first' - ialias llsa='/usr/bin/ls -hlru --color=always --group-directories-first' - ialias llsc='/usr/bin/ls -hclr --color=always --group-directories-first' - ialias lld='/usr/bin/ls -l --color=always | grep "^d"' - ialias llda='/usr/bin/ls -la --color=always | grep "^d"' - ialias llse='/usr/bin/ls -BhlX --color=always --group-directories-first' - ialias llsf='/usr/bin/ls -l --color=always | grep -v "^d"' - ialias llsfa='/usr/bin/ls -la --color=always | grep -v "^d"' - ialias llsm='/usr/bin/ls -hlr --time=ctime --color=always --group-directories-first' - ialias llsn='/usr/bin/ls -alp --color=always --group-directories-first' - ialias llss='/usr/bin/ls -hlrS --color=always --group-directories-first' - ialias llst='/usr/bin/ls -hlrt --color=always --group-directories-first' - ialias lw='/usr/bin/ls -Ahx --color=always --group-directories-first' -} - -# mime -alias mimereset="update-desktop-database ${XDG_DATA_HOME:-${HOME}/.local/share}/applications" - -# mkdir -ialias mkdir='mkdir -pv' - -# modified commands -alias grep="/usr/bin/grep $GREP_OPTIONS" -alias cp="cp -i" -alias freshclam="sudo freshclam" -alias less="less -R" -alias mkdir="mkdir -p" -alias multitail="multitail --no-repeat -c" -alias mv="mv -i" -alias ping="ping -c 10" -alias ps="ps auxf" -alias rm="rm -iv" -alias svi="sudo vi" -alias v="vim" -alias vi="vim" -alias vis="vim '+set si'" - -# move -ialias mv='mv -iv' - -# nginx -alias ngx="cd /etc/nginx" - -# nvim -alias v='$EDITOR' -alias v.='$EDITOR .' -alias ve='$EDITOR -c enew' -alias nv.='nvim .' -alias nve='nvim -c enew' -alias nts='NVIM_APPNAME=TheSiahxyz nvim' -alias nav='NVIM_APPNAME=AstroNvim nvim' -alias nlu='NVIM_APPNAME=LunarVim nvim' -alias nlv='NVIM_APPNAME=LazyVim nvim' -alias nnc='NVIM_APPNAME=NvChad nvim' -alias snv='sudo nvim' -alias vll='lastnvim -l' -alias vln='$EDITOR -c '\''execute "edit " . v:oldfiles[0] | normal ''0'\' - -# ports -alias openports="netstat -nape --inet" - -# ps -ialias ps='ps auxf' -alias psj='ps aux | grep "[j]ava"' -balias psg='ps auxf | grep' -alias topcpu='/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10' - -# python -alias py='python3' - -# realpath -alias rp='realpath' - -# remove -ialias rm='rm -vI' - -# rsync -alias rsc='rsync -vrazPlu' -alias rscd='rsync -vrazPlu --delete' -alias rscr='rsync -vrazPlu --remove-source-files' - -# rules -alias rrr='sudo udevadm control --reload-rules' - -# scp -ialias scp='scp -r' - -# sha1 -alias sha1='openssl sha1' - -# shell -alias tobash="sudo chsh $USER -s /bin/bash && 'Now log out.'" -alias tozsh="sudo chsh $USER -s /bin/zsh && 'Now log out.'" -alias tofish="sudo chsh $USER -s /bin/fish && 'Now log out.'" - -# shellcheck -alias shck='shellcheck --color=always' - -# shortcut -alias ref='shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc' - -# sudo -alias su='sudo su -l root' -alias sm='setopt no_nomatch && rm -rf *.rej *.orig >/dev/null 2>&1' -alias smi='setopt no_nomatch && rm -rf *.rej *.orig >/dev/null 2>&1 && unsetopt no_nomatch; sudo make clean install; rm -f config.h' - -# suffix -alias -s {pdf,PDF}='background mupdf' -alias -s {jpg,JPG,png,PNG}='background gpicview' -alias -s {ods,ODS,odt,ODT,odp,ODP,doc,DOC,docx,DOCX,xls,XLS,xlsx,XLSX,xlsm,XLSM,ppt,PPT,pptx,PPTX,csv,CSV}='background libreoffice' -alias -s {html,HTML}='background chromium' -alias -s {mp4,MP4,mov,MOV,mkv,MKV}='background vlc' -alias -s {zip,ZIP,war,WAR}="unzip -l" -alias -s {jar,JAR}="java -jar" -alias -s gz="tar -tf" -alias -s {tgz,TGZ}="tar -tf" - -# tar -alias txf='tar -xf' -alias ttf='tar -tf' -alias mktar="tar -cvf" -alias mkbz2="tar -cvjf" -alias mkgz="tar -cvzf" -alias untar="tar -xvf" -alias unbz2="tar -xvjf" -alias ungz="tar -xvzf" - -# tmux -alias sts='tmux source $XDG_CONFIG_HOME/tmux/tmux.conf' -alias ta='tmux a' -alias tmc='tmuxcreate' -alias tmka='tmux kill-session -a' -alias tmls='tmux ls' -alias tmo='tmuxopen' -alias tmpk='command pkill tmux' -alias tm.='tmux new -s "$(basename $PWD)"' - -# tor -alias torh="cat /var/lib/tor/hidden_service/hostname" - -# trash -alias trd='trash-rm' -alias tre='trash-empty' -alias trl='trash-list' -alias trp='trash-put' -alias trr='trash-restore' - -# tree -ialias tree='tree -a -I ".svn|.git|.hg|.idea"' -alias tree2='tree -L 2' -alias tree3='tree -L 3' - -# unix -alias -g md='mkdir -p' -alias -g wh='which' -alias -g wt='while true; do' -alias -g s1='sleep 1' -alias -g s2='sleep 2' -alias -g s01='sleep 0.1' -alias -g s05='sleep 0.5' -alias -g A1="| awk '{print \$1}'" -alias -g L='| less' -alias -g H='| head' -alias -g H2='| head -n 20' -alias -g X='| xargs -I@' -alias -g C='| xclip -selection clipboard' -alias -g Fj='| jq .' -alias -g Fy='| yq .' -alias -g Fx='| xmllint --format -' -alias -g V='| nvim -' - -# unzip -alias uz='unzip' -alias uzl='unzip -l' - -# vim -alias vi='vim' -alias vi.='vim .' - -# watch -alias w1='watch -n 1' - -# wget -ialias wget --hsts-file="${XDG_CACHE_HOME:-${HOME}/.cache}/wget-hsts" - -# xprog -alias progn='xprop | awk '\''/^WM_CLASS/{sub(/.* = /, "instance:"); sub(/, /, "\nclass:"); print} /^WM_NAME/{sub(/.* = /, "title:"); print}'\''' - -# zsh -alias sps="source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile" -alias szs="source ${XDG_CONFIG_HOME:-${HOME}/.config}/zsh/.zshrc" +if [ -n "$BASH_VERSION" ]; then + # ------------------------------ + # BASH-compatible aliases & functions + # ------------------------------ + + # helper: safe alias creation + _a() { alias "$1"="$2"; } + + # sudo not required for some system commands + for command in blkid lsblk mount umount dnf poweroff reboot shutdown su updatedb; do + alias "$command"="sudo $command" + done + + # systemd checks (keep as in original) + case "$(readlink -f /sbin/init)" in + *systemd*) + # journal-like commands as functions (replaces zsh global aliases) + jctl() { journalctl -xe "$@"; } + jctlou() { sudo journalctl -b -n 200 -f "$@"; } + rpi() { systemctl --user restart wireplumber pipewire pipewire-pulse pipewire-jack "$@"; } + + # systemctl helpers + sctl() { systemctl "$@"; } # general wrapper + sctlss() { systemctl status "$@"; } + sctle() { systemctl enable "$@"; } + sctld() { systemctl disable "$@"; } + sctlr() { systemctl restart "$@"; } + sctls() { systemctl start "$@"; } + sctlt() { systemctl stop "$@"; } + sctldr() { systemctl daemon-reload "$@"; } + + tctl() { timedatectl "$@"; } + ;; + esac + + # navigation + alias ...='../..' + alias ....='../../..' + alias .....='../../../..' + + # bash profile helpers + alias sbp="source ~/.config/bash/bash_profile" + alias sbs="source ~/.config/bash/bashrc" + + # cd helpers + cf() { cd "$(dirname "$(readlink -f health.lua)")" || return; } + alias pd='cd -' + + # chmod helpers (keep behavior) + alias che='find . -type f -exec chmod +x {} \;' + # chfd: set directories 755, files 644 (safe implementation) + chfd() { find . -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \;; } + alias cx='chmod a+x' + alias 000='chmod -R 000' + alias 600='chmod -R 600' + alias 644='chmod -R 644' + alias 666='chmod -R 666' + alias 755='chmod -R 755' + alias 777='chmod -R 777' + + # copy / clipboard + # last command copy (approx): copy last history entry to clipboard + CC() { eval "$(fc -ln -1)" | xclip -selection clipboard; } + alias cp='cp -iv' + alias pwdc='pwd | xclip -selection clipboard' + + # count files/links/dirs + alias countfiles='for t in files links directories; do echo "$(find . -type ${t:0:1} | wc -l) $t"; done 2>/dev/null' + + # cpu usage + cpu() { awk '/^cpu /{usage=($2+$4)*100/($2+$4+$5)} END{printf "%.1f\n",usage}' /proc/stat; } + + # curl + alias curl='curl --silent --show-error' + alias clh='curl localhost:' + alias clh8='curl localhost:8080' + alias clh9='curl localhost:9080' + alias c100='curl 192.168.99.100:' + + # date + alias da="date '+%Y-%m-%d %A %T %Z'" + + # delete helpers + alias _fd='find . -type f -name "._*" -print0 | xargs -0 rm -f' + alias _fp='find . -type f -name "._*" -print' + + # diff + alias diff='diff --color' + + # disk + alias diskspace="du -S | sort -n -r | more" + alias folders="du -h --max-depth=1" + alias folderssort="find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn" + alias tree="tree -CAhF --dirsfirst" + alias treed="tree -CAFd" + alias mountedinfo="df -hT" + + # docker + alias dk='docker' + alias dkp='docker ps' + alias dkpa='docker ps -a' + alias dkpaq='docker ps -a -q' + alias dkb='docker build -t' + alias dkbnc='docker build --no-cache -t' + alias dkr='docker run --rm' + alias dkrti='docker run --rm -ti' + alias dkrd='docker run -d' + alias dkrp8='docker run --rm -p 8080:8080' + alias dkrp9='docker run --rm -p 9080:9080' + alias dks='docker start' + alias dkt='docker stop' + alias dktt='docker stop $(docker ps -q)' + alias dkk='docker kill' + alias dkkk='docker kill $(docker ps -q)' + alias dkrm='docker rm' + alias dkri='docker rmi' + alias dke='docker exec -ti' + alias dkl='docker logs -f' + alias dki='docker images' + alias dkpu='docker pull' + alias dkph='docker push' + alias dkin='docker inspect' + alias dkn='docker network' + alias dkc='docker-compose' + alias dkcu='docker-compose up' + alias dkclean='docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi' + + # find + alias fdn='find . -name "' + f() { find . | grep "$*"; } + + # grep: replace zsh global and colored exclude + alias grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' + alias grepi='grep -i' + alias grepr='grep -r' + alias grepri='grep -ri' + alias grepw='grep -R -i --include="*"' + alias grepb='grep -R -i --include="*" --exclude-dir="zsh"' + # global-like helpers implemented as functions that read stdin: + Gg() { grep "$@"; } # usage: somecommand | Gg pattern + Gi() { grep -i "$@"; } + GH() { grep -i "HTTP" "$@"; } + + # hash + alias h='hash -r' + + # hexdump + alias hx='hexdump -C' + + # history + Hgrep() { history | grep "$*"; } # note: alias h was used earlier; avoid conflict + + # ip + alias ip='ip -color=auto' + alias whatsmyip='curl -s ifconfig.me | xargs' + ipview() { netstat -anpl | grep :80 | awk '{print $5}' | cut -d':' -f1 | sort | uniq -c | sort -n | sed -e 's/^ *//' -e 's/ *$//'; } + + # killall + alias ka='killall' + alias k9='kill -9' + alias k15='kill -15' + + # logs + logs() { sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e 's/:$//g' | grep -v '[0-9]$' | xargs tail -f; } + + # ls: use eza if available else fallback to ls + if command -v eza >/dev/null 2>&1; then + alias l='eza --icons --group-directories-first' + alias la='eza --icons -aa --group-directories-first' + alias lh='eza --icons -aa --group-directories-first' + alias ll='eza -gl --icons --group-directories-first' + alias lla='eza -glaa --icons --group-directories-first' + alias lm='eza -glA --group-directories-first | more' + alias lr='eza --icons -R --group-directories-first' + alias ls='eza --icons -A --group-directories-first' + else + alias l='/usr/bin/ls -h --color=always --group-directories-first' + alias la='/usr/bin/ls -alh --color=always --group-directories-first' + alias ll='/usr/bin/ls -lh --color=always --group-directories-first' + alias lla='/usr/bin/ls -aFls --color=always --group-directories-first' + alias llf='/usr/bin/ls -Fls --color=always --group-directories-first' + alias lm='/usr/bin/ls -alh --color=always --group-directories-first | more' + alias lr='/usr/bin/ls -hlR --color=always --group-directories-first' + alias ls='/usr/bin/ls -AFh --color=always --group-directories-first' + fi + + # mime + alias mimereset='update-desktop-database ${XDG_DATA_HOME:-${HOME}/.local/share}/applications' + + # mkdir + alias mkdir='mkdir -pv' + mkdir() { command mkdir -pv "$@"; } + + # modified commands (keep cautious variants) + alias grep="/usr/bin/grep $GREP_OPTIONS" + alias freshclam="sudo freshclam" + alias less="less -R" + alias multitail="multitail --no-repeat -c" + alias mv="mv -i" + alias ping="ping -c 10" + alias ps="ps auxf" + alias rm="rm -iv" + + # move + alias mv='mv -iv' + + # nginx + alias ngx="cd /etc/nginx" + + # vim helpers + alias v="$EDITOR" + alias 'v.'="$EDITOR ." + alias ve="$EDITOR -c enew" + vis() { $EDITOR '+set si' "$@"; } + vll() { lastfiles -l "$@"; } + vln() { $EDITOR -c "execute 'edit ' . v:oldfiles[0] | normal '0'" "$@"; } + + # ports + alias openports="netstat -nape --inet" + + # ps + alias ps='ps auxf' + alias psj='ps aux | grep "[j]ava"' + psg() { ps auxf | grep "$*"; } + alias topcpu='/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10' + + # python + alias py='python3' + + # realpath + alias rp='realpath' + + # remove + alias rm='rm -vI' + + # rsync + alias rsc='rsync -vrazPlu' + alias rscd='rsync -vrazPlu --delete' + alias rscr='rsync -vrazPlu --remove-source-files' + + # rules + alias rrr='sudo udevadm control --reload-rules' + + # scp + alias scp='scp -r' + + # sha1 + alias sha1='openssl sha1' + + # shell switching helpers (need sudo) + alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" + alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" + alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'" + + # shellcheck + alias shck='shellcheck --color=always' + + # ref/shortcut loader (keep as in original) + ref() { bmshortcuts >/dev/null; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc; } + + # sudo helpers + alias su='sudo su -l root' + sm() { rm -rf -- *.rej *.orig >/dev/null 2>&1 || true; } + smi() { rm -rf -- *.rej *.orig >/dev/null 2>&1; sudo make clean install; rm -f config.h; } + + # -------- suffix alias replacement: provide 'open' function ---------- + # zsh's "alias -s ext='cmd'" doesn't exist in bash. + # Use `open` (or 'of') to open files by extension: + openf() { + for f in "$@"; do + case "${f##*.}" in + pdf|PDF) mupdf "$f" & ;; + jpg|JPG|png|PNG) gpicview "$f" & ;; + ods|ODS|odt|ODT|odp|ODP|doc|DOC|docx|DOCX|xls|XLS|xlsx|XLSX|xlsm|XLSM|ppt|PPT|pptx|PPTX|csv|CSV) + libreoffice "$f" & ;; + html|HTML) chromium "$f" & ;; + mp4|MP4|mov|MOV|mkv|MKV) vlc "$f" & ;; + zip|ZIP|war|WAR) unzip -l "$f" ;; + jar|JAR) java -jar "$f" ;; + gz) tar -tf "$f" ;; + tgz|TGZ) tar -tf "$f" ;; + *) ${EDITOR:-vi} "$f" ;; + esac + done + } + alias of='openf' + alias open='openf' + + # tarring helpers + alias txf='tar -xf' + alias ttf='tar -tf' + alias mktar="tar -cvf" + alias mkbz2="tar -cvjf" + alias mkgz="tar -cvzf" + alias untar="tar -xvf" + alias unbz2="tar -xvjf" + alias ungz="tar -xvzf" + + # tmux + alias sts='tmux source $XDG_CONFIG_HOME/tmux/tmux.conf' + alias ta='tmux a' + alias tmc='tmuxcreate' + alias tmka='tmux kill-session -a' + alias tmls='tmux ls' + alias tmo='tmuxopen' + alias tmpk='command pkill tmux' + tm_new() { tmux new -s "$(basename "$PWD")"; } + alias tm.='tm_new' + + # trash + alias trd='trash-rm' + alias tre='trash-empty' + alias trl='trash-list' + alias trp='trash-put' + alias trr='trash-restore' + + # tree + alias tree='tree -a -I ".svn|.git|.hg|.idea"' + alias tree2='tree -L 2' + alias tree3='tree -L 3' + + # small unix helpers (converted global aliases -> functions) + md() { mkdir -p "$@"; } + wh() { which "$@"; } + wt() { while true; do "$@"; done } # usage differs from zsh's global alias + s1() { sleep 1; } + s2() { sleep 2; } + s01() { sleep 0.1; } + s05() { sleep 0.5; } + A1() { awk '{print $1}' "$@"; } + L() { less "$@"; } + H() { head "$@"; } + H2() { head -n 20 "$@"; } + X() { xargs -I@ "$@"; } # limited replacement + C() { xclip -selection clipboard "$@"; } + Fj() { jq . "$@"; } + Fy() { yq . "$@"; } + Fx() { xmllint --format "$@"; } + V() { vim - "$@"; } + + # unzip + alias uz='unzip' + alias uzl='unzip -l' + + # vim + alias vi='vim' + alias 'vi.'='vim .' + + # watch + alias w1='watch -n 1' + + # wget + # keep hsts path variable + alias wget="wget --hsts-file='${XDG_CACHE_HOME:-${HOME}/.cache}/wget-hsts'" + + # xprop helper + progn() { xprop | awk '/^WM_CLASS/{sub(/.* = /, "instance:"); sub(/, /, "\nclass:"); print} /^WM_NAME/{sub(/.* = /, "title:"); print}'; } + + # zsh sourcing helpers (just source config) + sps() { source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile; } + szs() { source ${XDG_CONFIG_HOME:-${HOME}/.config}/zsh/.zshrc; } +else + # ------------------------------ + # ZSH-compatible aliases & functions + # ------------------------------ + # sudo not required for some system commands + for command in blkid lsblk mount umount dnf poweroff reboot shutdown su updatedb; do + alias $command="sudo $command" + done + unset command + + case "$(readlink -f /sbin/init)" in + *systemd*) + # journal + alias -g jctl='journalctl -xe' + alias -g jctlou='sudo journalctl -b -n 200 -f' + alias -g rpi='systemctl --user restart wireplumber pipewire pipewire-pulse pipewire-jack' + alias -g sctl='systemctl' + alias -g sctlss='systemctl status' + alias -g sctle='systemctl enable' + alias -g sctld='systemctl disable' + alias -g sctlr='systemctl restart' + alias -g sctls='systemctl start' + alias -g sctlt='systemctl stop' + alias -g sctldr='systemctl daemon-reload' + alias -g tctl='timedatectl' + ;; + esac + + # Go back + alias ...='../..' + alias ....='../../..' + alias .....='../../../..' + + # bash + alias sbp="source ~/.config/bash/bash_profile" + alias sbs="source ~/.config/bash/bashrc" + + # cd + alias cf='cd "$(dirname "$(readlink -f health.lua)")"' + alias pd='cd -' + + # chmod + alias che='find . -type f -exec chmod +x {};' + alias chfd='find . -type d -exec chmod 755 {}; -o -type f -exec chmod 644 {};' + alias cx='chmod a+x' + alias 000='chmod -R 000' + alias 600='chmod -R 600' + alias 644='chmod -R 644' + alias 666='chmod -R 666' + alias 755='chmod -R 755' + alias 777='chmod -R 777' + + # copy + alias CC='$(fc -l -n -1) | xclip -selection clipboard' + ialias cp='cp -iv' + alias pwdc='pwd | xclip -selection clipboard' + + # count + alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null" + + # cpu + alias cpu="grep 'cpu ' /proc/stat | awk '{usage=(\$2+\$4)*100/(\$2+\$4+\$5)} END {print usage}' | awk '{printf(\"%.1f\n\", \$1)}'" + + # curl + ialias curl='curl --silent --show-error' + balias clh='curl localhost:' + balias clh8='curl localhost:8080' + balias clh9='curl localhost:9080' + balias c100='curl 192.168.99.100:' + + # date + alias da="date '+%Y-%m-%d %A %T %Z'" + + # delete + alias _fd='find . -type f -name "._*" -print0 | xargs -0 rm -f' + alias _fp='find . -type f -name "._*" -print' + + # diff + ialias diff='diff --color' + + # disk + alias diskspace="du -S | sort -n -r |more" + alias folders="du -h --max-depth=1" + alias folderssort="find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn" + alias tree="tree -CAhF --dirsfirst" + alias treed="tree -CAFd" + alias mountedinfo="df -hT" + + # docker + alias dk='docker' + alias dkp='docker ps' + alias dkpa='docker ps -a' + alias dkpaq='docker ps -a -q' + alias dkb='docker build -t' + alias dkbnc='docker build --no-cache -t' + alias dkr='docker run --rm' + alias dkrti='docker run --rm -ti' + alias dkrd='docker run -d' + alias dkrp8='docker run --rm -p 8080:8080' + alias dkrp9='docker run --rm -p 9080:9080' + alias dks='docker start' + alias dkt='docker stop' + alias dktt='docker stop $(docker ps -q)' + alias dkk='docker kill' + alias dkkk='docker kill $(docker ps -q)' + alias dkrm='docker rm' + alias dkri='docker rmi' + alias dke='docker exec -ti' + alias dkl='docker logs -f' + alias dki='docker images' + alias dkpu='docker pull' + alias dkph='docker push' + alias dkin='docker inspect' + alias dkn='docker network' + alias dkc='docker-compose' + alias dkcu='docker-compose up' + alias dkclean='docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi' + + # find + balias fdn='find . -name "' + alias f="find . | grep " + + # grep + ialias -g grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' + alias grepi='grep -i' + alias grepr='grep -r' + alias grepri='grep -ri' + alias grepw='grep -R -i --include="*"' + alias grepb='grep -R -i --include="*" --exclude-dir="zsh"' + alias -g Gg='| grep' + alias -g Gi='| grep -i' + alias -g GH='| grep HTTP' + + # hash + alias h='hash -rf' + + # hexdump + alias hx='hexdump -C' + + # history + alias h="history | grep " + + # ip + ialias ip='ip -color=auto' + alias whatsmyip='curl -s ifconfig.me | xargs' + alias ipview="netstat -anpl | grep :80 | awk '{print $5}' | cut -d':' -f1 | sort | uniq -c | sort -n | sed -e 's/^ *//' -e 's/ *$//'" + + # killall + alias ka='killall' + alias k9='kill -9' + alias k15='kill -15' + + # logs + alias logs="sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f" + + # ls: eza or built-in + [ -x "$(command -v eza)" ] && { + ialias l='eza --icons --group-directories-first' + ialias la='eza --icons -aa --group-directories-first' + ialias lh='eza --icons -aa --group-directories-first' + ialias ll='eza -gl --icons --group-directories-first' + ialias lla='eza -glaa --icons --group-directories-first' + ialias lm='eza -glA --group-directories-first | more' + ialias lr='eza --icons -R --group-directories-first' + ialias ls='eza --icons -A --group-directories-first' + ialias lsb='eza --icons -b --group-directories-first' + ialias lsby='eza --icons -B --group-directories-first' + ialias lld='eza --icons -Dl --group-directories-first' + ialias llda='eza --icons -aaDl --group-directories-first' + ialias llf='eza --icons -fl' + ialias llfa='eza --icons -aafl' + ialias llsa='eza --icons -l -s=accessed' + ialias llsaa='eza --icons -aal -s=accessed' + ialias llsc='eza --icons -l -s=created' + ialias llsca='eza --icons -aal -s=created' + ialias llse='eza --icons -l -s=extension' + ialias llsea='eza --icons -aal -s=extension' + ialias llsm='eza --icons -l -s=modified' + ialias llsma='eza --icons -aal -s=modified' + ialias llsn='eza --icons -l -s=name' + ialias llsna='eza --icons -aal -s=name' + ialias llss='eza --icons -l -s=size' + ialias llssa='eza --icons -aal -s=size' + ialias llst='eza --icons -l -s=type' + ialias llsta='eza --icons -aal -s=type' + ialias lt='eza --icons -T -L' + ialias ltd='eza --icons -TD -L' + ialias ltdr='eza --icons -TDr -L' + ialias ltr='eza --icons -Tr -L' + } || { + ialias l='/usr/bin/ls -h --color=always --group-directories-first' + ialias la='/usr/bin/ls -alh --color=always --group-directories-first' + ialias ll='/usr/bin/ls -lh --color=always --group-directories-first' + ialias lla='/usr/bin/ls -aFls --color=always --group-directories-first' + ialias llf='/usr/bin/ls -Fls --color=always --group-directories-first' + ialias lm='/usr/bin/ls -alh --color=always --group-directories-first | more' + ialias lr='/usr/bin/ls -hlR --color=always --group-directories-first' + ialias lra='/usr/bin/ls -ahlR --color=always --group-directories-first' + ialias ls='/usr/bin/ls -AFh --color=always --group-directories-first' + ialias llsa='/usr/bin/ls -hlru --color=always --group-directories-first' + ialias llsc='/usr/bin/ls -hclr --color=always --group-directories-first' + ialias lld='/usr/bin/ls -l --color=always | grep "^d"' + ialias llda='/usr/bin/ls -la --color=always | grep "^d"' + ialias llse='/usr/bin/ls -BhlX --color=always --group-directories-first' + ialias llsf='/usr/bin/ls -l --color=always | grep -v "^d"' + ialias llsfa='/usr/bin/ls -la --color=always | grep -v "^d"' + ialias llsm='/usr/bin/ls -hlr --time=ctime --color=always --group-directories-first' + ialias llsn='/usr/bin/ls -alp --color=always --group-directories-first' + ialias llss='/usr/bin/ls -hlrS --color=always --group-directories-first' + ialias llst='/usr/bin/ls -hlrt --color=always --group-directories-first' + ialias lw='/usr/bin/ls -Ahx --color=always --group-directories-first' + } + + # mime + alias mimereset="update-desktop-database ${XDG_DATA_HOME:-${HOME}/.local/share}/applications" + + # mkdir + ialias mkdir='mkdir -pv' + + # modified commands + alias grep="/usr/bin/grep $GREP_OPTIONS" + alias cp="cp -i" + alias freshclam="sudo freshclam" + alias less="less -R" + alias mkdir="mkdir -p" + alias multitail="multitail --no-repeat -c" + alias mv="mv -i" + alias ping="ping -c 10" + alias ps="ps auxf" + alias rm="rm -iv" + + # move + ialias mv='mv -iv' + + # nginx + alias ngx="cd /etc/nginx" + + # vim + alias v='$EDITOR' + alias v.='$EDITOR .' + alias ve='$EDITOR -c enew' + alias vis="$EDITOR '+set si'" + alias vll='lastfiles -l' + alias vln='$EDITOR -c '\''execute "edit " . v:oldfiles[0] | normal ''0'\' + + # ports + alias openports="netstat -nape --inet" + + # ps + ialias ps='ps auxf' + alias psj='ps aux | grep "[j]ava"' + balias psg='ps auxf | grep' + alias topcpu='/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10' + + # python + alias py='python3' + + # realpath + alias rp='realpath' + + # remove + ialias rm='rm -vI' + + # rsync + alias rsc='rsync -vrazPlu' + alias rscd='rsync -vrazPlu --delete' + alias rscr='rsync -vrazPlu --remove-source-files' + + # rules + alias rrr='sudo udevadm control --reload-rules' + + # scp + ialias scp='scp -r' + + # sha1 + alias sha1='openssl sha1' + + # shell + alias tobash="sudo chsh $USER -s /bin/bash && 'Now log out.'" + alias tozsh="sudo chsh $USER -s /bin/zsh && 'Now log out.'" + alias tofish="sudo chsh $USER -s /bin/fish && 'Now log out.'" + + # shellcheck + alias shck='shellcheck --color=always' + + # shortcut + alias ref='bmshortcuts >/dev/null; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc; source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc' + + # sudo + alias su='sudo su -l root' + alias sm='setopt no_nomatch && rm -rf *.rej *.orig >/dev/null 2>&1' + alias smi='setopt no_nomatch && rm -rf *.rej *.orig >/dev/null 2>&1 && unsetopt no_nomatch; sudo make clean install; rm -f config.h' + + # suffix + alias -s {pdf,PDF}='background mupdf' + alias -s {jpg,JPG,png,PNG}='background gpicview' + alias -s {ods,ODS,odt,ODT,odp,ODP,doc,DOC,docx,DOCX,xls,XLS,xlsx,XLSX,xlsm,XLSM,ppt,PPT,pptx,PPTX,csv,CSV}='background libreoffice' + alias -s {html,HTML}='background chromium' + alias -s {mp4,MP4,mov,MOV,mkv,MKV}='background vlc' + alias -s {zip,ZIP,war,WAR}="unzip -l" + alias -s {jar,JAR}="java -jar" + alias -s gz="tar -tf" + alias -s {tgz,TGZ}="tar -tf" + + # tar + alias txf='tar -xf' + alias ttf='tar -tf' + alias mktar="tar -cvf" + alias mkbz2="tar -cvjf" + alias mkgz="tar -cvzf" + alias untar="tar -xvf" + alias unbz2="tar -xvjf" + alias ungz="tar -xvzf" + + # tmux + alias sts='tmux source $XDG_CONFIG_HOME/tmux/tmux.conf' + alias ta='tmux a' + alias tmc='tmuxcreate' + alias tmka='tmux kill-session -a' + alias tmls='tmux ls' + alias tmo='tmuxopen' + alias tmpk='command pkill tmux' + alias tm.='tmux new -s "$(basename $PWD)"' + + # tor + alias torh="cat /var/lib/tor/hidden_service/hostname" + + # trash + alias trd='trash-rm' + alias tre='trash-empty' + alias trl='trash-list' + alias trp='trash-put' + alias trr='trash-restore' + + # tree + ialias tree='tree -a -I ".svn|.git|.hg|.idea"' + alias tree2='tree -L 2' + alias tree3='tree -L 3' + + # unix + alias -g md='mkdir -p' + alias -g wh='which' + alias -g wt='while true; do' + alias -g s1='sleep 1' + alias -g s2='sleep 2' + alias -g s01='sleep 0.1' + alias -g s05='sleep 0.5' + alias -g A1="| awk '{print \$1}'" + alias -g L='| less' + alias -g H='| head' + alias -g H2='| head -n 20' + alias -g X='| xargs -I@' + alias -g C='| xclip -selection clipboard' + alias -g Fj='| jq .' + alias -g Fy='| yq .' + alias -g Fx='| xmllint --format -' + alias -g V='| vim -' + + # unzip + alias uz='unzip' + alias uzl='unzip -l' + + # vim + alias vi='vim' + alias vi.='vim .' + + # watch + alias w1='watch -n 1' + + # wget + ialias wget --hsts-file="${XDG_CACHE_HOME:-${HOME}/.cache}/wget-hsts" + + # xprog + alias progn='xprop | awk '\''/^WM_CLASS/{sub(/.* = /, "instance:"); sub(/, /, "\nclass:"); print} /^WM_NAME/{sub(/.* = /, "title:"); print}'\''' + + # zsh + alias sps="source ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile" + alias szs="source ${XDG_CONFIG_HOME:-${HOME}/.config}/zsh/.zshrc" +fi diff --git a/fedora/.config/shell/bm-dirs b/fedora/.config/shell/bm-dirs index 2afa0b0..72558e9 100644 --- a/fedora/.config/shell/bm-dirs +++ b/fedora/.config/shell/bm-dirs @@ -6,7 +6,6 @@ cac ${XDG_CACHE_HOME:-${HOME}/.cache} cbc ${XDG_CONFIG_HOME:-${HOME}/.config}/bash cfg ${XDG_CONFIG_HOME:-${HOME}/.config} cgc ${XDG_CONFIG_HOME:-${HOME}/.config}/git -cnv ${XDG_CONFIG_HOME:-${HOME}/.config}/nvim csh ${XDG_CONFIG_HOME:-${HOME}/.config}/shell ctm ${XDG_CONFIG_HOME:-${HOME}/.config}/tmux cts ${XDG_CONFIG_HOME:-${HOME}/.config}/TheSiahxyz diff --git a/fedora/.config/shell/bm-files b/fedora/.config/shell/bm-files index 0be00a6..a7ee21d 100644 --- a/fedora/.config/shell/bm-files +++ b/fedora/.config/shell/bm-files @@ -8,12 +8,12 @@ vga ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/git-aliasrc vgc ${XDG_CONFIG_HOME:-${HOME}/.config}/git/config # Git config vgi ${XDG_CONFIG_HOME:-${HOME}/.config}/git/ignore # Git ignore Vsm /etc/samba/smb.conf # Samba config +vsa ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc # Aliases used by shell (and potentially other shells) +vsp ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile # Shell profile used for system vtm ${XDG_CONFIG_HOME:-${HOME}/.config}/tmux/tmux.conf # Tmux config vvc ${XDG_CONFIG_HOME:-${HOME}/.config}/vim/vimrc # Vim config vvi ${XDG_CONFIG_HOME:-${HOME}/.config}/vim/init.vim # Vim init vvp ${XDG_CONFIG_HOME:-${HOME}/.config}/vim/plugins.vim # Vim plugins -vza ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc # Aliases used by zsh (and potentially other shells) vzc ${ZDOTDIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/zsh}/.zshrc # Zsh config vzk ${ZDOTDIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/zsh}/keymaps.zsh # Zsh keymaps -vzp ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile # Zsh profile used for system vzs ${ZDOTDIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/zsh}/scripts.zsh # Zsh scripts diff --git a/fedora/.config/shell/git-aliasrc b/fedora/.config/shell/git-aliasrc deleted file mode 100644 index f87a556..0000000 --- a/fedora/.config/shell/git-aliasrc +++ /dev/null @@ -1,415 +0,0 @@ -# Git version checking -autoload -Uz is-at-least -git_version="${${(As: :)$(git version 2>/dev/null)}[3]}" - -# -# Functions Current -# (sorted alphabetically by function name) -# (order should follow README) -# - -# The name of the current branch -# Back-compatibility wrapper for when this function was defined here in -# the plugin, before being pulled in to core lib/git.zsh as git_current_branch() -# to fix the core -> git plugin dependency. -current_branch() { - git_current_branch -} - -# Check for develop and similarly named branches -git_develop_branch() { - command git rev-parse --git-dir &>/dev/null || return - local branch - for branch in dev devel develop development; do - if command git show-ref -q --verify refs/heads/$branch; then - echo $branch - return 0 - fi - done - - echo develop - return 1 -} - -# Check if main exists and use instead of master -git_main_branch() { - command git rev-parse --git-dir &>/dev/null || return - local ref - for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master}; do - if command git show-ref -q --verify $ref; then - echo ${ref:t} - return 0 - fi - done - - # If no main branch was found, fall back to master but return error - echo master - return 1 -} - -grename() { - if [[ -z "$1" || -z "$2" ]]; then - echo "Usage: $0 old_branch new_branch" - return 1 - fi - - # Rename branch locally - git branch -m "$1" "$2" - # Rename branch in origin remote - if git push origin :"$1"; then - git push --set-upstream origin "$2" - fi -} - -# -# Functions Work in Progress (WIP) -# (sorted alphabetically by function name) -# (order should follow README) -# - -# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one -gunwipall() { - local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H) - - # Check if a commit without "--wip--" was found and it's not the same as HEAD - if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then - git reset $_commit || return 1 - fi -} - -# Warn if the current branch is a WIP -work_in_progress() { - command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" -} - -# -# Aliases -# (sorted alphabetically by command) -# (order should follow README) -# (in some cases force the alisas order to match README, like for example gke and gk) -# - -alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' - -ggpnp() { - if [[ "$#" == 0 ]]; then - ggl && ggp - else - ggl "${*}" && ggp "${*}" - fi -} -compdef _git ggpnp=git-checkout - -alias ggpur='ggu' -alias g='git' -! pidof transmission-daemon >/dev/null && alias gaa='git add --all' || alias gaa='echo "Turn off transmission-daemon first!"' -alias gapa='git add --patch' -alias gau='git add --update' -alias gav='git add --verbose' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' -alias gam='git am' -alias gama='git am --abort' -alias gamc='git am --continue' -alias gamscp='git am --show-current-patch' -alias gams='git am --skip' -alias gap='git apply' -alias gapt='git apply --3way' -alias gbs='git bisect' -alias gbsb='git bisect bad' -alias gbsg='git bisect good' -alias gbsn='git bisect new' -alias gbso='git bisect old' -alias gbsr='git bisect reset' -alias gbss='git bisect start' -alias gb='git branch' -alias gba='git branch --all' -alias gbD='git branch --delete --force' - -gbda() { - git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null -} - -# Copied and modified from James Roeder (jmaroeder) under MIT License -# https://github.com/jmaroeder/plugin-git/blob/216723ef4f9e8dde399661c39c80bdf73f4076c4/functions/gbda.fish -gbds() { - local default_branch=$(git_main_branch) - (( ! $? )) || default_branch=$(git_develop_branch) - - git for-each-ref refs/heads/ "--format=%(refname:short)" | \ - while read branch; do - local merge_base=$(git merge-base $default_branch $branch) - if [[ $(git cherry $default_branch $(git commit-tree $(git rev-parse $branch\^{tree}) -p $merge_base -m _)) = -* ]]; then - git branch -D $branch - fi - done -} - -alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' -alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' -alias gbm='git branch --move' -alias gbnm='git branch --no-merged' -alias gbr='git branch --remote' -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' -alias gbg='LANG=C git branch -vv | grep ": gone\]"' -alias gcor='git checkout --recurse-submodules' -alias gcB='git checkout -B' -alias gcd='git checkout $(git_develop_branch)' -alias gcm='git checkout $(git_main_branch)' -alias gcpa='git cherry-pick --abort' -alias gcpc='git cherry-pick --continue' -alias gcl='git clone --recurse-submodules' - -gccd() { - setopt localoptions extendedglob - - # get repo URI from args based on valid formats: https://git-scm.com/docs/git-clone#URLS - local repo='${${@[(r)(ssh://*|git://*|ftp(s)#://*|http(s)#://*|*@*)(.git/#)#]}:-$_}' - - # clone repository and exit if it fails - command git clone --recurse-submodules "$@" || return - - # if last arg passed was a directory, that's where the repo was cloned - # otherwise parse the repo URI and use the last part as the directory - [[ -d "$_" ]] && cd '$_' || cd '${${repo:t}%.git/#}' -} -compdef _git gccd=git-clone - -alias gcam='git commit --all --message' -alias gcas='git commit --all --signoff' -alias gcasm='git commit --all --signoff --message' -alias gcs='git commit --gpg-sign' -alias gcss='git commit --gpg-sign --signoff' -alias gcssm='git commit --gpg-sign --signoff --message' -alias gcmsg='git commit --message' -alias gcsm='git commit --signoff --message' -alias gc='git commit --verbose' -alias gca='git commit --verbose --all' -alias gca!='git commit --verbose --all --amend' -alias gcan!='git commit --verbose --all --no-edit --amend' -alias gcans!='git commit --verbose --all --signoff --no-edit --amend' -alias gc!='git commit --verbose --amend' -alias gcn!='git commit --verbose --no-edit --amend' -alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' -alias gdca='git diff --cached' -alias gdcw='git diff --cached --word-diff' -alias gds='git diff --staged' -alias gdw='git diff --word-diff' - -gdv() { git diff -w "$@" | view - } -compdef _git gdv=git-diff - -alias gdup='git diff @{upstream}' - -gdnolock() { - git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" -} -compdef _git gdnolock=git-diff - -alias gdt='git diff-tree --no-commit-id --name-only -r' -alias gf='git fetch' -# --jobs=<n> was added in git 2.8 -is-at-least 2.8 "$git_version" \ - && alias gfa='git fetch --all --prune --jobs=10' \ - || alias gfa='git fetch --all --prune' -alias gfo='git fetch origin' -alias gg='git gui citool' -alias gga='git gui citool --amend' -alias ghh='git help' -alias glgg='git log --graph' -alias glggp='git log --graph --parents' -alias glgga='git log --graph --decorate --all' -alias glggpa='git log --graph --decorate --parents --all' -alias glgm='git log --graph --max-count=10' -alias glgpm='git log --graph --parents --max-count=10' -alias gloac='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%ae>%Creset" --abbrev-commit --all' -alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short' -alias glopds='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --parents --date=short' -alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"' -alias glopd='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --parents' -alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all' -alias glolpa='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --parents --all' -alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat' -alias glolps='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --parents --stat' -alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"' -alias glolp='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --parents' -alias glog='git log --oneline --decorate --graph' -alias glogp='git log --oneline --decorate --graph --parents' -alias gloga='git log --oneline --decorate --graph --all' -alias glogpa='git log --oneline --decorate --graph --parents --all' - -# Pretty log messages -_git_log_prettily(){ - if ! [ -z $1 ]; then - git log --pretty=$1 - fi -} -compdef _git _git_log_prettily=git-log - -alias glp='_git_log_prettily' -alias glg='git log --stat' -alias glgp='git log --stat --patch' -alias gignored='git ls-files -v | grep "^[[:lower:]]"' -alias gfg='git ls-files | grep' -alias gm='git merge' -alias gma='git merge --abort' -alias gms="git merge --squash" -alias gmom='git merge origin/$(git_main_branch)' -alias gmum='git merge upstream/$(git_main_branch)' -alias gmtl='git mergetool --no-prompt' -alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' - -alias gl='git pull' -alias gprb='git pull --rebase' -alias gprbv='git pull --rebase -v' -alias gpra='git pull --rebase --autostash' -alias gprav='git pull --rebase --autostash -v' - -ggu() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git pull --rebase origin "${b:=$1}" -} -compdef _git ggu=git-checkout - -alias gprom='git pull --rebase origin $(git_main_branch)' -alias gpromi='git pull --rebase=interactive origin $(git_main_branch)' -alias ggpull='git pull origin "$(git_current_branch)"' - -ggl() { - if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then - git pull origin "${*}" - else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git pull origin "${b:=$1}" - fi -} -compdef _git ggl=git-checkout - -alias gluc='git pull upstream $(git_current_branch)' -alias glum='git pull upstream $(git_main_branch)' -# alias gp='git push' -alias gpd='git push --dry-run' - -ggf() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force origin "${b:=$1}" -} -compdef _git ggf=git-checkout - -alias gpf!='git push --force' -is-at-least 2.30 "$git_version" \ - && alias gpf='git push --force-with-lease --force-if-includes' \ - || alias gpf='git push --force-with-lease' - -ggfl() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force-with-lease origin "${b:=$1}" -} -compdef _git ggfl=git-checkout - -alias gpsup='git push --set-upstream origin $(git_current_branch)' -is-at-least 2.30 "$git_version" \ - && alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \ - || alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease' -alias gpvb='git push --verbose' -alias gpoat='git push origin --all && git push origin --tags' -alias gpod='git push origin --delete' -alias ggpush='git push origin "$(git_current_branch)"' - -ggp() { - if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then - git push origin "${*}" - else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git push origin "${b:=$1}" - fi -} -compdef _git ggp=git-checkout - -alias gpu='git push upstream' -alias grba='git rebase --abort' -alias grbc='git rebase --continue' -alias grbi='git rebase --interactive' -alias grbo='git rebase --onto' -alias grbs='git rebase --skip' -alias grbd='git rebase $(git_develop_branch)' -alias grbm='git rebase $(git_main_branch)' -alias grbom='git rebase origin/$(git_main_branch)' -alias gr='git remote' -alias grv='git remote --verbose' -alias gra='git remote add' -alias grrm='git remote remove' -alias grmv='git remote rename' -alias grset='git remote set-url' -alias grup='git remote update' -alias gru='git reset --' -alias grhh='git reset --hard' -alias grhk='git reset --keep' -alias grhs='git reset --soft' -alias gpristine='git reset --hard && git clean --force -dfx' -alias groh='git reset origin/$(git_current_branch) --hard' -alias grs='git restore' -alias grss='git restore --source' -alias grst='git restore --staged' -alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1' -alias grev='git revert' -alias grm='git rm' -alias grmc='git rm --cached' -alias gcount='git shortlog --summary --numbered' -alias gsh='git show' -alias gsps='git show --pretty=short --show-signature' -alias gstall='git stash --all' -alias gstaa='git stash apply' -alias gstc='git stash clear' -alias gstd='git stash drop' -alias gstl='git stash list' -alias gstp='git stash pop' -# use the default stash push on git 2.13 and newer -is-at-least 2.13 "$git_version" \ - && alias gsta='git stash push' \ - || alias gsta='git stash save' -alias gsts='git stash show --patch' -alias gst='git status' -alias gsb='git status --short --branch' -alias gsi='git submodule init' -alias gsu='git submodule update' -alias gsd='git svn dcommit' -alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' -alias gsr='git svn rebase' -alias gsw='git switch' -alias gswc='git switch --create' -alias gswd='git switch $(git_develop_branch)' -alias gswm='git switch $(git_main_branch)' -alias gtan='git tag --annotate' -alias gtsn='git tag --sign' -alias gtv='git tag | sort -V' -alias gignore='git update-index --assume-unchanged' -alias gunignore='git update-index --no-assume-unchanged' -alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwt='git worktree' -alias gwta='git worktree add' -alias gwtls='git worktree list' -alias gwtmv='git worktree move' -alias gwtrm='git worktree remove' -alias gstu='gsta --include-untracked' -alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' -alias gk='\gitk --all --branches &!' -alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' - -unset git_version - -# Logic for adding warnings on deprecated aliases -local old_alias new_alias -for old_alias new_alias ( - # TODO(2023-10-19): remove deprecated `git pull --rebase` aliases - gup gpr - gupv gprv - gupa gpra - gupav gprav - gupom gprom - gupomi gpromi -); do - aliases[$old_alias]=' - print -Pu2 \"%F{yellow}[oh-my-zsh] '%F{red}${old_alias}%F{yellow}' is a deprecated alias, using '%F{green}${new_alias}%F{yellow}' instead.%f\" - $new_alias' -done -unset old_alias new_alias diff --git a/fedora/.config/shell/inputrc b/fedora/.config/shell/inputrc deleted file mode 100644 index 81cdf85..0000000 --- a/fedora/.config/shell/inputrc +++ /dev/null @@ -1,31 +0,0 @@ -$include /etc/inputrc - -set completion-display-width 0 -set completion-query-items 1000 - -# Prettyfi -set colored-stats on -set colored-completion-prefix on - -# ^C no longer shows on C-c keypress -set echo-control-characters off - -# Map tab to cycle through all the possible completions. -TAB: menu-complete - -# vi mode -set editing-mode vi - -$if mode=vi -set show-mode-in-prompt on -set vi-ins-mode-string \1\e[6 q\2 -set vi-cmd-mode-string \1\e[2 q\2 -set keymap vi-command - -# these are for vi-command mode -Control-l: clear-screen - -set keymap vi-insert -# these are for vi-insert mode -Control-l: clear-screen -$endif diff --git a/fedora/.config/shell/profile b/fedora/.config/shell/profile index 677943a..fee2a46 100644 --- a/fedora/.config/shell/profile +++ b/fedora/.config/shell/profile @@ -7,22 +7,27 @@ ### --- ENV PATH --- ### ################################################### # Add all directories in each subdirectory to $PATH -export PATH="$PATH:$(find ~/.local/bin -path '*/.git*' -prune -o \( -type f -o -type l \) -perm -u=x -exec dirname {} \; | sort -u | paste -sd ':' -)" -export PATH="$PATH:$(find ~/.local/share/.password-store -type d -name '.extensions' | paste -sd ':' -)" -command -v asdf >/dev/null 2>&1 && export PATH="$PATH:$(find -L ~/.local/share/asdf/installs -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -)" -command -v npm >/dev/null 2>&1 && export PATH="$PATH:$(find -L ~/.local/share/npm -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -)" +export PATH="$(find ~/.local/bin -path '*/.git*' -prune -o \( -type f -o -type l \) -perm -u=x -exec dirname {} \; | sort -u | paste -sd ':' -):$PATH" +export PATH="$(find ~/.local/share/.password-store -type d -name '.extensions' | paste -sd ':' -):$PATH" +command -v asdf >/dev/null 2>&1 && export PATH="$(find -L ~/.local/share/asdf/installs -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -):$PATH" +command -v npm >/dev/null 2>&1 && export PATH="$(find -L ~/.local/share/npm -name bin -type d -print 2>/dev/null | sort -u | paste -s -d ':' -):$PATH" unsetopt PROMPT_SP 2>/dev/null ################################################### ### --- DEFAULT PROGRAMS --- ### ################################################### +export BROWSER=$(command -v librewolf || command -v firefox || command -v qutebrowser) export EDITOR="nvim" export EDITOR2="vim" # export FILE_MANAGER="lf $(lf -version)" +export FILE_MANAGER="yazi $(yazi --version)" export KEYTIMEOUT=10 export SUDO_EDITOR=$EDITOR +export SUDO_ASKPASS="$HOME/.local/bin/dmenupass" export TERM="xterm-256color" +export TERMINAL="st" +export TERMINAL_PROG="st" export VISUAL=$EDITOR ################################################### @@ -68,6 +73,35 @@ export DICS="/usr/share/stardict/dic/" ### --- ELECTRUM --- ### export ELECTRUMDIR="$XDG_DATA_HOME/electrum" +### --- FCITX5 --- ### +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx + +### --- FZF --- ### +export FZF_ALT_C_COMMAND="fd --type d . --color=never --hidden" +export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -50'" +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_CTRL_T_OPTS="--preview 'bat --color=always --line-range :50 {}' --preview-window 'right:45%'" +# export FZF_DEFAULT_OPTS="--no-height --color=bg+:#343d46,gutter:-1,pointer:#ff3c3c,info:#0dbc79,hl:#0dbc79,hl+:#23d18b" +export FZF_DEFAULT_OPTS="--reverse --height 60% --color=bg+:#343d46,gutter:-1,pointer:#ff3c3c,info:#0dbc79,hl:#0dbc79,hl+:#23d18b" + +### --- FORGIT --- ### +export FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS='--sort=-committerdate' +export FORGIT_COPY_CMD='xclip -selection clipboard' + +### --- GEM --- ### +export GEMRC="$HOME/.config/gem/gemrc" +export GEM_HOME="$XDG_DATA_HOME/gem" +export GEM_PATH="$GEM_HOME" + +### --- GO --- ### +export GOMODCACHE="$XDG_CACHE_HOME/go/mod" +export GOPATH="$XDG_SCRIPTS_HOME/go" + +### --- GTK --- ### +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0":"$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0.mine" + ### --- HISTORY --- ### export HISTFILE="$XDG_DATA_HOME/history/sh_history" @@ -78,6 +112,18 @@ export INPUTRC="$XDG_CONFIG_HOME/shell/inputrc" export AWT_TOOLKIT="MToolkit wmname LG3D" # May have to install wmname export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm +### --- Jupyter --- ### +export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME/jupyter" +export JUPYTER_PLATFORM_DIRS="1" + +### --- KODI --- ### +export KODI_DATA="$XDG_DATA_HOME/kodi" + +### --- LYNX --- ### +export LYNX_CFG="$HOME/.config/lynx/lynx.cfg" +export LYNX_LSS="$HOME/.config/lynx/lynx.lss" +export LYNX_CFG_PATH="$XDG_CONFIG_HOME/lynx" + ### --- MANPAGER --- ### ([ -x "$(command -v batcat)" ] || [ -x "$(command -v batman)" ]) && { export MANPAGER="sh -c 'col -bx | bat -l man -p'" @@ -95,12 +141,24 @@ export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm export LESSOPEN="| lesspipe.sh %s" } +### --- MBSYNC --- ### +export MBSYNCRC="$XDG_CONFIG_HOME/mbsync/config" + +### --- MOZILLA --- ### +export MOZ_USE_XINPUT2=1 # Mozilla smooth scrolling/touchpads. + +### --- NOTMUCH --- ### +export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" + ### --- NPM --- ### export NPM_CONFIG_USERCONFIG="~/.config/npm/.npmrc" ### --- NVM --- ### export NVM_DIR="$XDG_CONFIG_HOME/nvm" +### --- PAM GNUPG --- ### +# export GNUPGHOME="$XDG_DATA_HOME/gnupg" + ### --- PASSWORD STORE --- ### export PASSWORD_STORE_DIR="$XDG_DATA_HOME/.password-store" export PASSWORD_STORE_CLIP_TIME=180 # Specifies the number of seconds to wait before restoring the clipboard, by default 45 seconds. @@ -118,15 +176,31 @@ export POWERLEVEL9K_INSTALLATION_DIR="/usr/share/zsh-theme-powerlevel10k" export PYTHONPYCACHEPREFIX=$XDG_CACHE_HOME/python export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc" +### --- QT --- ### +export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. + ### --- RUST --- ### export RUSTUP_HOME="$XDG_DATA_HOME/rustup" +### --- SERVER --- ### +export THESIAH="thesiah.xyz" +export THESIAH_GIT="git@$THESIAH" +export THESIAH_SERVER="root@$THESIAH" +export THESIAH_VPN="${THESIAH%%.*}" +export THESIAH_WWW="$HOME/Private/repos/THESIAH" + ### --- SQLITE --- ### export SQLITE_HISTORY="$XDG_DATA_HOME/history/sqlite_history" +### --- STARSHIP --- ### +export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/starship.toml" + ### --- TMUX --- ### export TMUX_TMPDIR="$XDG_RUNTIME_DIR" +### --- UNISON --- ### +export UNISON="$XDG_DATA_HOME/unison" + ### --- VIM --- ### # export GVIMINIT='let $MYGVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/gvimrc" : "$XDG_CONFIG_HOME/nvim/init.lua" | so $MYGVIMRC' # export VIMINIT='let $MYVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/vimrc" : "$XDG_CONFIG_HOME/nvim/init.lua" | so $MYVIMRC' @@ -137,15 +211,35 @@ export WORKON_HOME="$XDG_DATA_HOME/venvs" ### --- VISUAL STUDIO CODE --- ### export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" +### --- WEBKIT --- ### +export WEBKIT_DISABLE_COMPOSITING_MODE=1 + +### --- WINE --- ### +export WINEPREFIX="$XDG_DATA_HOME/wine" +export WINEDLLOVERRIDES="winemenubuilder.exe=d" + ### --- WGET --- ### export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" +### --- W3M --- ### +export W3M_DIR="$XDG_STATE_HOME/w3m" + +### --- X11 --- ### +export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" +export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" + +### --- XAUTH --- ### +export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs. + ### --- ZSH --- ### export ZDOTDIR="$XDG_CONFIG_HOME/zsh" export ZPLUGINDIR="$XDG_SCRIPTS_HOME/zsh" +### --- SDCV --- ### +export STARDICT_DATA_DIR="$XDG_DATA_HOME/dic" +export STARDICT_HISTFILE="$XDG_DATA_HOME/history/dic" +export SDCV_PAGER='less --quit-if-one-screen -RX' + ### --- SHORTCUTS --- ### [ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f shortcuts >/dev/null 2>&1 -### --- LAPTOP KEYMAP --- ### -sudo -n loadkeys "$XDG_DATA_HOME/thesiah/ttymaps.kmap" 2>/dev/null diff --git a/fedora/.config/shell/scripts.bash b/fedora/.config/shell/scripts.bash deleted file mode 100644 index f257809..0000000 --- a/fedora/.config/shell/scripts.bash +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -########################################################################################### -########################################################################################### -### --- COMMAND OUTPUT --- ### -alias ilco=insert_last_command_output -insert_last_command_output() { - local last_cmd - last_cmd=$(history | tail -n 2 | head -n 1 | sed 's/^[ ]*[0-9]\+[ ]*//') - eval "$last_cmd" -} - -########################################################################################### -########################################################################################### -### --- CREATE --- ### -alias mc=mkcd -mkcd() { mkdir -p "$1" && cd "$1" || return; } - -mkdt() { - mkdir -p "${1:+$1/}$(date +%F)" -} - -########################################################################################### -########################################################################################### -### --- PASS --- ### -pass_otp() { pass otp uri -q "$1"; } -pass_otp_insert() { pass otp insert "$1"; } - -alias cpqr=pass_qr -pass_qr() { qrencode -o "$1.png" -t png -Sv 40 < "$1.pgp"; } - -########################################################################################### -########################################################################################### -### --- STOW --- ### -alias dstw=dotfiles_stw -dotfiles_stw() { - "${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/$(whereami)/.local/bin/stw" -} - -########################################################################################### -########################################################################################### -### --- SUDO --- ### -pre_cmd() { - local prepend_command="$1" - local buffer="${READLINE_LINE:-}" - - if [ -z "$buffer" ]; then - buffer=$(history | tail -n 2 | head -n 1 | sed 's/^[ ]*[0-9]\+[ ]*//') - fi - - READLINE_LINE="$prepend_command $buffer" - READLINE_POINT=${#READLINE_LINE} -} -bind -x '"\es":pre_cmd sudo' diff --git a/fedora/.config/tmux/tmux.conf b/fedora/.config/tmux/tmux.conf new file mode 100644 index 0000000..3b78628 --- /dev/null +++ b/fedora/.config/tmux/tmux.conf @@ -0,0 +1,91 @@ +### --- Settings --- ### +# general +set -as terminal-features 'xterm*:extkeys' +set -g base-index 1 +set -g pane-base-index 1 +set -g default-shell /bin/bash +set -g detach-on-destroy off +set -s extended-keys on +set -g focus-events on +set -g history-limit 1000000 +set -g mouse on +set -g renumber-windows on +set -g set-clipboard on +set -g xterm-keys on +set -gq allow-passthrough on +set -ga update-environment TERM +set -ga update-environment TERM_PROGRAM +set -sg escape-time 0 +setw -g mode-keys vi +setw -g aggressive-resize on + +# activity +set -g monitor-activity on +set -g visual-activity off + +# color +set -g default-terminal "xterm-256color" +set -ga terminal-overrides ',xterm-256color:Tc' +set -sa terminal-features ',xterm-256color:RGB' + +# status +set -g status-interval 1 +set -g status-justify absolute-centre +set -g status-left "" +set -g status-left-length 10 +set -g status-position top +set -g status-right "" +set -g status-style "bg=default" + + +### --- Key Bindings --- ### +# clear +bind 'l' "send-keys C-l; send-keys -R; clear-history" + +# copy-mode +bind 'v' copy-mode + +# pane +bind '%' split-window -h -c '#{pane_current_path}' +bind '"' split-window -v -c '#{pane_current_path}' +bind '|' split-window -h +bind '-' split-window -v +bind -r 'C-down' resize-pane -D 5 +bind -r 'C-up' resize-pane -U 5 +bind -r 'C-left' resize-pane -L 5 +bind -r 'C-right' resize-pane -R 5 +bind '@' choose-window 'join-pane -h -s "%%"' +bind '#' choose-window 'join-pane -s "%%"' +bind 'x' kill-pane +bind 'a' kill-pane -a +bind 'X' kill-window +bind 'A' kill-window -a +bind -n 'M-k' move-pane -h -t '.{up-of}' +bind -n 'M-l' move-pane -t '.{right-of}' +bind -n 'M-h' move-pane -t '.{left-of}' +bind -n 'M-j' move-pane -h -t '.{down-of}' + +# prefix +unbind 'C-b' +set -g prefix 'C-Space' +bind 'C-Space' send-prefix + +# reload +unbind 'r' +bind 'r' source-file "~/.config/tmux/tmux.conf" + +# session +bind -r '(' switch-client -p \; refresh-client -S +bind -r ')' switch-client -n \; refresh-client -S +bind -nr 'M-<' switch-client -p \; refresh-client -S +bind -nr 'M->' switch-client -n \; refresh-client -S +bind "'" switch-client -t'{marked}' +bind -r 'BSpace' switch-client -l + +# window +bind -r '<' swap-window -d -t -1 +bind -r '>' swap-window -d -t +1 +bind -nr 'M-,' previous-window \; refresh-client -S +bind -nr 'M-.' next-window \; refresh-client -S +bind 'c' new-window -c "#{pane_current_path}" +bind -nr 'M-BSpace' last-window diff --git a/fedora/.config/vim/init.vim b/fedora/.config/vim/init.vim index fbb9097..4104ba3 100644 --- a/fedora/.config/vim/init.vim +++ b/fedora/.config/vim/init.vim @@ -9,21 +9,10 @@ autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Nerd tree autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif -" Runs a script that cleans out tex build files whenever I close out of a .tex file. -autocmd VimLeave *.tex !texclear % - " Text files -let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} -let g:vimwiki_list = [{'path': '~/.local/share/nvim/vimwiki', 'syntax': 'markdown', 'ext': '.md'}] -autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff autocmd BufRead,BufNewFile *.tex set filetype=tex -" Enable Goyo by default for mutt writing -autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo 80 | call feedkeys("jk") -autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo!\|x!<CR> -autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo!\|q!<CR> - " Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position autocmd BufWritePre * let currPos = getpos(".") autocmd BufWritePre * %s/\s\+$//e @@ -33,18 +22,7 @@ autocmd BufWritePre *neomutt* %s/^--$/-- /e " dash-dash-space signature delimite autocmd BufWritePre * cal cursor(currPos[1], currPos[2]) " When shortcut files are updated, renew bash and ranger configs with new material: -autocmd BufWritePost bm-files,bm-dirs !shortcuts - -" Run xrdb whenever Xdefaults or Xresources are updated. -autocmd BufRead,BufNewFile Xresources,Xdefaults,xresources,xdefaults set filetype=xdefaults -autocmd BufWritePost Xresources,Xdefaults,xresources,xdefaults !xrdb % - -" Recompile dwmblocks on config edit. -autocmd BufWritePost ${XDG_SOURCES_HOME:-$HOME/.local/src}/suckless/dwmblocks/config.h !cd ${XDG_SOURCES_HOME:-$HOME/.local/src}/suckless/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks } - -" Which key description -autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map') -let g:which_key_map = {} +autocmd BufWritePost bm-files,bm-dirs !bmshortcuts " }}} @@ -60,387 +38,10 @@ endif " }}} -" PLUGINS INIT ----------------------------------------------------------- {{{ - -let config_path = empty($XDG_CONFIG_HOME) ? expand("$HOME/.config") : expand("$XDG_CONFIG_HOME") -if filereadable(config_path . "/vim/plugins.vim") - silent! call mkdir(config_path . "/vim/plugged", "p") - execute "source " . config_path . "/vim/plugins.vim" -endif - -" goyo -let g:is_goyo_active = v:false -function! GoyoEnter() - if executable('tmux') && strlen($TMUX) - silent !tmux set status off - silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z - endif - - let g:default_colorscheme = exists('g:colors_name') ? g:colors_name : 'desert' - set background=light - set linebreak - set wrap - set textwidth=0 - set wrapmargin=0 - - Goyo 80x85% - colorscheme seoul256 - let g:is_goyo_active = v:true -endfunction - -function! GoyoLeave() - if executable('tmux') && strlen($TMUX) - silent !tmux set status on - silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z - endif - - Goyo! - execute 'colorscheme ' . g:default_colorscheme - let g:is_goyo_active = v:false -endfunction - -function! ToggleGoyo() - if g:is_goyo_active - call GoyoLeave() - else - call GoyoEnter() - endif -endfunction - -" }}} - - -" PLUGIN MAPPINGS & SETTINGS -------------------------------------------------------- {{{ - -" Open quickfix/location list -let g:which_key_map.o = { - \ 'name' : '+Open' , - \ 'q' : 'Quickfix-list' , - \ 'l' : 'Location-list' , - \ } - -" Check health -nnoremap <Leader>ch :CheckHealth<CR> -let g:which_key_map.c = { 'name' : 'Check' } -let g:which_key_map.c.h = 'Check-health' - -" Bookmarks -let g:bookmark_no_default_key_mappings = 1 -let g:bookmark_save_per_working_dir = 1 -let g:bookmark_auto_save = 1 -nmap <Leader>mm <Plug>BookmarkToggle -nmap <Leader>mi <Plug>BookmarkAnnotate -nmap <Leader>ma <Plug>BookmarkShowAll -nmap <Leader>m] <Plug>BookmarkNext -nmap <Leader>m[ <Plug>BookmarkPrev -nmap <Leader>mc <Plug>BookmarkClear -nmap <Leader>mx <Plug>BookmarkClearAll -nmap <Leader>mk <Plug>BookmarkMoveUp -nmap <Leader>mj <Plug>BookmarkMoveDown -nmap <Leader>mg <Plug>BookmarkMoveToLine - -" Fugitive -nnoremap <Leader>gs :Git<CR> -let g:which_key_map.g = { 'name' : 'Git/Goyo' } -let g:which_key_map.g.s = 'Git' - -" Goyo plugin makes text more readable when writing prose: -nnoremap <Leader>gy :call ToggleGoyo()<CR> -let g:which_key_map.g.y = 'Toggle-goyo' - -" Nerd tree -map <Leader>n :NERDTreeToggle<CR> -let g:which_key_map.n = 'Toggle-nerd-tree' - -" Undotree -nnoremap <Leader>u :UndotreeToggle<CR> -let g:which_key_map.u = 'Toggle-undo-tree' - -" vimwiki -map <Leader>vw :VimwikiIndex<CR> -let g:which_key_map.v = { 'name' : '+Vim-wiki' } -let g:which_key_map.v.w = 'Vim-wiki-index' - -" vim-plug -nnoremap <Leader>pc :PlugClean<CR> -nnoremap <Leader>pi :PlugInstall<CR> -nnoremap <Leader>pu :PlugUpdate<CR> -let g:which_key_map.p = { 'name' : '+Plug' } -let g:which_key_map.p.c = 'Plug-clean' -let g:which_key_map.p.i = 'Plug-install' -let g:which_key_map.p.u = 'Plug-update' - -" whichkey -nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR> -nnoremap <silent> <localleader> :<C-U>WhichKey '\'<CR> - -" lsp -if executable('pylsp') - " pip install python-lsp-server - au User lsp_setup call lsp#register_server({ - \ 'name': 'pylsp', - \ 'cmd': {server_info->['pylsp']}, - \ 'allowlist': ['python'], - \ }) -endif - -function! s:on_lsp_buffer_enabled() abort - setlocal omnifunc=lsp#complete - setlocal signcolumn=yes - if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif - nmap <buffer> gd <plug>(lsp-definition) - nmap <buffer> gs <plug>(lsp-document-symbol-search) - nmap <buffer> gS <plug>(lsp-workspace-symbol-search) - nmap <buffer> gr <plug>(lsp-references) - nmap <buffer> gi <plug>(lsp-implementation) - nmap <buffer> gt <plug>(lsp-type-definition) - nmap <buffer> <Leader>lr <plug>(lsp-rename) - nmap <buffer> [t <plug>(lsp-previous-diagnostic) - nmap <buffer> ]t <plug>(lsp-next-diagnostic) - nmap <buffer> K <plug>(lsp-hover) - " nnoremap <buffer> <expr><C-D> lsp#scroll(+4) - " nnoremap <buffer> <expr><C-U> lsp#scroll(-4) - - let g:lsp_format_sync_timeout = 1000 - autocmd! BufWritePre *.rs,*.go,*.py call execute('LspDocumentFormatSync') - - " refer to doc to add more commands -endfunction - -let g:which_key_map.g = { - \ 'name' : '+Goto' , - \ 'd' : 'Definition' , - \ 's' : 'Symbol' , - \ 'S' : 'Workspace-symbol' , - \ 'r' : 'References' , - \ 'i' : 'Implementation' , - \ 't' : 'Type-definition' , - \ } - -let g:which_key_map['['] = { 'name' : '+Previous' } -let g:which_key_map[']'] = { 'name' : '+Next' } -let g:which_key_map['[t'] = 'Diagnostic' -let g:which_key_map[']t'] = 'Diagnostic' -let g:which_key_map.K = 'Keyword' - -augroup lsp_install - au! - " call s:on_lsp_buffer_enabled only for languages that has the server registered. - autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() -augroup END - -let g:lsp_fold_enabled = 0 -let g:lsp_log_verbose = 1 -let g:lsp_log_file = expand('~/.cache/vim/vim-lsp.log') -let g:asyncomplete_log_file = expand('~/.cache/vim/asyncomplete.log') -let g:lsp_settings_filetype_python = ['pyright-langserver', 'ruff', 'ruff-lsp'] - -nnoremap <Leader>li :LspInstallServer<CR> - -" vim-airline -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif -let g:airline_symbols.colnr = ' C:' -let g:airline_symbols.linenr = ' L:' -let g:airline_symbols.maxlinenr = ' ' -let g:airline#extensions#whitespace#symbol = '!' - -" colorscheme -if isdirectory(expand("${XDG_CONFIG_HOME:-$HOME/.config}/vim/plugged/catppuccin")) - let g:airline_theme = 'catppuccin_mocha' - colorscheme catppuccin_mocha -endif - -" fzf -let g:fzf_vim = {} -let $FZF_DEFAULT_OPTS = "--layout=default --preview-window 'right:60%' --preview 'bat --style=numbers --line-range :300 {}' - \ --bind ctrl-y:preview-up, - \ ctrl-e:preview-down, - \ ctrl-b:preview-page-up, - \ ctrl-f:preview-page-down, - \ ctrl-u:preview-half-page-up, - \ ctrl-d:preview-half-page-down, - \ shift-up:preview-top, - \ shift-down:preview-bottom, - \ alt-up:half-page-up, - \ alt-down:half-page-down - \ " - -" tmux -if exists('$TMUX') - let g:fzf_layout = { 'tmux': '90%,70%' } - let g:tmux_navigator_no_wrap = 1 -else - let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'relative': v:true } } -endif -let g:fzf_vim.preview_window = ['right,50%,<70(up,40%)', 'ctrl-/'] -let g:fzf_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' -let g:fzf_vim.tags_command = 'ctags -R' - -function! s:build_quickfix_list(lines) - call setqflist(map(copy(a:lines), '{ "filename": v:val, "lnum": 1 }')) - copen - cc -endfunction - -let g:fzf_action = { - \ 'ctrl-q' : function('s:build_quickfix_list'), - \ 'ctrl-t' : 'tab split' , - \ 'ctrl-x' : 'split' , - \ 'ctrl-v' : 'vsplit' , - \ } - -nnoremap <Leader>cl :Colors<CR> -nnoremap <Leader>fb :Files ~/.local/bin<CR> -nnoremap <Leader>fc :Files ~/.config<CR> -nnoremap <Leader>fd :Files ~/.dotfiles<CR> -nnoremap <Leader>ff :Files .<CR> -nnoremap <Leader>fF :Files ~<CR> -nnoremap <Leader>fg :GFiles<CR> -nnoremap <Leader>fG :GFiles?<CR> -nnoremap <Leader>fs :Files ~/.local/src/suckless<CR> -nnoremap <Leader>fv :Files ~/.config/vim<CR> -nnoremap <Leader>sb :Buffers<CR> -nnoremap <Leader>sc :Changes<CR> -nnoremap <Leader>sC :Commands<CR> -nnoremap <Leader>sg :Rg<CR> -nnoremap <Leader>sG :RG<CR> -nnoremap <Leader>shc :History:<CR> -nnoremap <Leader>shh :History<CR> -nnoremap <Leader>shp :Helptags<CR> -nnoremap <Leader>shs :History/<CR> -nnoremap <Leader>sj :Jumps<CR> -nnoremap <Leader>sk :Maps<CR> -nnoremap <Leader>sl :Locate<CR> -nnoremap <Leader>sm :Marks<CR> -nnoremap <Leader>sn :Snippets<CR> -nnoremap <Leader>st :Filetypes<CR> -nnoremap <Leader>gc :Commits<CR> -nnoremap <Leader>gC :BCommits<CR> - -let g:which_key_map.c = 'Color-schemes' -let g:which_key_map.f = { - \ 'name' : '+Find' , - \ 'b' : 'Scripts' , - \ 'c' : 'Config' , - \ 'd' : 'Dotfiles' , - \ 'f' : 'Files' , - \ 'F' : 'Root-files' , - \ 'g' : 'Git-files' , - \ 'G' : 'Git-status' , - \ 's' : 'Suckless' , - \ 'v' : 'Vim-config' , - \ } - -let g:which_key_map.g = { - \ 'name' : '+Git' , - \ 'c' : 'Commits' , - \ 'C' : 'Buffer-commits' , - \ } - -let g:which_key_map.s = { - \ 'name' : '+Search' , - \ 'b' : 'Buffers' , - \ 'c' : 'Changes' , - \ 'C' : 'Commands' , - \ 'g' : 'Rip-grep' , - \ 'G' : 'Rip-Grep' , - \ 'h' : { - \ 'name' : '+History' , - \ 'c' : 'Command-history' , - \ 'h' : 'History' , - \ 'p' : 'Help-tags' , - \ 's' : 'Search-history' , - \ }, - \ 'j' : 'Jumps' , - \ 'k' : 'Key-maps' , - \ 'l' : 'Locate' , - \ 'm' : 'Marks' , - \ 'n' : 'Snippets' , - \ 't' : 'File-types' , - \ } - - -" snippets -let g:SuperTabDefaultCompletionType = '<C-N>' -let g:SuperTabCrMapping = 0 -let g:UltiSnipsExpandTrigger = '<C-E>' -let g:UltiSnipsJumpForwardTrigger = '<tab>' -let g:UltiSnipsJumpBackwardTrigger = '<s-tab>' -let g:UltiSnipsEditSplit = 'vertical' -let g:UltiSnipsAutoTrigger = 1 -let g:asyncomplete_auto_completeopt = 0 -let g:asyncomplete_auto_popup = 1 - -set completeopt=menuone,noinsert,noselect,preview -autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif - -if has('python3') - call asyncomplete#register_source(asyncomplete#sources#ultisnips#get_source_options({ - \ 'name': 'ultisnips', - \ 'allowlist': ['*'], - \ 'completor': function('asyncomplete#sources#ultisnips#completor'), - \ })) -endif - -inoremap <expr> <Tab> pumvisible() ? "\<C-N>" : "\<Tab>" -inoremap <expr> <S-Tab> pumvisible() ? "\<C-P>" : "\<S-Tab>" -inoremap <expr> <CR> pumvisible() ? asyncomplete#close_popup() : "\<CR>" - -" whichkey -set timeoutlen=500 - -let g:which_key_map.a = 'Select-all-the-text' -let g:which_key_map.b = { 'name' : '+Buffer' } -let g:which_key_map.b.n = 'New/open-buffer' -let g:which_key_map.c = { 'name' : '+Format' } -let g:which_key_map.c.f = 'Format-buffer' -let g:which_key_map.e = 'Explorer' -let g:which_key_map.h = { 'name' : '+Hex' } -let g:which_key_map.h.x = 'Toggle-hex/reverse-conversion' -let g:which_key_map.l = { 'name' : '+Lex/Lsp' } -let g:which_key_map.l.e = 'Open-lex' -let g:which_key_map.l.i = 'Lsp-install-server' -let g:which_key_map.l.r = 'Rename' -let g:which_key_map.o = { 'name' : '+Open' } -let g:which_key_map.o.g = 'Orthography' -let g:which_key_map.Q = 'Force-quit-all' -let g:which_key_map.r = { 'name' : '+Replace' } -let g:which_key_map.r.w = 'Replace word' -let g:which_key_map.s = { 'name' : '+Surround' } -let g:which_key_map.s.o = 'Source-file' -let g:which_key_map.s.w = 'Surround-word' -let g:which_key_map.t = 'Go-to-tab' -let g:which_key_map["'"] = 'Register' -let g:which_key_map['w'] = { - \ 'name' : '+windows' , - \ 'd' : ['<C-W>c' , 'Delete-window'] , - \ 'h' : ['<C-W>h' , 'Window-left'] , - \ 'H' : ['<C-W>5<' , 'Expand-window-left'] , - \ 'j' : ['<C-W>j' , 'Window-below'] , - \ 'J' : [':resize +5' , 'Expand-window-below'] , - \ 'k' : ['<C-W>k' , 'Window-up'] , - \ 'K' : [':resize -5' , 'Expand-window-up'] , - \ 'l' : ['<C-W>l' , 'Window-right'] , - \ 'L' : ['<C-W>5>' , 'Expand-window-right'] , - \ 's' : ['<C-W>s' , 'Split-window-below'] , - \ 'v' : ['<C-W>v' , 'Split-window-below'] , - \ 'w' : ['<C-W>w' , 'Other-window'] , - \ '2' : ['<C-W>v' , 'Layout-double-columns'] , - \ '-' : ['<C-W>s' , 'Split-window-below'] , - \ '|' : ['<C-W>v' , 'Split-window-right'] , - \ '=' : ['<C-W>=' , 'Balance-window'] , - \ '?' : ['Windows' , 'Fzf-window'] , - \ } - -" }}} - - " SHORTCUTS ---------------------------------------------------------------- {{{ -if filereadable(expand("${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim")) - silent! source ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim +if filereadable(expand("${XDG_CONFIG_HOME:-$HOME/.config}/vim/shortcuts.vim")) + silent! source ${XDG_CONFIG_HOME:-$HOME/.config}/vim/shortcuts.vim endif " }}} diff --git a/fedora/.config/vim/vimrc b/fedora/.config/vim/vimrc index 0535aec..0a76953 100644 --- a/fedora/.config/vim/vimrc +++ b/fedora/.config/vim/vimrc @@ -367,9 +367,6 @@ set title set timeoutlen=300 " Time (in milliseconds) to wait for a mapping set ttimeoutlen=10 " Time (in milliseconds) to wait for terminal key codes -" Esc -set noesckeys - " Set the commands to save in history default number is 20. set history=1000 diff --git a/fedora/.config/zsh/.zshrc b/fedora/.config/zsh/.zshrc new file mode 100644 index 0000000..12fa76a --- /dev/null +++ b/fedora/.config/zsh/.zshrc @@ -0,0 +1,141 @@ +#!/bin/zsh + +### --- Prompt --- ### +autoload -U colors && colors +autoload -Uz add-zsh-hook vcs_info +setopt prompt_subst +add-zsh-hook precmd vcs_info +PROMPT='%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%F{green}${vcs_info_msg_0_}%{$reset_color%}$%b ' +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' unstagedstr '*' +zstyle ':vcs_info:*' stagedstr '+' +zstyle ':vcs_info:git:*' formats "%{$fg[blue]%}(%{$fg[white]%}%b%{$fg[blue]%}:%r%{$fg[yellow]%}%u%m%{$fg[magenta]%}%c%{$fg[blue]%})" +zstyle ':vcs_info:git:*' actionformats "%{$fg[blue]%}(%{$fg[white]%}%b%{$fg[blue]%}:%r%{$reset_color%}|%{$fg[red]%}%a%u%c%{$fg[blue]%})" +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-behind-upstream git-ahead-upstream git-diverged-upstream ++vi-git-untracked() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]] && \ + git status --porcelain | grep -m 1 "^??" &>/dev/null + then + hook_com[misc]+="%{$fg[yellow]%}%%" + fi +} ++vi-git-behind-upstream() { + if [[ $(git rev-list HEAD..$(git rev-parse --abbrev-ref @{upstream}) --count) -gt 0 ]]; then + hook_com[misc]+="%{$fg[red]%}<" + fi +} ++vi-git-ahead-upstream() { + if [[ $(git rev-list $(git rev-parse --abbrev-ref @{upstream})..HEAD --count) -gt 0 ]]; then + hook_com[misc]+="%{$fg[green]%}>" + fi +} ++vi-git-diverged-upstream() { + local ahead_count=$(git rev-list --count $(git rev-parse --abbrev-ref @{upstream})..HEAD 2>/dev/null) + local behind_count=$(git rev-list --count HEAD..$(git rev-parse --abbrev-ref @{upstream}) 2>/dev/null) + if [[ "$ahead_count" -gt 0 && "$behind_count" -gt 0 ]]; then + hook_com[misc]+="%{$fg[white]%}<>" + fi +} + + +### --- ZSH --- ### +# GnuPG +unset SSH_AGENT_PID +if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + gpgconf --launch gpg-agent +fi +export GPG_TTY="$(tty)" +gpg-connect-agent updatestartuptty /bye >/dev/null + +# Options +stty -ixon # Disable Ctrl+S and Ctrl+Q flow control +setopt autocd +setopt extendedglob +setopt nomatch +setopt menucomplete +setopt interactive_comments +unsetopt bad_pattern + +# History in cache directory +HISTSIZE=10000000 +SAVEHIST=10000000 +HISTFILE="${XDG_DATA_HOME:-${HOME}/.local/share}/history/sh_history" +setopt inc_append_history +setopt appendhistory +setopt share_history +setopt hist_ignore_all_dups +setopt hist_ignore_space # ignores all commands starting with a blank space! Usefull for passwords + +# Style +ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(vi-forward-char forward-char) +ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS:#(vi-forward-char|forward-char)}) +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=60' +zstyle :bracketed-paste-magic paste-init pasteinit +zstyle :bracketed-paste-magic paste-finish pastefinish + + +### --- Autoload compinit and run it --- ### +autoload -Uz compinit # Autoload compinit +_comp_options+=(globdots) # Include hidden files in completion +compinit # Initialize completion system +zmodload zsh/complist # Load completion list module +zmodload -i zsh/parameter # Load last command output + +# _dotbare_completion_cmd +zstyle ':completion:*' menu select # selectable menu +zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*' # case insensitive completion +zstyle ':completion:*' special-dirs true # Complete . and .. special directories +zstyle ':completion:*' list-colors '' # colorize completion lists +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' # colorize kill list + +# fzf-tab +zstyle ':completion:*:git-checkout:*' sort false # disable sort when completing `git checkout` +zstyle ':completion:*:descriptions' format '[%d]' # set descriptions format to enable group support +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} # set list-colors to enable filename colorizing +zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath' # preview directory's content with exa when completing cd +zstyle ':fzf-tab:*' switch-group ',' '.' # switch group using `,` and `.` + + +### --- Load ZSH Configs, Aliases, Functions, and Shortcuts --- ### +# NOTE: the sequence of sourcing files is strict. Be careful to change the sequence. +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/git.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/git.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/p10k.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/p10k.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/autocomplete.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/autocomplete.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/scripts.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/scripts.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/keymaps.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/keymaps.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/plugins.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/plugins.zsh" +[ -f "${ZDOTDIR:-${HOME}/.config/zsh}/packages.zsh" ] && source "${ZDOTDIR:-${HOME}/.config/zsh}/packages.zsh" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/git-aliasrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/git-aliasrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" +[ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" + + +### --- AVANTE --- ### +export AVANTE_ANTHROPIC_API_KEY="$(pass show api/claude/nvim | head -n1)" +export AVANTE_OPENAI_API_KEY="$(pass show api/chatGPT/nvim | head -n1)" +# export AVANTE_AZURE_OPENAI_API_KEY="$(pass show api/azure/nvim | head -n1)" +# export AVANTE_GEMINI_API_KEY="$(pass show api/gemini/nvim | head -n1)" +# export AVANTE_CO_API_KEY="$(pass show api/cohere/nvim | head -n1)" +# export AVANTE_AIHUBMIX_API_KEY="$(pass show api/aihubmix/nvim | head -n1)" +# export AVANTE_MOONSHOT_API_KEY="$(pass show api/moonshot/nvim | head -n1)" + + +### --- OPENAI --- ### +export OPENAI_API_KEY="$(pass show api/chatGPT/nvim | head -n1)" + + +## --- TMUX --- ### +if command -v tmux >/dev/null 2>&1 && [ -z "$TMUX" ]; then + terminal_count=$(pgrep -u "$USER" -ax "${TERMINAL:-st}" | grep -Ev 'ncmpcpp|newsboat|pulsemixer|spterm|splf|spcalc|stig|vimwikitodo' | wc -l) + if [ "$terminal_count" -le 1 ]; then + if ! tmux has-session 2>/dev/null; then + exec tmux new-session -s code + else + exec tmux attach-session + fi + fi +fi diff --git a/fedora/.config/zsh/autocomplete.zsh b/fedora/.config/zsh/autocomplete.zsh new file mode 100644 index 0000000..4763f71 --- /dev/null +++ b/fedora/.config/zsh/autocomplete.zsh @@ -0,0 +1,70 @@ +### --- Auto-completes aliases --- ### +# alias - normal aliases (completed with trailing space) +# balias - blank aliases (completed without space) +# ialias - ignored aliases (not completed) + + +# ignored aliases +typeset -a ialiases +ialiases=() + +ialias() { + alias $@ + args="$@" + args=${args%%\=*} + ialiases+=(${args##* }) +} + + +# blank aliases +typeset -a baliases +baliases=() + +balias() { + alias $@ + args="$@" + args=${args%%\=*} + baliases+=(${args##* }) +} + + +# functionality +expand-alias-space() { + [[ $LBUFFER =~ "\<(${(j:|:)baliases})\$" ]] && insertBlank=$? + if [[ ! $LBUFFER =~ "\<(${(j:|:)ialiases})\$" ]]; then + zle _expand_alias + zle expand-word + fi + zle self-insert + if [[ "$insertBlank" -eq 0 ]]; then + zle backward-delete-char + fi +} +zle -N expand-alias-space + + +# starts multiple args as programs in background +background() { + for ((i=2;i<=$#;i++)); do + ${@[1]} ${@[$i]} &> /dev/null & + done +} + + +# A function for expanding any aliases before accepting the line as is and executing the entered command +expand-alias-and-accept-line() { + expand-alias-space + # zle .backward-delete-char + zle .accept-line +} +# zle -N accept-line expand-alias-and-accept-line + + +bindkey '^ ' expand-alias-space # ctrl-space to bypass completion +bindkey ' ' magic-space +bindkey -M isearch ' ' magic-space + + +# file completion patterns +zstyle ':completion:*:*:nvim:*' file-patterns '^*.(pdf|odt|ods|doc|docx|xls|xlsx|odp|ppt|pptx|mp4|mkv|aux):source-files' '*:all-files' +zstyle ':completion:*:*:(build-workshop|build-document):*' file-patterns '*.mom' diff --git a/fedora/.config/zsh/git.zsh b/fedora/.config/zsh/git.zsh new file mode 100644 index 0000000..e5633bf --- /dev/null +++ b/fedora/.config/zsh/git.zsh @@ -0,0 +1,7 @@ +#!/bin/zsh + +# Speed up git completion +# http://talkings.org/post/5236392664/zsh-and-slow-git-completion +__git_files () { + _wanted files expl 'local files' _files +} diff --git a/fedora/.config/zsh/keymaps.zsh b/fedora/.config/zsh/keymaps.zsh new file mode 100644 index 0000000..81b3027 --- /dev/null +++ b/fedora/.config/zsh/keymaps.zsh @@ -0,0 +1,342 @@ +#!/bin/zsh + +### --- CUSTOM FUNCTIONS --- ### +# man +function man-command-line() { pre_cmd "man"; } + +# sudo +function sudo-command-line() { pre_cmd "sudo"; } + +# clears the shell and displays the dir tree with level 2 +function clear-tree-2() { + clear + tree -L 2 + zle reset-prompt +} +zle -N clear-tree-2 + +# clears the shell and displays the dir tree with level 3 +function clear-tree-3() { clear && tree -L 3 && zle reset-prompt; } +zle -N clear-tree-3 + +# prints the current date in ISO 8601 +function print-current-date() { LBUFFER+=$(date -I); } +zle -N print-current-date + +# prints the current Unix timestamp +function print-unix-timestamp() { LBUFFER+=$(date +%s); } +zle -N print-unix-timestamp + +# git status +function git-status() { clear && git status && zle reset-prompt; } +zle -N git-status + +# appends the clipboard contents to the buffer +function vi-append-clip-selection() { char=${RBUFFER:0:1} && RBUFFER=${RBUFFER:1} && RBUFFER=$char$(clippaste)$RBUFFER; } + +# copy +function detect-clipboard() { + emulate -L zsh + + if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } + function clippaste() { pbpaste; } + elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then + function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } + function clippaste() { cat /dev/clipboard; } + elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then + function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } + function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } + elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } + function clippaste() { wl-paste --no-newline; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } + function clippaste() { xsel --clipboard --output; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } + function clippaste() { xclip -out -selection clipboard; } + elif (( ${+commands[lemonade]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; } + function clippaste() { lemonade paste; } + elif (( ${+commands[doitclient]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | doitclient wclip; } + function clippaste() { doitclient wclip -r; } + elif (( ${+commands[win32yank]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | win32yank -i; } + function clippaste() { win32yank -o; } + elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then + function clipcopy() { cat "${1:-/dev/stdin}" | termux-clipboard-set; } + function clippaste() { termux-clipboard-get; } + elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then + function clipcopy() { tmux load-buffer "${1:--}"; } + function clippaste() { tmux save-buffer -; } + else + function _retry_clipboard_detection_or_fail() { + local clipcmd="${1}"; shift + if detect-clipboard; then + "${clipcmd}" "$@" + else + print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 + return 1 + fi + } + function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; } + function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } + return 1 + fi +} + +function clipcopy clippaste { + unfunction clipcopy clippaste + detect-clipboard || true # let one retry + "$0" "$@" +} + +function copybuffer () { + if builtin which clipcopy &>/dev/null; then + printf "%s" "$BUFFER" | clipcopy + fi +} + +# Function to switch to the left tmux pane and maximize it +function tmux_left_pane() { + export TMUX_PANE_DIRECTION="right" + if [[ $TMUX_PANE_DIRECTION == "right" ]]; then + tmux select-pane -L # Move to the left (opposite of right) + elif [[ $TMUX_PANE_DIRECTION == "bottom" ]]; then + tmux select-pane -U # Move to the top (opposite of bottom) + fi + tmux resize-pane -Z +} + + +### --- GLOBAL --- ### +# emacs style +bindkey '^a' beginning-of-line +bindkey '^e' end-of-line + +# function key bindings +bindkey '^X^E' clear-tree-2 +bindkey '^X^W' clear-tree-3 +bindkey '^X^S' git-status +bindkey '^X^X^T' print-current-date +bindkey '^X^X^U' print-unix-timestamp + + +### --- VI-MODE --- ### +if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.zsh" ]]; then + ### --- ZSH-VI-MODE--- ### + # config + ZVM_INIT_MODE=sourcing + ZVM_VI_ESCAPE_BINDKEY=jk + ZVM_VI_INSERT_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY + ZVM_VI_VISUAL_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY + ZVM_VI_OPPEND_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY + ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BEAM + ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK + ZVM_OPPEND_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE + ZVM_LAZY_KEYBINDINGS=false + # ZVM_VI_HIGHLIGHT_BACKGROUND=#458588 + + + function zvm_bind_script() { + local keymap="$1" + local key="$2" + local script="$3" + + # Dynamically define a widget to run the script + eval "function run_script_${keymap}_${key//\^/}() { + zle -I + $script + zle reset-prompt + }" + + # Register the widget with zsh-vi-mode + zvm_define_widget "run_script_${keymap}_${key//\^/}" + zvm_bindkey "$keymap" "$key" "run_script_${keymap}_${key//\^/}" + } + + function zvm_after_init() { + ### --- KEY BINDINGS --- ### + # programs & scripts + bindkey -s '^B' '^ubc -lq\n' + bindkey -s '^D' '^ucdi\n' + bindkey -s '^F' '^ufzffiles\n' + bindkey -s '^G' '^ulf\n' + # bindkey -s '^G' '^uyazi\n' + bindkey -s '^N' '^ulastfiles\n' + bindkey -s '^O' '^utmo\n' + bindkey -s '^P' '^ufzfpass\n' + bindkey -s '^Q' '^uhtop\n' + bindkey -s '^T' '^usessionizer\n' + bindkey -s '^Y' '^ulfcd\n' + # bindkey -s '^Y' '^uyazicd\n' + bindkey -s '^Z' '^upd\n' + # bindkey -s '^_' '^u\n' + + # ctrl+x key bindings + zvm_bind_script viins '^X^A' 'ali' + zvm_bind_script viins '^X^B' 'gitopenbranch' + zvm_bind_script viins '^X^D' 'fD' + zvm_bind_script viins '^X^F' 'gitfiles' + zvm_bind_script viins '^X^G' 'rgafiles ' + zvm_bind_script viins '^X^L' 'gloac' + zvm_bind_script viins '^X^N' 'lastfiles -l' + # zvm_bind_script viins '^X^O' '^u\n' + zvm_bind_script viins '^X^Q' 'fpkill' + zvm_bind_script viins '^X^R' 'fgst' + zvm_bind_script viins '^X^T' 'gitstagedfiles' + zvm_bind_script viins '^X^U' 'gitupdate' + # zvm_bind_script viins '^X^]' '^u\n' + zvm_bind_script viins '^X^_' 'fzffns' + zvm_bind_script viins '^X^X^B' 'rbackup' + zvm_bind_script viins '^X^X^P' 'pcyr' + zvm_bind_script viins '^X^X^R' 'rbackup -r' + zvm_bind_script viins '^X^X^S' 'sshadd' + zvm_bind_script viins '^X^X^Y' 'yay -Syu && remaps' + + # widgets + zvm_define_widget sudo-command-line + zvm_bindkey vicmd '^S' sudo-command-line + zvm_bindkey viins '^S' sudo-command-line + zvm_define_widget insert_last_command_output + zvm_bindkey viins '^]' insert_last_command_output + zvm_define_widget tmux_left_pane + zvm_bindkey vicmd '^[\' tmux_left_pane + zvm_bindkey viins '^[\' tmux_left_pane + zvm_define_widget man-command-line + zvm_bindkey vicmd '^X^M' man-command-line + zvm_bindkey viins '^X^M' man-command-line + zvm_define_widget vi-append-clip-selection + zvm_bindkey viins "^X^P" vi-append-clip-selection + zvm_bindkey vicmd "^X^P" vi-append-clip-selection + zvm_define_widget copybuffer + zvm_bindkey viins "^X^Y" copybuffer + zvm_bindkey vicmd "^X^Y" copybuffer + } + + # key bindings (lazy) + # function zvm_after_lazy_keybindings() { + # + # } + + # Append a command directly + # Since the default initialization mode, this plugin will overwrite the previous key + # bindings, this causes the key bindings of other plugins (i.e. fzf, zsh-autocomplete, etc.) to fail. + # zvm_after_init_commands+=('[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh') + # function zvm_after_init() { + # [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + # } +else + ### --- Built-in --- ### + # Cursor shape + bindkey -v # activate vim mode. + KEYTIMEOUT=5 + + # Change cursor shape for different vi modes. + function zle-keymap-select () { + case "$KEYMAP $1" in + vicmd*|*block) echo -ne '\e[1 q' ;; # block + viins*|main*|''|*beam) echo -ne '\e[5 q' ;; # beam + esac + } + zle -N zle-keymap-select + + function zle-line-init() { + zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) + echo -ne "\e[5 q" + } + zle -N zle-line-init + echo -ne '\e[5 q' # Use beam shape cursor on startup. + function preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. + + + ### --- VI-MODE KEY BINDINGS --- ### + bindkey -M menuselect 'h' vi-backward-char + bindkey -M menuselect 'l' vi-forward-char + bindkey -M menuselect 'k' vi-up-line-or-history + bindkey -M menuselect 'j' vi-down-line-or-history + bindkey -v '^?' backward-delete-char + bindkey '^[[P' delete-char + + # edit line in vim with ctrl-v in viins and ctrl-e in vicmd + autoload edit-command-line + zle -N edit-command-line + bindkey '^X^V' edit-command-line # ctrl-v + bindkey -M vicmd '^[[P' vi-delete-char # delete + bindkey -M vicmd '^e' edit-command-line # ctrl-e + bindkey -M visual '^[[P' vi-delete # delete + bindkey -M viins 'jk' vi-cmd-mode # normal mode + + # last command output + zle -N insert_last_command_output + bindkey -M viins '^]' insert_last_command_output + + # man + zle -N man-command-line + bindkey -M emacs '^X^M' man-command-line + bindkey -M vicmd '^X^M' man-command-line + bindkey -M viins '^X^M' man-command-line + + # sudo + zle -N sudo-command-line + bindkey -M emacs '^S' sudo-command-line + bindkey -M vicmd '^S' sudo-command-line + bindkey -M viins '^S' sudo-command-line + + # bind y/Y to yank until end of line/yank whole line + # bindkey -M vicmd y zsh-system-clipboard-vicmd-vi-yank-eol + # bindkey -M vicmd Y zsh-system-clipboard-vicmd-vi-yank-whole-line + + # appends the clipboard contents to the buffer + zle -N vi-append-clip-selection + bindkey -M emacs "^X^P" vi-append-clip-selection + bindkey -M viins "^X^P" vi-append-clip-selection + bindkey -M vicmd "^X^P" vi-append-clip-selection + + # copy buffer + zle -N copybuffer + bindkey -M emacs "^X^Y" copybuffer + bindkey -M viins "^X^Y" copybuffer + bindkey -M vicmd "^X^Y" copybuffer + + # Register the function as a ZLE widget + zle -N tmux_left_pane + bindkey -M vicmd '^[\' tmux_left_pane + bindkey -M viins '^[\' tmux_left_pane + + ### --- DEFAULT KEY BINDINGS --- ### + # programs & scripts + bindkey -s '^B' '^ubc -lq\n' + bindkey -s '^D' '^ucdi\n' + bindkey -s '^F' '^ufzffiles\n' + bindkey -s '^G' '^ulf\n' + bindkey -s '^N' '^ulastfiles\n' + bindkey -s '^O' '^utmo\n' + bindkey -s '^P' '^ufzfpass\n' + bindkey -s '^Q' '^uhtop\n' + bindkey -s '^T' '^usessionizer\n' + bindkey -s '^Y' '^ulfcd\n' + bindkey -s '^Z' '^upd\n' + bindkey -s '^_' '^ucht\n' + bindkey -s '^X^A' '^uali\n' + bindkey -s '^X^B' '^ugitopenbranch\n' + bindkey -s '^X^D' '^ufD\n' + bindkey -s '^X^F' '^ugitfiles\n' + bindkey -s '^X^G' '^urgafiles ' + bindkey -s '^X^L' '^ugloac\n' + bindkey -s '^X^N' '^ulastfiles -l\n' + # bindkey -s '^X^O' '^u\n' + bindkey -s '^X^Q' '^ufpkill\n' + bindkey -s '^X^R' '^ufgst\n' + bindkey -s '^X^T' '^ugitstagedfiles\n' + bindkey -s '^X^U' '^ugitupdate\n' + # bindkey -s '^X^]' '^u\n' + bindkey -s '^X^_' '^ufzffns\n' + bindkey -s '^X^X^B' '^urbackup\n' + bindkey -s '^X^X^P' '^upcyr\n' + bindkey -s '^X^X^R' '^urbackup -r\n' + bindkey -s '^X^X^S' '^usshadd\n' + bindkey -s '^X^X^Y' '^uyay -Syu && remaps\n' +fi diff --git a/fedora/.config/zsh/p10k.zsh b/fedora/.config/zsh/p10k.zsh new file mode 100644 index 0000000..604d76d --- /dev/null +++ b/fedora/.config/zsh/p10k.zsh @@ -0,0 +1,1721 @@ +#!/bin/zsh + +# Generated by Powerlevel10k configuration wizard on 2024-03-06 at 08:21 CST. +# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 52020. +# Wizard options: nerdfont-v3 + powerline, large icons, unicode, lean, 24h time, +# 2 lines, disconnected, no frame, sparse, many icons, fluent, transient_prompt, +# instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' + + # Zsh >= 5.1 is required. + [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline # \n + prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + asdf # asdf version manager (https://github.com/asdf-vm/asdf) + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + pyenv # python environment (https://github.com/pyenv/pyenv) + goenv # go environment (https://github.com/syndbg/goenv) + nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) + # java_version # java version (https://www.java.com/) + # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) + fvm # flutter version management (https://github.com/leoafarias/fvm) + luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) + jenv # java version from jenv (https://github.com/jenv/jenv) + plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) + scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) + haskell_stack # haskell version from stack (https://haskellstack.org/) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + # terraform_version # terraform version (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + gcloud # google cloud cli account and project (https://cloud.google.com/) + google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + toolbox # toolbox name (https://github.com/containers/toolbox) + context # user@hostname + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) + yazi # yazi shell (https://github.com/sxyazi/yazi) + nnn # nnn shell (https://github.com/jarun/nnn) + lf # lf shell (https://github.com/gokcehan/lf) + xplr # xplr shell (https://github.com/sayanarijit/xplr) + vim_shell # vim shell indicator (:sh) + midnight_commander # midnight commander shell (https://midnight-commander.org/) + nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + # vpn_ip # virtual private network indicator + load # CPU load + # disk_usage # disk usage + ram # free RAM + # swap # used swap + todo # todo items (https://github.com/todotxt/todo.txt-cli) + timewarrior # timewarrior tracking status (https://timewarrior.net/) + taskwarrior # taskwarrior task count (https://taskwarrior.org/) + per_directory_history # Oh My Zsh per-directory-history local/global indicator + # cpu_arch # CPU architecture + time # current time + # =========================[ Line #2 ]========================= + newline + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + proxy # system-wide http/https/ftp proxy + battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=nerdfont-v3 + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=moderate + + # Basic style options that define the overall look of your prompt. You probably don't want to + # change them. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll + # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and + # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. + typeset -g POWERLEVEL9K_SHOW_RULER=false + typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' + typeset -g POWERLEVEL9K_RULER_FOREGROUND=242 + + # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' + # to make it easier to see the alignment between left and right prompt and to separate prompt + # from command output. It serves the same purpose as ruler (see above) without increasing + # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false + # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact + # prompt. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 + # Add a space between the end of left prompt and the filler. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + # Add a space between the filler and the start of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + + ##################################[ dir: current directory ]################################## + # Default current directory color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-versions + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + # + # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. + # This moves the truncation point to the right (positive offset) or to the left (negative offset) + # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" + # respectively. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON + # and POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 + + # The default icon shown next to non-writable and non-existent directories when + # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories + # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one + # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or + # WORK_NON_EXISTENT. + # + # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NON_EXISTENT. + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 ' + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + fi + + local res + + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" + fi + + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi + + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" + fi + + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + + if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then + # Tip: Uncomment the next line to display '=' if up to date with the remote. + # res+=" ${clean}=" + fi + + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg repository. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for repositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes at least this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent directory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Julia version from asdf. + typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### + # Yazi shell color. + typeset -g POWERLEVEL9K_YAZI_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### + # lf shell color. + typeset -g POWERLEVEL9K_LF_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## + # xplr shell color. + typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########################[ vim_shell: vim shell indicator (:sh) ]########################### + # Vim shell indicator color. + typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 + # Custom icon. + # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### + # Midnight Commander shell color. + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## + # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 + + # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. + # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## + # chezmoi shell color. + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 + # Custom icon. + # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### + # Color when using local/global history. + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130 + + # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' + + # Custom icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ cpu_arch: CPU architecture ]################################ + # CPU architecture color. + typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 + + # Hide the segment when on a specific CPU architecture. + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # If set to "false", won't show virtualenv if pyenv is already shown. + # If set to "if-different", won't show virtualenv if it's the same as pyenv. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + + # Anaconda segment format. The following parameters are available within the expansion. + # + # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. + # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. + # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). + # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). + # + # CONDA_PROMPT_MODIFIER can be configured with the following command: + # + # conda config --set env_prompt '({default_env}) ' + # + # The last argument is a Python format string that can use the following variables: + # + # - prefix The same as CONDA_PREFIX. + # - default_env The same as CONDA_DEFAULT_ENV. + # - name The last segment of CONDA_PREFIX. + # - stacked_env Comma-separated list of names in the environment stack. The first element is + # always the same as default_env. + # + # Note: '({default_env}) ' is the default value of env_prompt. + # + # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER + # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former + # is empty. + typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' + + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or + # starts with "$P9K_PYENV_PYTHON_VERSION/". + # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ + # Perlbrew color. + typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 + # Show perlbrew version only when in a perl project subdirectory. + typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true + # Don't show "perl-" at the front. + typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### + # Scala color. + typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 + # Hide scala version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) + # If set to false, hide scala version if it's the same as global: + # $(scalaenv version-name) == $(scalaenv global). + typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide scala version if it's equal to "system". + typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Don't show terraform workspace if it's literally "default". + typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ terraform_version: terraform version (https://www.terraform.io) ]############## + # Terraform version color. + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # AWS segment format. The following parameters are available within the expansion. + # + # - P9K_AWS_PROFILE The name of the current AWS profile. + # - P9K_AWS_REGION The region associated with the current AWS profile. + typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current azure account name gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current azure account is "company_test", its class is TEST because "company_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### + # Toolbox color. + typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 + # Don't display the name of the toolbox if it matches fedora-toolbox-*. + typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' + # Custom icon. + # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_FOREGROUND=38 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+------------------------------------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt + # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES='\UF008E\UF007A\UF007B\UF007C\UF007D\UF007E\UF007F\UF0080\UF0081\UF0082\UF0079' + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -f 208 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/fedora/.config/zsh/packages.zsh b/fedora/.config/zsh/packages.zsh new file mode 100644 index 0000000..b3931f5 --- /dev/null +++ b/fedora/.config/zsh/packages.zsh @@ -0,0 +1,23 @@ +#!/bin/zsh + +### --- Packages --- ### +typeset -A packages +packages=( + atuin "--disable-up-arrow" + batman "--export-env" + zoxide "--cmd cd --hook prompt" + tmuxdbussync "" +) + +### --- Eval Function --- ### +eval_packages() { + for package in ${(k)packages}; do + if command -v "$package" >/dev/null; then + local args=(${(s: :)packages[$package]}) + [[ ${#args[@]} -gt 0 ]] && eval "$($package init zsh ${args[@]})" || eval "$($package init zsh)" + fi + done +} + +### --- Init --- ### +eval_packages diff --git a/fedora/.config/zsh/plugins.zsh b/fedora/.config/zsh/plugins.zsh new file mode 100644 index 0000000..f1ef0a9 --- /dev/null +++ b/fedora/.config/zsh/plugins.zsh @@ -0,0 +1,105 @@ +#!/bin/zsh + +[[ "$XDG_SCRIPTS_HOME" == "$HOME/.local/bin" ]] || return +[[ "$ZDOTDIR" == "$HOME/.config/zsh" ]] || return +[[ "$ZPLUGINDIR" == "$XDG_SCRIPTS_HOME/zsh" ]] || return + +### --- Plugins --- ### +plugins=( + "Aloxaf/fzf-tab" + # "jeffreytse/zsh-vi-mode" + "kutsan/zsh-system-clipboard" + # "MichaelAquilina/zsh-you-should-use" + # "marlonrichert/zsh-autocomplete" + "ohmyzsh/command-not-found" + #"ohmyzsh/sudo" + # "romkatv/powerlevel10k" + "wfxr/forgit" + "zdharma-continuum/fast-syntax-highlighting" + "zsh-users/zsh-autosuggestions" + "zsh-users/zsh-completions" +) + +### --- Source Plugins --- ### +# Check plugins +zsh_check_plugins() { + installed="true" + for plugin in "${plugins[@]}"; do + PLUGIN_NAME=$(echo "$plugin" | cut -d '/' -f 2) + [ "$ZPLUGINDIR" = "ohmyzsh" ] && ZPLUGINDIR="$PLUGIN_NAME" + PLUGIN_PATH="$ZPLUGINDIR/$PLUGIN_NAME" + [ -d "$PLUGIN_PATH" ] && zsh_source_plugin "$PLUGIN_NAME/$PLUGIN_NAME" || { installed="false"; break; } + done + [ "$installed" = "true" ] || zsh_add_plugins "${plugins[@]}" +} + +# Function to source plugin files +zsh_source_plugin() { + for file in "$@"; do + if [ -f "$ZPLUGINDIR/$file.plugin.zsh" ] && echo "$file" | grep -vq "command-not-found/command-not-found"; then + . "$ZPLUGINDIR/$file.plugin.zsh" + elif echo "$file" | grep -q "command-not-found/command-not-found"; then + . "$ZPLUGINDIR/command-not-found/command-not-found.plugin.zsh" + elif [ -z "$ZPLUGINDIR/$file.plugin.zsh" ] && [ -f "$ZPLUGINDIR/$file.zsh" ]; then + . "$ZPLUGINDIR/$file.zsh" + fi + [ -f "$ZPLUGINDIR/$file.zsh-theme" ] && . "$ZPLUGINDIR/$file.zsh-theme" && . "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/p10k" + done +} + +# Function to add plugins +zsh_add_plugins() { + for plugin do + PLUGIN_NAME=$(echo "$plugin" | cut -d '/' -f 2) + PLUGIN_PATH="$ZPLUGINDIR/$PLUGIN_NAME" + + if [ -d "$PLUGIN_PATH" ]; then + zsh_source_plugin "$PLUGIN_NAME/$PLUGIN_NAME" + else + ORG_NAME=$(echo "$plugin" | cut -d '/' -f 1) + case "$ORG_NAME" in + "ohmyzsh") + [ ! -d "$ZPLUGINDIR/oh-my-zsh" ] && git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$ZPLUGINDIR/oh-my-zsh" >/dev/null 2>&1 + + OHMYZSH_PLUGIN_PATH="$ZPLUGINDIR/oh-my-zsh/plugins/$PLUGIN_NAME" + cp -r "$OHMYZSH_PLUGIN_PATH" "$ZPLUGINDIR/" >/dev/null 2>&1 + rm -rf "$ZPLUGINDIR/oh-my-zsh" >/dev/null 2>&1 + ;; + *) + git clone "https://github.com/$plugin.git" "$PLUGIN_PATH" >/dev/null 2>&1 + ;; + esac + rm -rf "$PLUGIN_PATH/.git" + chmod +x "$PLUGIN_PATH" + fi + done +} + +# Function to sync plugins +zsh_sync_plugins() { + ACTIVE_PLUGINS=$(grep '^[[:space:]]*"[^"]\+"' ~/.config/zsh/plugins.zsh | sed 's|.*/\([^/"]*\)".*|\1|') + + for PLUGIN_DIR in "$ZPLUGINDIR"/*; do + if [ -d "$PLUGIN_DIR" ]; then + PLUGIN_NAME=$(basename "$PLUGIN_DIR") + + echo "$ACTIVE_PLUGINS" | grep -q "$PLUGIN_NAME" || { + echo "Removing unused plugin: $PLUGIN_NAME" + rm -rf "$PLUGIN_DIR" + } + fi + done +} + +# Function to update plugins +# Since .git folder in each plugin dir is removed, +# Delete all plugins and install them agian +# .git is searched in Neovim projects +alias zup=zsh_update_plugins +zsh_update_plugins() { + [ -d "$ZPLUGINDIR" ] && rm -rf "$ZPLUGINDIR" && zsh_check_plugins "${plugins[@]}" + zsh_sync_plugins +} + +zsh_check_plugins "${plugins[@]}" +zsh_sync_plugins diff --git a/fedora/.config/zsh/scripts.zsh b/fedora/.config/zsh/scripts.zsh new file mode 100644 index 0000000..5a47ffa --- /dev/null +++ b/fedora/.config/zsh/scripts.zsh @@ -0,0 +1,880 @@ +#!/bin/zsh + +########################################################################################### +########################################################################################### +### --- ALIAS --- ### +# find aliases +alias ali=fzf_aliases +function fzf_aliases() { + local aliases=$(alias) + local max_length=$(echo "$aliases" | cut -d'=' -f1 | awk '{print length}' | sort -nr | head -n 1) + [ "$max_length" -gt 20 ] && max_length=20 + format_aliases() { + echo "$aliases" | while IFS= read -r line; do + alias_name=$(echo "$line" | cut -d'=' -f1) + alias_command=$(echo "$line" | cut -d'=' -f2- | sed "s/^'//;s/'$//") + printf "%-${max_length}s = %s\n" "$alias_name" "$alias_command" + done + } + alias_file="${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc" + selected_alias=$(format_aliases | fzf --header="select an alias") + # check if an alias was selected + if [ -n "$selected_alias" ]; then + # extract the alias name + alias_name=$(echo "$selected_alias" | cut -d'=' -f1 | xargs) + + # get the line number from the alias file + line_number=$(grep -n "^alias $alias_name=" "$alias_file" | cut -d':' -f1) + + # open nvim at the specified line + if [ -n "$line_number" ]; then + nvim "+$line_number" "$alias_file" + else + scripts_file="${ZDOTDIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/zsh}/7-scripts.zsh" + line_number=$(grep -n "^alias $alias_name=" "$scripts_file" | cut -d':' -f1) + nvim "+$line_number" "$scripts_file" + fi + fi +} + + +########################################################################################### +########################################################################################### +### --- CHEAT.SH --- ### +function cht() { + if [ -z "$1" ]; then + printf "Enter program name: " + read prog + curl cht.sh/"$prog" + else + curl cht.sh/"$1" + fi +} + + +########################################################################################### +########################################################################################### +### --- COLOR --- ### +# print color +alias pcol=print_col +function print_col() { + awk 'BEGIN{ +s="/\\/\\/\\/\\/\\"; s=s s s s s s s s; +for (colnum = 0; colnum<77; colnum++) { + r = 255-(colnum*255/76); + g = (colnum*510/76); + b = (colnum*255/76); + if (g>255) g = 510-g; + printf "\033[48;2;%d;%d;%dm", r,g,b; + printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b; + printf "%s\033[0m", substr(s,colnum+1,1); +} +printf "\n"; + }' +} +function colors() { + curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | zsh +} + + +########################################################################################### +########################################################################################### +### --- COMMAND OUTPUT --- ### +# print last command output +alias ilco=insert_last_command_output +function insert_last_command_output() { LBUFFER+="$(eval $history[$((HISTCMD-1))])"; } + + +########################################################################################### +########################################################################################### +### --- CONFIG --- ### +# fzf config +alias fcfg=fzf_config +function fzf_config() { + [ $# -gt 0 ] && zoxide query -i "$1" | xargs "${EDITOR}" && return + local file + file="$(zoxide query -l | fzf --cycle -1 -0 --no-sort +m)" && cd "${file}" || return 1 +} + + +########################################################################################### +########################################################################################### +### --- COPY --- ### +# copy file name to clipboard +alias cpfn=copy_filename +function copy_filename() { + if ! command -v xclip >/dev/null; then + echo "Error: 'xclip' is not installed." >&2 + return 1 + fi + + if ! command -v fzf >/dev/null; then + echo "Error: 'fzf' is not installed." >&2 + return 1 + fi + + local file="$1" + + # If no argument is provided, use fzf to select a file + if [ -z "$file" ]; then + file=$(fzf --cycle --preview "cat {}") + fi + + # Check if a file was found or selected + if [ -n "$file" ]; then + local filename=$(basename "$file") + echo -n "$filename" | xclip -selection clipboard + echo "Filename copied to clipboard: $filename" + else + echo "No file selected." + fi +} + +# copy file contents +alias cpfc=copy_contents +function copy_contents() { + if ! command -v xclip >/dev/null; then + echo "Error: 'xclip' is not installed." >&2 + return 1 + fi + + if ! command -v fzf >/dev/null; then + echo "Error: 'fzf' is not installed." >&2 + return 1 + fi + + local file="$1" + + # If no argument is provided, use fzf to select a file + if [ -z "$file" ]; then + file=$(fzf --cycle --preview "cat {}") + fi + + # Check if a file was found or selected + if [ -n "$file" ]; then + # Use `sed` to delete only the last newline character + cat "$file" | sed ':a;N;$!ba;s/\n$//' | xclip -selection clipboard + echo "Contents of '$file' copied to clipboard." + else + echo "No file selected." + fi +} + +# copy the current working directory path to the clipboard +alias cpcp=copy_current_path +function copy_current_path() { + if command -v xclip >/dev/null; then + printf "%s" "$PWD" | xclip -selection clipboard + printf "%s\n" "Current working directory '$(basename "$PWD")' path copied to clipboard." + else + printf "%s\n" "Error: 'xclip' command not found. Please install 'xclip' to use this function." + fi +} + +# copy file real path +alias cprp=copy_real_path +function copy_real_path() { + if ! command -v xclip >/dev/null; then + echo "Error: 'xclip' is not installed." >&2 + return 1 + fi + + if ! command -v fzf >/dev/null; then + echo "Error: 'fzf' is not installed." >&2 + return 1 + fi + + local file="$1" + + # If no argument is provided, use fzf to select a file + if [ -z "$file" ]; then + file=$(fzf --cycle --preview "cat {}") + fi + + # Check if a file was found or selected + if [ -n "$file" ]; then + local full_path=$(realpath "$file") + echo -n "$full_path" | xclip -selection clipboard + echo "File path copied to clipboard: $full_path" + else + echo "No file selected." + fi +} + + +########################################################################################### +########################################################################################### +### --- CREATE --- ### +# mkdir && cd +alias mc=mkcd +function mkcd() { mkdir -p "$@" && cd "$_"; } + +# create dir with current date +function mkdt () { mkdir -p ${1:+$1$prefix_separator}"$(date +%F)"; } + + +########################################################################################### +########################################################################################### +### --- DOCKER --- ### +# select a docker container to start and attach to +alias doca=docker_container_init +function docker_container_init() { + local cid + cid=$(docker ps -a | sed 1d | fzf --cycle -1 -q "$1" | awk '{print $1}') + + [ -n "$cid" ] && docker start "$cid" && docker attach "$cid" +} + +# select a running docker container to stop +alias docs=docker_stop +function docker_stop() { + local cid + cid=$(docker ps | sed 1d | fzf --cycle -q "$1" | awk '{print $1}') + + [ -n "$cid" ] && docker stop "$cid" +} + +# select a docker container or containers to remove +alias docrmc=docker_remove_containers +function docker_remove_containers() { docker ps -a | sed 1d | fzf --cycle -q "$1" --no-sort -m --tac | awk '{ print $1 }' | xargs -r docker rm; } + +# select a docker image or images to remove +alias docrmi=docker_remove_images +function docker_remove_images() { docker images | sed 1d | fzf --cycle -q "$1" --no-sort -m --tac | awk '{ print $3 }' | xargs -r docker rmi; } + + +########################################################################################### +########################################################################################### +### --- ECRYPTFS --- ### +# mount ecryptfs +alias emt=ecryptfs_mount +function ecryptfs_mount() { + ! mount | grep -q " $1 " && echo "$(pass show encryption/ecryptfs)" | sudo mount -t ecryptfs "$1" "$2" \ + -o ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes,ecryptfs_sig="$(sudo cat /root/.ecryptfs/sig-cache.txt)",ecryptfs_fnek_sig="$(sudo cat /root/.ecryptfs/sig-cache.txt)",passwd="$(pass show encryption/ecryptfs)" >/dev/null 2>&1 && + echo "'$2' folder is mounted!" +} + + +########################################################################################### +########################################################################################### +### --- GIT --- ### +# TheSiahxyz's git repos +alias gcggg=thesiahxyz_git +function thesiahxyz_git() { + choice=$(ssh "$THESIAH_GIT" "ls -a | grep -i \".*\\.git$\"" | fzf --cycle --prompt=" " --height=50% --layout=reverse --border --exit-0) + [ -d "$HOME/Private/repos" ] || mkdir -p "$HOME/Private/repos" + [ -n "$choice" ] && [ -n "$1" ] && cd "$HOME/Private/repos" && git clone "${THESIAH_GIT:-git@${THESIAH:-thesiah.xyz}}":"$choice" "$1" || + [ -n "$choice" ] && cd "$HOME/Private/repos" && git clone "${THESIAH_GIT:-git@${THESIAH:-thesiah.xyz}}":"$choice" + cd - +} + + +########################################################################################### +########################################################################################### +### --- GOTO --- ### +# go to the path stored in the clipboard +alias cdp=cd_clipboard_path +function cd_clipboard_path() { + if command -v xclip >/dev/null; then + local target_dir + target_dir="$(xclip -o -sel clipboard)" + if [[ -d "${target_dir}" ]]; then + cd "${target_dir}" && printf "%s\n" "Changed directory to: ${target_dir}" + else + printf "%s\n" "Error: Invalid directory path or directory does not exist." + fi + else + printf "%s\n" "Error: 'xclip' command not found. Please install 'xclip' to use this function." + fi +} + +# fzf directory and go to the parent directory +alias fD=fzf_directory +function fzf_directory() { + dirs="$(find "$HOME" -type d \( -path "**/.git/*" -o -path "**/.cache/*" -o -path "**/yay/*" -o -path "$HOME/.local/bin/zsh" \) -prune -o -type d -print | fzf --multi)" + [ -d "$dirs" ] && cd "$dirs" && ls -A || opensessions "$dirs" +} + +# search scripts in ~/.local/bin +alias sscs=search_scripts +function search_scripts() { + choice="$(find ${HOME}/.local/bin -mindepth 1 -not -path "${HOME}/.local/bin/zsh" -not -path "${HOME}/.local/bin/zsh/*" -printf '%P\n' | fzf)" + [ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice" +} + +# check git status by directories in specific path +alias fgst=fetch_git_repos_status +function fetch_git_repos_status() { + SELECTED_DIRS=$(bash << 'EOF' + # Source the Git prompt script to get access to __git_ps1 + source /usr/share/git/completion/git-prompt.sh + + # Enable symbols for dirty state, untracked files, and branch ahead/behind + export GIT_PS1_SHOWDIRTYSTATE="auto" + export GIT_PS1_SHOWUNTRACKEDFILES="auto" + export GIT_PS1_SHOWUPSTREAM="auto" + + # Define an array of target directories + TARGET_DIRECTORIES=( + "$HOME/.dotfiles" + "$HOME/.local/share/.password-store" + "$HOME/.local/src/suckless" + ) + + # Check the directories under the paths. eg. ../repos/* + GIT_DIRS=("$HOME/Private/repos" "$HOME/Public/repos") + + # Append all subdirectories under GIT_DIRS that are Git repositories + for GIT_DIR in "${GIT_DIRS[@]}"; do + if [ -d "$GIT_DIR" ]; then + for SUBDIR in "$GIT_DIR"/*; do + if [ -d "$SUBDIR/.git" ]; then + TARGET_DIRECTORIES+=("$SUBDIR") + fi + done + fi + done + + # Create an array to store the output + OUTPUT=() + + # Function to colorize only the Git status symbols + colorize_git_status() { + local status="$1" + # Colorize the entire status with a single color + echo -e "\033[33m${status}\033[0m" # Apply yellow color to the status + } + + update_time() { + timestamp_file="${HOME}/.cache/gitreposupdate" + current_time=$(date +%s) + if [[ -f "$timestamp_file" ]] && (($(cat "$timestamp_file") > (current_time - 21600))); then + return 1 # No update needed + else + echo "$current_time" >"$timestamp_file" + return 0 # Update needed + fi + } + update_time && update=true || update=false + + # Loop through each directory and get the Git status + for DIR in "${TARGET_DIRECTORIES[@]}"; do + if [ -d "$DIR/.git" ]; then + cd "$DIR" || continue + + if $update; then + if [ "$(dirname $DIR)" = ".password-store" ]; then + pass git fetch >/dev/null 2>&1 + else + git fetch --all --prune --jobs=10 >/dev/null 2>&1 + fi + fi + + # Get Git branch and status using __git_ps1 + GIT_STATUS=$(__git_ps1 "%s") + + # Colorize the Git status + COLORED_GIT_STATUS=$(colorize_git_status "$GIT_STATUS") + + # Add formatted output with colored Git status and directory + OUTPUT+=("$(printf "%-20s %s" "$COLORED_GIT_STATUS" "$DIR")") + fi + done + + # Pass the output to fzf with multi-select enabled (-m) + SELECTED=$(printf "%s\n" "${OUTPUT[@]}" | fzf -m --ansi --layout=reverse) + + # Filter out lines that do not end with a valid directory path and are not empty + echo "$SELECTED" | awk '{if (NF > 1 && system("[ -d \""$NF"\" ]") == 0) print $NF}' +EOF + ) + [[ -z "${SELECTED_DIRS// }" ]] && return + if [[ "$(echo "$SELECTED_DIRS" | wc -l)" -eq 1 ]]; then + cd "$SELECTED_DIRS" + if [[ -n "$(git -C "$SELECTED_DIRS" status --porcelain)" ]]; then + git status --porcelain 2>/dev/null + fi + else + opensessions "$SELECTED_DIRS" + fi +} + + +########################################################################################### +########################################################################################### +### --- HELP --- ### +# help opt colored by bat +alias bathelp='bat --plain --language=help' +function help() { "$@" --help 2>&1 | bathelp; } + + +########################################################################################### +########################################################################################### +### --- KEYS --- ### +# list setxkbmap options +alias xkey=xset_options +function xset_options() { grep --color -E "$1" /usr/share/X11/xkb/rules/base.lst; } + +# print raw xev key events +alias keys=xev_raw_key_event +function xev_raw_key_event() { + xev -event keyboard | awk ' + /^KeyPress/,/^KeyRelease/ { + if ($0 ~ /keysym/) print $0 + }' +} + +# print aligned xev key events +alias key=xev_aligned_key_event +function xev_aligned_key_event() { + xev -event keyboard | awk ' + /^(KeyPress|KeyRelease)/ { + event_type = $1 + } + /keysym/ { + gsub(/\),$/, "", $7) + printf "%-12s %-3s %s\n", event_type, $4, $7 + }' +} + + +########################################################################################### +########################################################################################### +### --- KILL --- ### +# kill process +alias fpkill=fzf_kill_process +function fzf_kill_process() { + ps aux | grep -e "^$(whoami)" | + fzf --height 40% \ + --layout=reverse \ + --header-lines=1 \ + --prompt="Select process to kill: " \ + --preview 'echo {}' \ + --preview-window up:3:hidden:wrap \ + --bind 'F2:toggle-preview' | + awk '{print $2}' | + xargs -r bash -c ' + if ! kill -9 "$1" 2>/dev/null; then + echo "Regular kill failed. Attempting with sudo..." + sudo kill -9 "$1" || echo "Failed to kill process $1" >&2 + fi + ' -- +} + + +########################################################################################### +########################################################################################### +### --- LF --- ### +# open lf and cd to the file path +function lfcd () { + tmp="$(mktemp -uq)" + trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} + +########################################################################################### +########################################################################################### +### --- MAN --- ### +# color man page +function van() { + if [[ -z "$@" ]]; then + if command -v fzf >/dev/null 2>&1; then + local page=$(command man -k . | fzf --prompt='Man> ' --exit-0 | awk '{print $1}') + if [[ -n $page ]]; then + nvim +"Man $page | only" + fi + fi + else + nvim +"Man $@ | only" + fi +} +function ban() { + BAT_THEME="ansi" command batman "$@" + return $? +} + + +########################################################################################### +########################################################################################### +### --- NVIM --- ### +# rename nvim directory +alias ctn=rename_nvim_dir +function rename_nvim_dir() { + if [ $# -ne 2 ]; then + echo "Usage: ctn <old_suffix> <new_suffix>" + return 1 + fi + + local old_suffix="$1" + local new_suffix="$2" + local base_name="nvim" + + # Handle the case where the old suffix is '.' + [ "$old_suffix" = "." ] && old_suffix="" + [ "$new_suffix" = "." ] && new_suffix="" + + # Directories to be renamed + local directories=( + "$HOME/.config/$base_name" + "$HOME/.local/share/$base_name" + "$HOME/.local/state/$base_name" + "$HOME/.cache/$base_name" + ) + + for dir in "${directories[@]}"; do + if [ -d "$dir$old_suffix" ]; then + mv "$dir$old_suffix" "$dir$new_suffix" + echo "Renamed $dir$old_suffix to $dir$new_suffix" + else + echo "Directory $dir$old_suffix does not exist" + fi + done +} + +# change nvim config +alias cnf=change_nvim_config_dir +function change_nvim_config_dir() { + local base_dir="${XDG_DOTFILES_DIR:-$HOME/.dotfiles}/$(whereami)/.config" # Base directory for Neovim configs + local target_dir="${XDG_CONFIG_HOME:-$HOME/.config}/nvim" # Target directory for active Neovim config + local target_share="${XDG_DATA_HOME:-$HOME/.local/share}/nvim" # Neovim"s share directory + local target_state="${XDG_STATE_HOME:-$HOME/.local/state}/nvim" # Neovim"s state directory + local target_cache="${XDG_CACHE_HOME:-$HOME/.cache}/nvim" # Neovim"s cache directory + + # Explicitly list your configuration options + local configs=("Default" "TheSiahxyz" "AstroNvim" "LazyVim" "LunarVim" "NvChad") + local selected_dir=$(printf "%s\n" "${configs[@]}" | fzf --cycle --prompt=" Neovim Config " --height 50% --layout=reverse --border --exit-0) + + # Check if a configuration was selected + [[ -z $selected_dir ]] && return 1 + + # Default configuration + if [[ $selected_dir == "Default" ]]; then + selected_dir="kickstart" + echo "Clearing the Neovim configuration directory..." + rm -rf "$target_dir" "$target_share" "$target_state" "$target_cache" &>/dev/null + echo "Switched to the base Neovim configuration." + return 0 + fi + + # Construct the full path of the selected configuration + local config_path="$base_dir/$selected_dir" + echo "$config_path" + + # Clear existing configurations if confirmed by the user + echo -n "This will overwrite existing configurations. Continue? (y/n) " + read reply + if [[ $reply =~ ^[Yy]$ ]]; then + echo "Clearing existing Neovim configurations..." + rm -rf "$target_dir" "$target_share" "$target_state" "$target_cache" &>/dev/null + mkdir -p "$target_dir" "$target_share" "$target_state" "$target_cache" &>/dev/null + else + echo "Operation cancelled." + return 2 + fi + + # Copy the selected configuration to the target directories + if [[ -d "$config_path" ]]; then + cp -r "$config_path/." "$target_dir" > /dev/null 2>&1 + echo "Successfully applied $selected_dir configuration." + shortcuts >/dev/null + else + echo "Configuration directory for $selected_dir does not exist." + return 3 + fi + + if [ "$whereami" = "ar" ]; then + chown -R "$USER:wheel" "/home/$USER/.config/nvim" + fi +} + +# run nvim with target config +alias vnf=nvim_target_config +function nvim_target_config() { + items=("Default" "TheSiahxyz" "AstroNvim" "LazyVim" "LunarVim" "NvChad") + config=$(printf "%s\n" "${items[@]}" | fzf --cycle --prompt=" Neovim Config " --height=~50% --layout=reverse --border --exit-0) + [[ -z $config ]] && return 0 + [[ $config == "Default" ]] && config="kickstart" + NVIM_APPNAME=$config nvim $@ +} + + +########################################################################################### +########################################################################################### +### --- PASS --- ### +# otp +function pass_otp() { pass otp uri -q $1; } + +# otp insert +function pass_otp_insert() { pass otp insert $1; } + +# copy pass qr code +alias cpqr=pass_qr +function pass_qr() { qrencode -o "$1".png -t png -Sv 40 < "$1".pgp; } + + +########################################################################################### +########################################################################################### +### --- PASTE --- ### +if ls "${ZPLUGINDIR:-${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/zsh}/zsh-autosuggestions" >/dev/null 2>&1; then + autoload -Uz url-quote-magic + function pasteinit() { + OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} + zle -N self-insert url-quote-magic + } + function pastefinish() { + zle -N self-insert $OLD_SELF_INSERT + } + zstyle :bracketed-paste-magic paste-init pasteinit + zstyle :bracketed-paste-magic paste-finish pastefinish +fi + + +########################################################################################### +########################################################################################### +### --- SDCV --- ### +function def() { + sdcv -n --utf8-output --color "$@" 2>&1 | \ + fold --width=$(tput cols) | \ + less --quit-if-one-screen -RX +} + + +########################################################################################### +########################################################################################### +### --- STOW --- ### +# run stow script from dotfiles repo +alias dstw=dotfeils_stw +function dotfiles_stw() { "${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/$(whereami)/.local/bin/stw"; } + + +########################################################################################### +########################################################################################### +### --- SUDO --- ### +# insert prefix at the beginning of the previous command +function __command_replace_buffer() { + local old=$1 new=$2 space=${2:+ } + if [[ $CURSOR -le ${#old} ]]; then + BUFFER="${new}${space}${BUFFER#$old }" + CURSOR=${#new} + else + LBUFFER="${new}${space}${LBUFFER#$old }" + fi +} + +# manipulate the previous command line +function pre_cmd() { + local prepend_command=$1 + local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}} + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" + local WHITESPACE="" + + # Remove leading whitespace and store it for later restoration + if [[ ${LBUFFER:0:1} = " " ]]; then + WHITESPACE=" " + LBUFFER="${LBUFFER:1}" + fi + + # Main logic block + { + local cmd="${${(Az)BUFFER}[1]}" + local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}" + local editorcmd="${${(Az)EDITOR}[1]}" + # Check if EDITOR is set, otherwise prepend the command and return + if [[ -z "$EDITOR" ]]; then + LBUFFER="$prepend_command $LBUFFER" + return + fi + # Check if the command is an editor command + is_editor_cmd=false + # Check if realcmd matches EDITOR, editorcmd, or their case variations + [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) || "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] && is_editor_cmd=true + # Check if the real command's executable path matches the editor command + builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd" && is_editor_cmd=true + # Execute the command replacement if it's an editor command + if $is_editor_cmd; then + __command_replace_buffer "$cmd" "$prepend_command -e" + return + fi + # Handle various command patterns in BUFFER + case "$BUFFER" in + $editorcmd\ *) __command_replace_buffer "$editorcmd" "$prepend_command -e" ;; + \$EDITOR\ *) __command_replace_buffer '$EDITOR' "$prepend_command -e" ;; + ${prepend_command}\ -e\ *) __command_replace_buffer "${prepend_command} -e" "$EDITOR" ;; + ${prepend_command}\ *) __command_replace_buffer "${prepend_command}" "" ;; + *) LBUFFER="$prepend_command $LBUFFER" ;; + esac + } always { + # Cleanup code: restore leading whitespace and update the command line + LBUFFER="${WHITESPACE}${LBUFFER}" + zle && zle redisplay # Only run redisplay if zle is enabled + } +} + + +########################################################################################### +########################################################################################### +### --- TMUX --- ### +# tmux init +alias tit=tmux_init +function tmux_init() { + ! tmux has-session -t "$TERMINAL" 2>/dev/null && tmux new-session -d -s "$TERMINAL" -c "$HOME" + [[ -n "$TMUX" ]] && tmux switch-client -t "$TERMINAL" || tmux attach-session -t "$TERMINAL" +} + +# cd tmux session +alias cds=cd_session_path +function cd_session_path() { cd "$(tmux display-message -p '#{session_path}')"; } + +# kill tmux session +alias tmk='kill_tmux_sessions' +function kill_tmux_sessions() { + local sessions + sessions="$(tmux ls | fzf --cycle --exit-0 --multi)" || return $? + local i + for i in "${(f@)sessions}" + do + [[ $i =~ '([^:]*):.*' ]] && { + echo "Killing $match[1]" + tmux kill-session -t "$match[1]" + } + done +} + +# switch tmux session +alias tms='switch_tmux_session' +function switch_tmux_session() { + local session + session=$(tmux list-sessions -F "#{session_name}" \ + | fzf --cycle --query="$1" --select-1 --exit-0) && + tmux switch-client -t "$session" +} + + +########################################################################################### +########################################################################################### +### --- VIRTUAL ENV --- ### +# create venvs +alias createv=create_venv +function create_venv() { + local env_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/venvs/${1:-venv}" + local requirements_path="${XDG_DATA_HOME:-${HOME}/.local/share}/venvs" + + # Check if the environment already exists + # Create the virtual environment + echo "Creating new virtual environment in '$env_dir'..." + python3 -m venv $env_dir + + # Activate the virtual environment + source $env_dir/bin/activate + + # Optional: Install any default packages + pip3 install --upgrade pip >/dev/null 2>&1 + + if [ -f "$requirements_path/default-requirements.txt" ]; then + echo "Installing packages from '$requirements_path/default-requirements.txt'..." + pip3 install -r "$requirements_path/default-requirements.txt" >/dev/null 2>&1 + fi + + if [ -f "$requirements_path/captured-requirements.txt" ]; then + echo "Installing packages from '$requirements_path/captured-requirements.txt'..." + pip3 install -r "$requirements_path/captured-requirements.txt" >/dev/null 2>&1 + fi + + echo "Virtual environment '${1:-venv}' created and activated!" +} + +# activate or switch venvs +alias actv=active_venv +function active_venv() { + local venv="$1" + if [[ -z "$venv" ]]; then + venv=$(find "$XDG_DATA_HOME/venvs" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | fzf) + fi + source "$XDG_DATA_HOME/venvs/$venv/bin/activate" + python -m ensurepip --upgrade >/dev/null 2>&1 + python -m pip install --upgrade pip >/dev/null 2>&1 + jupyter kernel --kernel=$venv +} + +# list venvs +alias listv=list_venv +function list_venv() { + local venvs_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/venvs" + local venvs=("$venvs_dir"/*) + + if [ ${#venvs[@]} -eq 0 ]; then + echo "No venvs" + return 0 + fi + + echo "venvs list:" + for venv in "${venvs[@]}"; do + if [ -d "$venv" ]; then + echo " $(basename "$venv")" + fi + done +} + +# deactivate venv +alias deactv=deactive_venv +function deactive_venv() { + if [[ "$VIRTUAL_ENV" != "" ]]; then + if [[ ! -f "${XDG_DATA_HOME:-${HOME}/.local/share}/venvs/requirements.txt" ]]; then + pip3 freeze > "${XDG_DATA_HOME:-${HOME}/.local/share}/venvs/captured-requirements.txt" + fi + deactivate + echo "Virtual environment deactivated and all installed packages captured" + else + echo "No virtual environment is active." + fi +} + +# delete venv +alias delv=delete_venv +function delete_venv() { + local venv="$1" + local env_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/venvs" + + if [[ -z $venv ]]; then + local options=($(find "$env_dir" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)) + options+=("Delete All") + + # Prompt user to select virtual environments or choose to delete all + local selected_envs=$(printf "%s\n" "${options[@]}" | fzf --cycle --prompt="venvs " --height=~50% --layout=reverse --border --multi --exit-0) + + if [[ -z $selected_envs ]]; then + echo "No venvs selected" + return 0 + elif [[ $selected_envs == *"Delete All"* ]]; then + rm -rf "$env_dir"/* + echo "All venvs deleted" + else + # Loop through selected environments and delete each + local env + while IFS= read -r env; do + rm -rf "$env_dir/$env" + echo "$env deleted" + done <<< "$selected_envs" + fi + else + rm -rf "$env_dir/$venv" + echo "$venv deleted" + fi +} + + +########################################################################################### +########################################################################################### +### --- YAZI --- ### +# open yazi and cd to the file path +function yazicd() { + local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd + yazi "$@" --cwd-file="$tmp" + IFS= read -r -d '' cwd < "$tmp" + [ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd" + rm -f -- "$tmp" +} diff --git a/fedora/.local/bin/bat b/fedora/.local/bin/bat Binary files differnew file mode 100755 index 0000000..f9846c7 --- /dev/null +++ b/fedora/.local/bin/bat diff --git a/fedora/.local/bin/shortcuts b/fedora/.local/bin/bmshortcuts index ab5e69d..af4ad58 100755 --- a/fedora/.local/bin/shortcuts +++ b/fedora/.local/bin/bmshortcuts @@ -10,9 +10,15 @@ zsh_named_dirs="${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" command -v lf && lf_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/lf/shortcutrc" || lf_shortcuts="/dev/null" command -v vim && vim_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/vim/shortcuts.vim" || vim_shortcuts="/dev/null" command -v nvim && nvim_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/shortcuts.lua" || nvim_shortcuts="/dev/null" -command -v yazi && yazi_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/keymap.toml" || yazi_shortcuts="/dev/null" +if command -v yazi; then + yazi_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/keymap.toml" + yazi_shortcuts_tmp="$yazi_shortcuts.tmp" +else + yazi_shortcuts="/dev/null" + yazi_shortcuts_tmp="/dev/null" +fi command -v ranger && ranger_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/ranger/shortcuts.conf" || ranger_shortcuts="/dev/null" -command -v qutebrowser && qute_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/qutebrowser/shortcuts.py" || qute_shortcuts="/dev/null" +command -v qutebrowser && qute_shortcuts="$HOME/.qutebrowser/shortcuts.py" || qute_shortcuts="/dev/null" command -v fish && fish_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/fish/shortcuts.fish" || fish_shortcuts="/dev/null" command -v vifm && vifm_shortcuts="${XDG_CONFIG_HOME:-${HOME}/.config}/vifm/shortcuts.rc" || vifm_shortcuts="/dev/null" @@ -22,7 +28,7 @@ printf "# vim: filetype=sh\\n" >"$fish_shortcuts" printf "# vim: filetype=sh\\nalias " >"$shell_shortcuts" printf "# vim: filetype=sh\\n" >"$shell_env_shortcuts" printf "\" vim: filetype=vim\\n" >"$vifm_shortcuts" -cp "$HOME/.config/yazi/keymap-default.toml" "$yazi_shortcuts" +[ -f "$HOME/.config/yazi/keymap-default.toml" ] && cp "$HOME/.config/yazi/keymap-default.toml" "$yazi_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. eval "echo \"$(cat "$bmdirs")\"" | @@ -43,7 +49,7 @@ eval "echo \"$(cat "$bmdirs")\"" | printf(\"vim.keymap.set('n', '<localleader><localleader>%s', function() require('mini.files').open('%s') end, { noremap = true, silent = true, desc = '%s' })\n\", \$1, \$2, desc_path) >> \"$nvim_shortcuts\" ; desc_path = \$2; gsub(\"^/home/$USER/\",\"~/\",desc_path); key_array = \"\"; for(i=1; i<=length(\$1); i++) { if(i==1) key_array = \"\\\"\" substr(\$1,i,1) \"\\\"\"; else key_array = key_array \", \\\"\" substr(\$1,i,1) \"\\\"\" } - printf(\"\\t{ on = [ %s ], run = \\\"cd %s\\\", desc = \\\"Go to %s\\\" },\\n\",key_array,\$2,desc_path) >> \"$yazi_shortcuts.tmp\"}" + printf(\"\\t{ on = [ %s ], run = \\\"cd %s\\\", desc = \\\"Go to %s\\\" },\\n\",key_array,\$2,desc_path) >> \"$yazi_shortcuts_tmp\"}" # Format the `files` file in the correct syntax and sent it to both configs. eval "echo \"$(cat "$bmfiles")\"" | @@ -66,10 +72,10 @@ eval "echo \"$(cat "$bmfiles")\"" | printf(\"vim.keymap.set('n', '<localleader><localleader>%s', '<cmd>e %s<cr>', { noremap = true, silent = true, desc = '%s' })\n\", \$1, \$2, desc_path) >> \"$nvim_shortcuts\" ; desc_path = \$2; gsub(\"^/home/$USER/\",\"~/\",desc_path); key_array = \"\"; for(i=1; i<=length(\$1); i++) { if(i==1) key_array = \"\\\"\" substr(\$1,i,1) \"\\\"\"; else key_array = key_array \", \\\"\" substr(\$1,i,1) \"\\\"\" } - printf(\"\\t{ on = [ %s ], run = [ 'reveal %s', 'open' ], desc = \\\"Open %s\\\" },\\n\", key_array, \$2, desc_path) >> \"$yazi_shortcuts.tmp\" }" + printf(\"\\t{ on = [ %s ], run = [ 'reveal %s', 'open' ], desc = \\\"Open %s\\\" },\\n\", key_array, \$2, desc_path) >> \"$yazi_shortcuts_tmp\" }" # Merge bookmarks into keymap-default.toml -if [ -f "$yazi_shortcuts.tmp" ]; then +if [ -f "$yazi_shortcuts_tmp" ]; then # Find the line with the closing bracket in the [mgr] section line_num=$(grep -n "^]" "$yazi_shortcuts" | head -1 | cut -d: -f1) @@ -77,11 +83,11 @@ if [ -f "$yazi_shortcuts.tmp" ]; then head -n $((line_num - 1)) "$yazi_shortcuts" >"$yazi_shortcuts.new" echo "" >>"$yazi_shortcuts.new" echo " # Custom bookmarks" >>"$yazi_shortcuts.new" - cat "$yazi_shortcuts.tmp" >>"$yazi_shortcuts.new" + cat "$yazi_shortcuts_tmp" >>"$yazi_shortcuts.new" echo "]" >>"$yazi_shortcuts.new" tail -n +$((line_num + 1)) "$yazi_shortcuts" >>"$yazi_shortcuts.new" # Replace the original file mv "$yazi_shortcuts.new" "$yazi_shortcuts" - rm -f "$yazi_shortcuts.tmp" + rm -f "$yazi_shortcuts_tmp" fi diff --git a/fedora/.local/bin/bookmarks b/fedora/.local/bin/bookmarks deleted file mode 100755 index a892a33..0000000 --- a/fedora/.local/bin/bookmarks +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/sh - -usage() { - echo "Open bookmarks, URLs, or browser history in a program." - echo "" - echo "Usage: ${0##*/} [OPTIONS]" - echo "" - echo "Options:" - echo " -h : Show this message" - echo " -b : Open a browser bookmark" - echo " -c : Copy a URL from snippets/urls to the clipboard" - echo " -o : Get a URL from snippets/urls and open it in a new browser window" - echo " -p : Get a URL from snippets/urls and open it in a private browser window" - echo " -s : Open browser history" - echo " -t : Get a URL from snippets/urls and type it using xdotool" - echo " -v : Open a browser bookmark in private browser window" - echo "" - echo "Programs:" - echo " browser : System default browser" - echo " lynx : A text browser for World Wide Web" - echo " w3m : A text WWW browser, similar to lynx" - echo "" - echo "Examples:" - echo " ${0##*/} -b # Opens a browser bookmark in a program" - echo " ${0##*/} -c # Copies a URL from snippets/urls to the clipboard" - echo " ${0##*/} -o # Opens a URL from snippets/urls in a new browser window" - echo " ${0##*/} -p # Opens a URL in a private browser window" - echo " ${0##*/} -s # Opens browser history in a program" - echo " ${0##*/} -v # Opens browser boomark in private browser window" -} - -addurls() { - url=$(echo | dmenu -i -p "Enter a url: ") - [ -z "$url" ] && printf "Error: url must be provided\n\n" && exit 0 - - description=$(echo | dmenu -i -p "Enter a description of the url: ") - [ -z "$description" ] && echo "https://$url" >>~/.local/share/thesiah/snippets - [ -n "$description" ] && echo "$description https://$url" >>~/.local/share/thesiah/snippets -} - -opentool() { - available_tools="" - command -v xdg-open 2>/dev/null | grep -v "alias" -q && available_tools="$available_tools xdg-open" - command -v open 2>/dev/null | grep -v "alias" -q && available_tools="$available_tools open" - command -v lynx 2>/dev/null | grep -v "alias" -q && available_tools="$available_tools lynx" - command -v w3m 2>/dev/null | grep -v "alias" -q && available_tools="$available_tools w3m" - available_tools=$(printf "%s" "$available_tools" | awk '{$1=$1; print}' | tr ' ' '\n') - if [ -z "$available_tools" ]; then - printf "No browser found\n" >&2 - exit 1 - fi - - opentool=$(printf "%s\n" "$available_tools" | dmenu -i -p "Choose an open tool:") - - # Set the selected tool to the variable 'open' - case "$opentool" in - xdg-open) xdg-open "$1" ;; - open) - case "$(uname -s)" in - Darwin) open "$1" ;; - *) xdg-open "$1" ;; - esac - ;; - lynx) setsid -f "$TERMINAL" -e lynx "$1" ;; - w3m) setsid -f "$TERMINAL" -e w3m "$1" ;; - *) echo "Invalid selection" >&2 && exit 1 ;; - esac -} - -openwindow() { - if [ "$1" = "private" ]; then - case "$BROWSER" in - *qutebrowser*) "$BROWSER" --target private-window "$url" ;; - *firefox* | *librewolf*) "$BROWSER" --private-window "$url" ;; - esac - else - case "$BROWSER" in - *qutebrowser*) "$BROWSER" --target window "$url" ;; - *firefox* | *librewolf*) "$BROWSER" --new-window "$url" ;; - esac - fi -} - -openinbrowser() { - # Extract only the default part of the profile name - case $BROWSER in - *firefox*) - profiles_ini_path="$HOME/.mozilla/firefox/profiles.ini" - profile=$(awk '/\[Install/ {found=1} found && /^Default=/ {split($0, arr, "."); print arr[2]; exit}' "$profiles_ini_path") - profile_dir=$(find ~/.mozilla/firefox -type d -name "*.$profile*" | head -n 1) - db_path="$profile_dir/places.sqlite" - ;; - *librewolf*) - profiles_ini_path="$HOME/.librewolf/profiles.ini" - profile=$(awk '/\[Install/ {found=1} found && /^Default=/ {split($0, arr, "."); print arr[2]; exit}' "$profiles_ini_path") - profile_dir=$(find ~/.librewolf -type d -name "*.$profile*" | head -n 1) - db_path="$profile_dir/places.sqlite" - ;; - *qutebrowser*) - profile_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/qutebrowser" - db_path="$profile_dir/history.sqlite" - ;; - *) echo "Default browser path is needed." && exit ;; - esac - - tmp_file="$(mktemp)" - cp -f "$db_path" "$tmp_file" - - type dmenu >/dev/null 2>&1 && - selection="dmenu -i -l 20 -p \"Choose a $1 to open:\"" || - selection="fzf-tmux --reverse --cycle --ansi --delimiter='|' --with-nth=1..-2" - - cols=$((${COLUMNS:-90} / 3)) - case "$1" in - *bookmark*) - case "$BROWSER" in - qutebrowser) bookmarks -o ;; - *firefox* | *librewolf*) - sqlite_query=" - SELECT substr(b.title, 1, $cols) || ' | ' || p.url AS bookmark - FROM moz_bookmarks b - JOIN moz_places p ON b.fk = p.id - WHERE b.type = 1 AND p.url LIKE 'http%' AND b.title NOT NULL - ORDER BY b.title; - " - ;; - *qutebrowser*) geturls && openwindow && exit ;; - esac - ;; - *history*) - case "$BROWSER" in - *qutebrowser*) - sqlite_query=" - SELECT substr(h.title, 1, $cols) || ' | ' || h.url AS bookmark - FROM CompletionHistory h - ORDER BY h.last_atime DESC - LIMIT 100; - " - ;; - *firefox* | *librewolf*) - sqlite_query=" - SELECT substr(p.title, 1, $cols) || ' | ' || p.url - FROM moz_places p - JOIN moz_historyvisits hv ON hv.place_id = p.id - ORDER BY hv.visit_date DESC - LIMIT 100; - " - ;; - esac - ;; - esac - choice=$(sqlite3 "$tmp_file" "$sqlite_query" | eval "$selection" | cut -d'|' -f2 | sed 's|.*\(https://\)|\1|' | xargs) - if [ -n "$choice" ]; then - if echo "$1" | grep -q "private"; then - "$BROWSER" --private-window "$choice" - else - opentool "$choice" - fi - else - exit - fi - rm "$tmp_file" -} - -geturls() { - urls=$(cat ~/.config/qutebrowser/quickmarks ~/.config/qutebrowser/bookmarks/urls ~/.local/share/thesiah/snippets ~/.local/share/thesiah/urls 2>/dev/null) - choice=$(echo "$urls" | grep -v -e '^#' -e '^$' | awk ' - { - if ($1 ~ /^https?:\/\//) { alias = substr($0, index($0, $2)) } # Case 2: URL first - else { alias = substr($0, 1, length($0) - length($NF) - 1) } # Case 1: URL last - print alias - }' | dmenu -i -l 50 -p "Choose an alias $1:") - - [ -z "$choice" ] && exit - url=$(echo "$urls" | grep -v -e '^#' -e '^$' | awk -v choice="$choice" ' - { - if ($1 ~ /^https?:\/\//) { url = $1; alias = substr($0, index($0, $2)) } # Case 2 - else { alias = substr($0, 1, length($0) - length($NF) - 1); url = $NF } # Case 1 - if (alias == choice) print url - }') -} - -copytoclipboard() { - if command -v xclip >/dev/null 2>&1; then - printf "%s" "$url" | xclip -selection clipboard - elif command -v clipcopy >/dev/null 2>&1; then - printf "%s" "$url" | clipcopy - elif command -v xsel >/dev/null 2>&1; then - printf "%s" "$url" | xsel --clipboard --input - else - echo "Clipboard utility not found. Install xclip, clipcopy, or xsel." >&2 - exit 1 - fi - notify-send "'$choice' copied in clipbaord" "$url" -} - -[ $# -eq 0 ] && usage && exit 1 - -while getopts "abchopstv" opt; do - case $opt in - a) addurls ;; - b) openinbrowser "bookmark" ;; - c) geturls "to copy" && copytoclipboard ;; - o) geturls "to open in $BROWSER" && openwindow ;; - p) geturls "to open in private $BROWSER" && openwindow private ;; - s) openinbrowser "history" ;; - t) geturls "to type under cursor" && xdotool type "$url" ;; - v) openinbrowser "private bookmark" ;; - h | *) usage && exit 0 ;; - esac -done diff --git a/fedora/.local/bin/chafa b/fedora/.local/bin/chafa Binary files differnew file mode 100755 index 0000000..89b4c96 --- /dev/null +++ b/fedora/.local/bin/chafa diff --git a/fedora/.local/bin/eza b/fedora/.local/bin/eza Binary files differnew file mode 100755 index 0000000..0d40b22 --- /dev/null +++ b/fedora/.local/bin/eza diff --git a/fedora/.local/bin/fzf b/fedora/.local/bin/fzf Binary files differnew file mode 100755 index 0000000..0e89dac --- /dev/null +++ b/fedora/.local/bin/fzf diff --git a/fedora/.local/bin/fzf-preview.sh b/fedora/.local/bin/fzf-preview.sh new file mode 100755 index 0000000..5f99697 --- /dev/null +++ b/fedora/.local/bin/fzf-preview.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# The purpose of this script is to demonstrate how to preview a file or an +# image in the preview window of fzf. +# +# Dependencies: +# - https://github.com/sharkdp/bat +# - https://github.com/hpjansson/chafa +# - https://iterm2.com/utilities/imgcat + +if [[ $# -ne 1 ]]; then + >&2 echo "usage: $0 FILENAME[:LINENO][:IGNORED]" + exit 1 +fi + +file=${1/#\~\//$HOME/} + +center=0 +if [[ ! -r $file ]]; then + if [[ $file =~ ^(.+):([0-9]+)\ *$ ]] && [[ -r ${BASH_REMATCH[1]} ]]; then + file=${BASH_REMATCH[1]} + center=${BASH_REMATCH[2]} + elif [[ $file =~ ^(.+):([0-9]+):[0-9]+\ *$ ]] && [[ -r ${BASH_REMATCH[1]} ]]; then + file=${BASH_REMATCH[1]} + center=${BASH_REMATCH[2]} + fi +fi + +type=$(file --brief --dereference --mime -- "$file") + +if [[ ! $type =~ image/ ]]; then + if [[ $type =~ =binary ]]; then + file "$1" + exit + fi + + # Sometimes bat is installed as batcat. + if command -v batcat > /dev/null; then + batname="batcat" + elif command -v bat > /dev/null; then + batname="bat" + else + cat "$1" + exit + fi + + ${batname} --style="${BAT_STYLE:-numbers}" --color=always --pager=never --highlight-line="${center:-0}" -- "$file" + exit +fi + +dim=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES} +if [[ $dim == x ]]; then + dim=$(stty size < /dev/tty | awk '{print $2 "x" $1}') +elif ! [[ $KITTY_WINDOW_ID ]] && ((FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stty size < /dev/tty | awk '{print $1}'))); then + # Avoid scrolling issue when the Sixel image touches the bottom of the screen + # * https://github.com/junegunn/fzf/issues/2544 + dim=${FZF_PREVIEW_COLUMNS}x$((FZF_PREVIEW_LINES - 1)) +fi + +# 1. Use icat (from Kitty) if kitten is installed +if [[ $KITTY_WINDOW_ID ]] || [[ $GHOSTTY_RESOURCES_DIR ]] && command -v kitten > /dev/null; then + # 1. 'memory' is the fastest option but if you want the image to be scrollable, + # you have to use 'stream'. + # + # 2. The last line of the output is the ANSI reset code without newline. + # This confuses fzf and makes it render scroll offset indicator. + # So we remove the last line and append the reset code to its previous line. + kitten icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' + +# 2. Use chafa with Sixel output +elif command -v chafa > /dev/null; then + chafa -s "$dim" "$file" + # Add a new line character so that fzf can display multiple images in the preview window + echo + +# 3. If chafa is not found but imgcat is available, use it on iTerm2 +elif command -v imgcat > /dev/null; then + # NOTE: We should use https://iterm2.com/utilities/it2check to check if the + # user is running iTerm2. But for the sake of simplicity, we just assume + # that's the case here. + imgcat -W "${dim%%x*}" -H "${dim##*x}" "$file" + +# 4. Cannot find any suitable method to preview the image +else + file "$file" +fi diff --git a/fedora/.local/bin/fzf-tmux b/fedora/.local/bin/fzf-tmux new file mode 100755 index 0000000..e73a908 --- /dev/null +++ b/fedora/.local/bin/fzf-tmux @@ -0,0 +1,257 @@ +#!/usr/bin/env bash +# fzf-tmux: starts fzf in a tmux pane +# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + +fail() { + >&2 echo "$1" + exit 2 +} + +fzf="$(command which fzf)" || fzf="$(dirname "$0")/fzf" +[[ -x $fzf ]] || fail 'fzf executable not found' + +args=() +opt="" +skip="" +swap="" +close="" +term="" +[[ -n $LINES ]] && lines=$LINES || lines=$(tput lines) || lines=$(tmux display-message -p "#{pane_height}") +[[ -n $COLUMNS ]] && columns=$COLUMNS || columns=$(tput cols) || columns=$(tmux display-message -p "#{pane_width}") + +tmux_version=$(tmux -V | sed 's/[^0-9.]//g') +tmux_32=$(awk '{print ($1 >= 3.2)}' <<< "$tmux_version" 2> /dev/null || bc -l <<< "$tmux_version >= 3.2") + +help() { + >&2 echo 'usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + + LAYOUT OPTIONS: + (default layout: -d 50%) + + Popup window (requires tmux 3.2 or above): + -p [WIDTH[%][,HEIGHT[%]]] (default: 50%) + -w WIDTH[%] + -h HEIGHT[%] + -x COL + -y ROW + + Split pane: + -u [HEIGHT[%]] Split above (up) + -d [HEIGHT[%]] Split below (down) + -l [WIDTH[%]] Split left + -r [WIDTH[%]] Split right +' + exit +} + +while [[ $# -gt 0 ]]; do + arg="$1" + shift + [[ -z $skip ]] && case "$arg" in + -) + term=1 + ;; + --help) + help + ;; + --version) + echo "fzf-tmux (with fzf $("$fzf" --version))" + exit + ;; + -p* | -w* | -h* | -x* | -y* | -d* | -u* | -r* | -l*) + if [[ $arg =~ ^-[pwhxy] ]]; then + [[ $opt =~ "-E" ]] || opt="-E" + elif [[ $arg =~ ^.[lr] ]]; then + opt="-h" + if [[ $arg =~ ^.l ]]; then + opt="$opt -d" + swap="; swap-pane -D ; select-pane -L" + close="; tmux swap-pane -D" + fi + else + opt="" + if [[ $arg =~ ^.u ]]; then + opt="$opt -d" + swap="; swap-pane -D ; select-pane -U" + close="; tmux swap-pane -D" + fi + fi + if [[ ${#arg} -gt 2 ]]; then + size="${arg:2}" + else + if [[ $1 =~ ^[0-9%,]+$ ]] || [[ $1 =~ ^[A-Z]$ ]]; then + size="$1" + shift + else + continue + fi + fi + + if [[ $arg =~ ^-p ]]; then + if [[ -n $size ]]; then + w=${size%%,*} + h=${size##*,} + opt="$opt -w$w -h$h" + fi + elif [[ $arg =~ ^-[whxy] ]]; then + opt="$opt ${arg:0:2}$size" + elif [[ $size =~ %$ ]]; then + size=${size:0:${#size}-1} + if [[ $tmux_32 == 1 ]]; then + if [[ -n $swap ]]; then + opt="$opt -l $((100 - size))%" + else + opt="$opt -l $size%" + fi + else + if [[ -n $swap ]]; then + opt="$opt -p $((100 - size))" + else + opt="$opt -p $size" + fi + fi + else + if [[ -n $swap ]]; then + if [[ $arg =~ ^.l ]]; then + max=$columns + else + max=$lines + fi + size=$((max - size)) + [[ $size -lt 0 ]] && size=0 + opt="$opt -l $size" + else + opt="$opt -l $size" + fi + fi + ;; + --) + # "--" can be used to separate fzf-tmux options from fzf options to + # avoid conflicts + skip=1 + continue + ;; + *) + args+=("$arg") + ;; + esac + [[ -n $skip ]] && args+=("$arg") +done + +if [[ -z $TMUX ]]; then + "$fzf" "${args[@]}" + exit $? +fi + +# * --height option is not allowed +# * CTRL-Z is also disabled +# * fzf-tmux script is not compatible with --tmux option in fzf 0.53.0 or later +args=("${args[@]}" "--no-height" "--bind=ctrl-z:ignore" "--no-tmux") + +# Handle zoomed tmux pane without popup options by moving it to a temp window +if [[ ! $opt =~ "-E" ]] && tmux list-panes -F '#F' | grep -q Z; then + zoomed_without_popup=1 + original_window=$(tmux display-message -p "#{window_id}") + tmp_window=$(tmux new-window -d -P -F "#{window_id}" "bash -c 'while :; do for c in \\| / - '\\;' do sleep 0.2; printf \"\\r\$c fzf-tmux is running\\r\"; done; done'") + tmux swap-pane -t $tmp_window \; select-window -t $tmp_window +fi + +set -e + +# Clean up named pipes on exit +id=$RANDOM +argsf="${TMPDIR:-/tmp}/fzf-args-$id" +fifo1="${TMPDIR:-/tmp}/fzf-fifo1-$id" +fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id" +fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id" +if tmux_win_opts=$(tmux show-options -p remain-on-exit \; show-options -p synchronize-panes 2> /dev/null); then + tmux_win_opts=($(sed '/ off/d; s/synchronize-panes/set-option -p synchronize-panes/; s/remain-on-exit/set-option -p remain-on-exit/; s/$/ \\;/' <<< "$tmux_win_opts")) + tmux_off_opts='; set-option -p synchronize-panes off ; set-option -p remain-on-exit off' +else + tmux_win_opts=($(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed '/ off/d; s/^/set-window-option /; s/$/ \\;/')) + tmux_off_opts='; set-window-option synchronize-panes off ; set-window-option remain-on-exit off' +fi +cleanup() { + \rm -f $argsf $fifo1 $fifo2 $fifo3 + + # Restore tmux window options + if [[ ${#tmux_win_opts[@]} -gt 1 ]]; then + eval "tmux ${tmux_win_opts[*]}" + fi + + # Remove temp window if we were zoomed without popup options + if [[ -n $zoomed_without_popup ]]; then + tmux display-message -p "#{window_id}" > /dev/null + tmux swap-pane -t $original_window \; \ + select-window -t $original_window \; \ + kill-window -t $tmp_window \; \ + resize-pane -Z + fi + + if [[ $# -gt 0 ]]; then + trap - EXIT + exit 130 + fi +} +trap 'cleanup 1' SIGUSR1 +trap 'cleanup' EXIT + +envs="export TERM=$TERM " +if [[ $opt =~ "-E" ]]; then + if [[ $tmux_version == 3.2 ]]; then + FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS" + elif [[ $tmux_32 == 1 ]]; then + FZF_DEFAULT_OPTS="--border $FZF_DEFAULT_OPTS" + opt="-B $opt" + else + echo "fzf-tmux: tmux 3.2 or above is required for popup mode" >&2 + exit 2 + fi +fi +envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")" +envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")" +envs="$envs FZF_DEFAULT_OPTS_FILE=$(printf %q "$FZF_DEFAULT_OPTS_FILE")" +[[ -n $RUNEWIDTH_EASTASIAN ]] && envs="$envs RUNEWIDTH_EASTASIAN=$(printf %q "$RUNEWIDTH_EASTASIAN")" +[[ -n $BAT_THEME ]] && envs="$envs BAT_THEME=$(printf %q "$BAT_THEME")" +echo "$envs;" > "$argsf" + +# Build arguments to fzf +opts=$(printf "%q " "${args[@]}") + +pppid=$$ +echo -n "trap 'kill -SIGUSR1 -$pppid' EXIT SIGINT SIGTERM;" >> $argsf +close="; trap - EXIT SIGINT SIGTERM $close" + +export TMUX=$(cut -d , -f 1,2 <<< "$TMUX") +mkfifo -m o+w $fifo2 +if [[ $opt =~ "-E" ]]; then + cat $fifo2 & + if [[ -n $term ]] || [[ -t 0 ]]; then + cat <<< "\"$fzf\" $opts > $fifo2; out=\$? $close; exit \$out" >> $argsf + else + mkfifo $fifo1 + cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; out=\$? $close; exit \$out" >> $argsf + cat <&0 > $fifo1 & + fi + + tmux popup -d "$PWD" $opt "bash $argsf" > /dev/null 2>&1 + exit $? +fi + +mkfifo -m o+w $fifo3 +if [[ -n $term ]] || [[ -t 0 ]]; then + cat <<< "\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" >> $argsf +else + mkfifo $fifo1 + cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; echo \$? > $fifo3 $close" >> $argsf + cat <&0 > $fifo1 & +fi +tmux \ + split-window -c "$PWD" $opt "bash -c 'exec -a fzf bash $argsf'" $swap \ + $tmux_off_opts \ + > /dev/null 2>&1 || { + "$fzf" "${args[@]}" + exit $? +} +cat $fifo2 +exit "$(cat $fifo3)" diff --git a/fedora/.local/bin/fzffiles b/fedora/.local/bin/fzffiles new file mode 100755 index 0000000..44634a2 --- /dev/null +++ b/fedora/.local/bin/fzffiles @@ -0,0 +1,99 @@ +#!/bin/sh + +# The set -e option instructs sh to immediately exit if any command has a non-zero exit status +set -e + +# Set new line and tab for word splitting +IFS=' +' + +# Get the list of selected files with key bindings for specific paths +files=$(fzf-tmux \ + --header "^a pwd ^b public ^d .dotfiles ^f configs ^g git ^h home ^k desktop ^r scripts ^s suckless ^u staged files ^v private ^/ help" \ + --preview "selection={}; + clean=\$(printf '%s' \"\$selection\" | sed -e 's/^📄 //' -e 's/^✏️ //' -e 's/^✅ //' -e 's/^❌ //' -e 's/^🔀 //' -e 's/^❓ //'); + [ -z \"\$clean\" ] && { echo 'No selection'; exit 0; } + target=\$(readlink -f \"\$clean\" 2>/dev/null || printf '%s' \"\$clean\"); + if [ -z \"\$target\" ]; then + echo 'Could not resolve path'; + exit 0; + fi + if [ -f \"\$target\" ]; then + dir=\$(dirname \"\$target\"); + if git_root=\$(git -C \"\$dir\" rev-parse --show-toplevel 2>/dev/null); then + rel=\${target#\"\$git_root\"/}; + diff_output=\$(git -C \"\$git_root\" diff --color -- \"\$rel\"); + if [ -n \"\$diff_output\" ]; then + printf '%s\n' \"\$diff_output\" + exit 0 + fi + diff_output=\$(git -C \"\$git_root\" diff --color --cached -- \"\$rel\"); + if [ -n \"\$diff_output\" ]; then + printf '%s\n' \"\$diff_output\" + exit 0 + fi + fi + fi + if [ -d \"\$target\" ]; then + exa --color=always --long --all --header --icons --git \"\$target\" + elif [ -f \"\$target\" ]; then + bat --color=always --style=header,grid --line-range=:500 \"\$target\" + else + file -h \"\$target\" + fi" \ + --reverse \ + --query="$1" \ + --multi \ + --exit-0 \ + --prompt " 💡 " \ + --bind "ctrl-a:change-prompt( ⚡ )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . $PWD)" \ + --bind "ctrl-b:change-prompt( 🌎 )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . ${XDG_PUBLICSHARE_DIR:-${HOME}/Public})" \ + --bind "ctrl-d:change-prompt( ⚙️ )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . ${XDG_DOTFILES_DIR:-${HOME}/.dotfiles})" \ + --bind "ctrl-f:change-prompt( 🗂️ )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . ${XDG_CONFIG_HOME:-${HOME}/.config})" \ + --bind "ctrl-g:change-prompt( )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . $HOME/Private/repos $HOME/Public/repos)" \ + --bind "ctrl-h:change-prompt( 🏠 )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . $HOME)" \ + --bind "ctrl-k:change-prompt( 🖥️ )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . ${XDG_DESKTOP_DIR:-${HOME}/Desktop})" \ + --bind "ctrl-r:change-prompt( 👟 )+reload(fd -H -L -t f -E .Trash -E .git -E .cache -E zsh . ${XDG_BIN_HOME:-${HOME}/.local/bin})" \ + --bind "ctrl-s:change-prompt( 🛠 )+reload(find ${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless -maxdepth 2 -type f -not -path '*/.git/*')" \ + --bind "ctrl-u:change-prompt( 📝 )+reload(if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then top=\$(git rev-parse --show-toplevel 2>/dev/null); git -C \"\$top\" status --porcelain | awk -v root=\"\$top\" '{ + staged=substr(\$0,1,1); + unstaged=substr(\$0,2,1); + file=substr(\$0,4); + gsub(/^ +/, \"\", file); + if (file == \"\") next; + if (staged == \"?\" && unstaged == \"?\") icon=\"📄\"; + else if (staged == \"!\" && unstaged == \"!\") icon=\"❌\"; + else if (staged != \" \" && staged != \"?\" && unstaged != \" \" && unstaged != \"?\") icon=\"🔀\"; + else if (staged != \" \" && staged != \"?\") icon=\"✅\"; + else if (unstaged != \" \") icon=\"✏️\"; + else icon=\"❓\"; + print icon \" \" root \"/\" file + }'; else echo 'This is not a git repository.'; fi)" \ + --bind "ctrl-v:change-prompt( 🔒 )+reload(fd -H -L -t f -E .Trash -E .git -E .cache . $HOME/Private)" \ + --bind 'ctrl-/:change-prompt( ❓ )+reload(echo "^a all +^b public +^c configs +^d .dotfiles +^g git +^k desktop +^r scripts +^s suckless +^u staged files +^v private +^/ help")') + +# Check if any files were selected, and exit if not +[ -z "$files" ] && exit 0 + +files=$(printf '%s\n' "$files" | sed -e 's/^📄 //' -e 's/^✏️ //' -e 's/^✅ //' -e 's/^❌ //' -e 's/^🔀 //' -e 's/^❓ //') + +if [ -d "$files" ]; then + absolute_files=$(realpath $files) + if echo "$absolute_files" | while read -r file; do file --mime-type "$file" | grep -q 'video/'; done; then + mpv --quiet --loop $absolute_files + else + openfiles "$absolute_files" + fi +else + openfiles "$files" +fi diff --git a/fedora/.local/bin/fzffns b/fedora/.local/bin/fzffns new file mode 100755 index 0000000..c919723 --- /dev/null +++ b/fedora/.local/bin/fzffns @@ -0,0 +1,74 @@ +#!/bin/sh + +# Print all functions and comments in a readable format +# Set the filename of the script containing the functions +file="${ZDOTDIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/zsh}/scripts.zsh" + +# Initialize an empty variable to hold functions, aliases, and comments +functions="" + +# Parse the file for function names, aliases, and comments +while IFS= read -r line || [ -n "$line" ]; do + case "$line" in + \#*) + if [ "$(printf '%s' "$line" | cut -c 2)" != "#" ] && [ "$(printf '%s' "$line" | cut -c 2)" != "!" ]; then + # Remove the '#' from the comment line + comment=$(printf '%s' "$line" | sed 's/^# //') + + # Read the next line to check for alias or function definition + IFS= read -r next_line || break + + # Check if it's an alias definition + if echo "$next_line" | grep -q '^alias '; then + alias_name=$(echo "$next_line" | sed -n 's/^alias \([a-zA-Z0-9_]*\)=.*$/\1/p') + + # Read another line to get the function definition + IFS= read -r func_line || break + f_name=$(printf '%s' "$func_line" | sed -n 's/^function \([^(]*\)().*$/\1/p') + + if [ -n "$f_name" ]; then + functions="$functions$f_name|$alias_name|$comment\n" + fi + + # Check if it's a function definition + elif echo "$next_line" | grep -q '^function '; then + f_name=$(printf '%s' "$next_line" | sed -n 's/^function \([^(]*\)().*$/\1/p') + if [ -n "$f_name" ]; then + functions="$functions$f_name||$comment\n" + fi + fi + fi + ;; + esac +done <"$file" + +# Sort the functions alphabetically by name +sorted=$(printf '%b' "$functions" | sort) + +# Print out the sorted functions with aliases and comments in a readable format +formatted=$(printf '%b' "$sorted" | while IFS='|' read -r f_name alias_name comment; do + if [ -n "$alias_name" ]; then + printf 'fn: %-30s - %s (alias: %s)\n' "$f_name" "$comment" "$alias_name" + else + printf 'fn: %-30s - %s\n' "$f_name" "$comment" + fi +done) + +# Use fzf to select a function +selected=$(printf '%b' "$formatted" | fzf-tmux --header "Select a function:" --reverse) + +# Check if a function was selected +if [ -n "$selected" ]; then + # Extract the function name + f_name=$(echo "$selected" | cut -d ' ' -f 2 | sed 's/[[:space:]]\+//g') + + # Get the line number of the function definition + line_number=$(grep -n "^function $f_name(" "$file" | cut -d ':' -f 1) + + # Open the function in nvim at the specific line number + if [ -n "$line_number" ]; then + nvim "+$line_number" "$file" + else + echo "Function '$f_name' not found in $file." + fi +fi diff --git a/fedora/.local/bin/fzfpass b/fedora/.local/bin/fzfpass new file mode 100755 index 0000000..5190f8e --- /dev/null +++ b/fedora/.local/bin/fzfpass @@ -0,0 +1,88 @@ +#!/bin/sh + +set -e + +usage() { + echo "Find pass gpg files in Password-Store using fzf." + echo "" + echo "Usage: ${0##*/} [-h|--help]" + echo "" + echo "Options:" + echo " -h, --help : Show this message" + echo "" + echo "Shortcuts:" + echo " return - echo password and copy to clipboard (wayland only)" + echo " ctrl+a - new password (named as per the prompt)" + echo " ctrl+e - edit selected password" + echo " ctrl+g - regenerate selected password" + echo " ctrl+r - rename selected password" + echo " ctrl+x - delete selected password" + echo " tab - tab complete" + echo " esc/ctrl+c - exit" + exit 0 +} + +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + usage +fi + +passdir=${PASSWORD_STORE_DIR:-$HOME/.local/share/.password-store} +cd "$passdir" + +# Unlock the password for this session +pass show "$(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | head -n 1)" >/dev/null + +# Main fzf session +passfile=$( + tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | + fzf-tmux \ + --header="🔑 Password Manager" \ + --reverse \ + --no-mouse \ + --preview="pass {}" \ + --header="🔑 ^a: Generate | ^e: Edit | ^g: Generate (no symbol) | ^r: Rename | ^s: Generate (symbol) | ^x: Delete | tab: Replace" \ + --bind="ctrl-a:execute(if [ -z {q} ]; then read -p \"Can't generate empty password. Press enter to continue...\"; else pass generate -n {q} < /dev/tty > /dev/tty 2>&1 && pass edit {q} < /dev/tty > /dev/tty 2>&1; fi)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty 2>&1)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="ctrl-r:execute(bash -c ' +echo -n \"Enter new name for {}: \" > /dev/tty; +read new_name < /dev/tty; +if [ -n \"\$new_name\" ]; then + pass mv {} \"\$new_name\" || echo \"Rename failed.\" > /dev/tty; +else + echo \"No name entered. Rename aborted.\" > /dev/tty; +fi' < /dev/tty > /dev/tty 2>&1)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="ctrl-g:execute(if [ -z {} ]; then read -p \"Can't generate empty password. Press enter to continue...\"; else pass generate -in {} < /dev/tty > /dev/tty 2>&1 && pass edit {} < /dev/tty > /dev/tty 2>&1; fi)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="ctrl-s:execute(if [ -z {} ]; then read -p \"Can't generate empty password. Press enter to continue...\"; else pass generate -i {} < /dev/tty > /dev/tty 2>&1 && pass edit {} < /dev/tty > /dev/tty 2>&1; fi)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="ctrl-x:execute(pass rm {} < /dev/tty > /dev/tty 2>&1)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g')" \ + --bind="tab:replace-query" +) + +show_passdata=false + +if [ "$1" = "-i" ]; then + show_passdata=true + shift +fi + +if [ "$show_passdata" = true ]; then + passdata="$(pass "$passfile")" + echo "$passdata" +else + password="$(pass show "$passfile" | head -n 1)" + echo "$password" + + if [ -n "$password" ]; then + case "$(uname)" in + Darwin*) + printf "%s" "$password" | pbcopy # Use pbcopy on macOS + ;; + Linux*) + printf "%s" "$password" | xclip -selection clipboard # Use xclip on Linux + ;; + *) + echo "Unsupported operating system" + ;; + esac + sleep 0.1 + fi +fi diff --git a/fedora/.local/bin/imgcat b/fedora/.local/bin/imgcat new file mode 100755 index 0000000..af50702 --- /dev/null +++ b/fedora/.local/bin/imgcat @@ -0,0 +1,274 @@ +#!/usr/bin/env bash + +set -o pipefail + +# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux; +# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It +# only accepts ESC backslash for ST. We use TERM instead of TMUX because TERM +# gets passed through ssh. +function print_osc() { + if [[ $TERM == screen* || $TERM == tmux* ]]; then + printf "\033Ptmux;\033\033]" + else + printf "\033]" + fi +} + +# More of the tmux workaround described above. +function print_st() { + if [[ $TERM == screen* || $TERM == tmux* ]]; then + printf "\a\033\\" + else + printf "\a" + fi +} + +function load_version() { + if [ -z ${IMGCAT_BASE64_VERSION+x} ]; then + IMGCAT_BASE64_VERSION=$(base64 --version 2>&1) + export IMGCAT_BASE64_VERSION + fi +} + +function b64_encode() { + load_version + if [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then + # Disable line wrap + base64 -w0 + else + base64 + fi +} + +function b64_decode() { + load_version + if [[ $IMGCAT_BASE64_VERSION =~ fourmilab ]]; then + BASE64ARG=-d + elif [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then + BASE64ARG=-di + else + BASE64ARG=-D + fi + base64 $BASE64ARG +} + +# print_image filename inline base64contents print_filename width height preserve_aspect_ratio +# filename: Filename to convey to client +# inline: 0 or 1, if set to 1, the file will be displayed inline, otherwise, it will be downloaded +# base64contents: Base64-encoded contents +# print_filename: 0 or 1, if set to 1, print the filename after outputting the image +# width: set output width of the image in character cells, pixels or percent +# height: set output height of the image in character cells, pixels or percent +# preserve_aspect_ratio: 0 or 1, if set to 1, fill the specified width and height as much as possible without stretching the image +# file: Empty string or file type like "application/json" or ".js". +# legacy: 1 to send one giant control sequence, 0 to send many small control sequences. +function print_image() { + # Send metadata to begin transfer. + print_osc + printf "1337;" + if [[ "$9" -eq 1 ]]; then + printf "File" + else + printf "MultipartFile" + fi + printf "=inline=%s" "$2" + printf ";size=%d" $(printf "%s" "$3" | b64_decode | wc -c) + [ -n "$1" ] && printf ";name=%s" "$(printf "%s" "$1" | b64_encode)" + [ -n "$5" ] && printf ";width=%s" "$5" + [ -n "$6" ] && printf ";height=%s" "$6" + [ -n "$7" ] && printf ";preserveAspectRatio=%s" "$7" + [ -n "$8" ] && printf ";type=%s" "$8" + if [[ "$9" -eq 1 ]]; then + printf ":%s" "$3" + print_st + else + print_st + + # Split into 200-byte chunks. This helps it get through tmux. + parts=$(printf "%s" "$3" | fold -w 200) + + # Send each part. + for part in $parts; do + print_osc + printf '1337;FilePart=%s' "$part" + print_st + done + + # Indicate completion + print_osc + printf '1337;FileEnd' + print_st + fi + + printf '\n' + [ "$4" == "1" ] && echo "$1" + has_image_displayed=t +} + +function error() { + errcho "ERROR: $*" +} + +function errcho() { + echo "$@" >&2 +} + +function show_help() { + errcho + errcho "Usage: imgcat [-p] [-n] [-W width] [-H height] [-r] [-s] [-u] [-t file-type] [-f] filename ..." + errcho " cat filename | imgcat [-W width] [-H height] [-r] [-s]" + errcho + errcho "Display images inline in the iTerm2 using Inline Images Protocol" + errcho + errcho "Options:" + errcho + errcho " -h, --help Display help message" + errcho " -p, --print Enable printing of filename or URL after each image" + errcho " -n, --no-print Disable printing of filename or URL after each image" + errcho " -u, --url Interpret following filename arguments as remote URLs" + errcho " -f, --file Interpret following filename arguments as regular Files" + errcho " -t, --type file-type Provides a type hint" + errcho " -r, --preserve-aspect-ratio When scaling image preserve its original aspect ratio" + errcho " -s, --stretch Stretch image to specified width and height (this option is opposite to -r)" + errcho " -W, --width N Set image width to N character cells, pixels or percent (see below)" + errcho " -H, --height N Set image height to N character cells, pixels or percent (see below)" + errcho " -l, --legacy Use legacy protocol that sends the whole image in a single control sequence" + errcho + errcho " If you don't specify width or height an appropriate value will be chosen automatically." + errcho " The width and height are given as word 'auto' or number N followed by a unit:" + errcho " N character cells" + errcho " Npx pixels" + errcho " N% percent of the session's width or height" + errcho " auto the image's inherent size will be used to determine an appropriate dimension" + errcho + errcho " If a type is provided, it is used as a hint to disambiguate." + errcho " The file type can be a mime type like text/markdown, a language name like Java, or a file extension like .c" + errcho " The file type can usually be inferred from the extension or its contents. -t is most useful when" + errcho " a filename is not available, such as whe input comes from a pipe." + errcho + errcho "Examples:" + errcho + errcho " $ imgcat -W 250px -H 250px -s avatar.png" + errcho " $ cat graph.png | imgcat -W 100%" + errcho " $ imgcat -p -W 500px -u http://host.tld/path/to/image.jpg -W 80 -f image.png" + errcho " $ cat url_list.txt | xargs imgcat -p -W 40 -u" + errcho " $ imgcat -t application/json config.json" + errcho +} + +function check_dependency() { + if ! (builtin command -V "$1" >/dev/null 2>&1); then + error "missing dependency: can't find $1" + exit 1 + fi +} + +# verify that value is in the image sizing unit format: N / Npx / N% / auto +function validate_size_unit() { + if [[ ! "$1" =~ ^(:?[0-9]+(:?px|%)?|auto)$ ]]; then + error "Invalid image sizing unit - '$1'" + show_help + exit 1 + fi +} + +## Main + +if [ -t 0 ]; then + has_stdin=f +else + has_stdin=t +fi + +# Show help if no arguments and no stdin. +if [ $has_stdin = f ] && [ $# -eq 0 ]; then + show_help + exit +fi + +check_dependency base64 +check_dependency wc +file_type="" +legacy=0 + +# Look for command line flags. +while [ $# -gt 0 ]; do + case "$1" in + -h | --h | --help) + show_help + exit + ;; + -p | --p | --print) + print_filename=1 + ;; + -n | --n | --no-print) + print_filename=0 + ;; + -W | --W | --width) + validate_size_unit "$2" + width="$2" + shift + ;; + -H | --H | --height) + validate_size_unit "$2" + height="$2" + shift + ;; + -r | --r | --preserve-aspect-ratio) + preserve_aspect_ratio=1 + ;; + -s | --s | --stretch) + preserve_aspect_ratio=0 + ;; + -l | --l | --legacy) + legacy=1 + ;; + -f | --f | --file) + has_stdin=f + is_url=f + ;; + -u | --u | --url) + check_dependency curl + has_stdin=f + is_url=t + ;; + -t | --t | --type) + file_type="$2" + shift + ;; + -*) + error "Unknown option flag: $1" + show_help + exit 1 + ;; + *) + if [ "$is_url" == "t" ]; then + encoded_image=$(curl -fs "$1" | b64_encode) || { + error "Could not retrieve image from URL $1, error_code: $?" + exit 2 + } + elif [ -r "$1" ]; then + encoded_image=$(cat "$1" | b64_encode) + else + error "imgcat: $1: No such file or directory" + exit 2 + fi + has_stdin=f + print_image "$1" 1 "$encoded_image" "$print_filename" "$width" "$height" "$preserve_aspect_ratio" "$file_type" "$legacy" + ;; + esac + shift +done + +# Read and print stdin +if [ $has_stdin = t ]; then + print_image "" 1 "$(cat | b64_encode)" 0 "$width" "$height" "$preserve_aspect_ratio" "$file_type" "$legacy" +fi + +if [ "$has_image_displayed" != "t" ]; then + error "No image provided. Check command line options." + show_help + exit 1 +fi + +exit 0 diff --git a/fedora/.local/bin/lastnvim b/fedora/.local/bin/lastfiles index b1ab6c9..082b004 100755 --- a/fedora/.local/bin/lastnvim +++ b/fedora/.local/bin/lastfiles @@ -2,14 +2,14 @@ # Display help message usage() { - echo "Open the most recent file or the list of old files in fzf edited by nvim." + echo "Open the most recent file or the list of old files in fzf edited by Vim." echo "" echo "Usage: ${0##*/} [OPTION]" echo "" echo "Options:" - echo " : Open the most recent old file in Neovim." + echo " : Open the most recent old file in Vim." echo " -h, --help : Show this help message." - echo " -l, --list : Show all recent files in Neovim using fzf." + echo " -l, --list : Show all recent files in Vim using fzf." echo "" echo "Examples:" echo " ${0##*/} # Open the most recent file." @@ -17,14 +17,20 @@ usage() { exit 0 } +# Fetch oldfiles from Vim +get_oldfiles() { + vim -u NONE -es +'silent oldfiles' +qa 2>/dev/null | + sed 's/^[0-9]\+\s\+//' | + grep -v "^$" +} + # List and handle oldfiles list_oldfiles() { - # Fetch the oldfiles list from Neovim - oldfiles=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) + oldfiles=$(get_oldfiles) # Exit if no oldfiles are found [ -z "$oldfiles" ] && { - echo "No recent files found in Neovim." >&2 + echo "No recent files found in Vim." >&2 exit 1 } @@ -33,18 +39,15 @@ list_oldfiles() { usage ;; -l | --list) - # Filter valid files valid_files=$(echo "$oldfiles" | while IFS= read -r file; do [ -f "$file" ] && printf "%s\n" "$file" done) - # Exit if no valid files exist [ -z "$valid_files" ] && { echo "No valid files found." >&2 exit 1 } - # Use fzf to select files selected_files=$(echo "$valid_files" | fzf-tmux \ --multi \ @@ -52,14 +55,12 @@ list_oldfiles() { --height=70% \ --reverse) - # Exit if no files were selected [ -z "$selected_files" ] && exit 1 - # Open selected files in Neovim - openfiles "$selected_files" + openfiles $selected_files ;; *) - # Open the most recent file + # Open the most recent valid file for file in $oldfiles; do if [ -f "$file" ]; then openfiles "$file" diff --git a/fedora/.local/bin/openfiles b/fedora/.local/bin/openfiles index 5b4f7e2..f35aef1 100755 --- a/fedora/.local/bin/openfiles +++ b/fedora/.local/bin/openfiles @@ -1,7 +1,7 @@ #!/bin/sh -if ! command -v nvim >/dev/null 2>&1; then - echo "Error: 'nvim' is not installed." >&2 +if ! command -v vim >/dev/null 2>&1; then + echo "Error: 'vim' is not installed." >&2 exit 1 fi @@ -20,15 +20,15 @@ count=$# case "$count" in 2) - ${EDITOR:-nvim} -O +'silent! normal g;' "$@" -c 'wincmd t' + ${EDITOR:-vim} -O +'silent! normal g;' "$@" -c 'wincmd t' ;; 3) - ${EDITOR:-nvim} -O "$1" -c 'wincmd j' -c "silent! vsplit $2" -c "silent! split $3" -c 'wincmd t' + ${EDITOR:-vim} -O "$1" -c 'wincmd j' -c "silent! vsplit $2" -c "silent! split $3" -c 'wincmd t' ;; 4) - ${EDITOR:-nvim} -O "$1" -c "silent! vsplit $2" -c "silent! split $3" -c 'wincmd h' -c "silent! split $4" -c 'wincmd t' + ${EDITOR:-vim} -O "$1" -c "silent! vsplit $2" -c "silent! split $3" -c 'wincmd h' -c "silent! split $4" -c 'wincmd t' ;; *) - ${EDITOR:-nvim} "$@" + ${EDITOR:-vim} "$@" ;; esac diff --git a/fedora/.local/bin/restartnvim b/fedora/.local/bin/restartvim index ab040ab..3c63f8b 100755 --- a/fedora/.local/bin/restartnvim +++ b/fedora/.local/bin/restartvim @@ -15,11 +15,11 @@ fi # Get the current tmux pane ID tmux_pane=$(tmux display-message -p '#D') -# Send Escape, :wq, and Enter to Neovim in the tmux pane +# Send Escape, :wq, and Enter to Vim in the tmux pane tmux send-keys -t "$tmux_pane" Escape C-m ':wq' C-m -# Wait to ensure Neovim exits +# Wait to ensure Vim exits sleep 0.5 -# Detach the script from Neovim and wait a bit to ensure Neovim exits -(nohup sh -c "sleep 0.5; tmux send-keys -t \"$tmux_pane\" 'nvim -c \"execute \\\"edit \\\" . v:oldfiles[0] | normal '\''0\"' C-m" >/dev/null 2>&1 &) +# Detach the script from Vim and wait a bit to ensure Vim exits +(nohup sh -c "sleep 0.5; tmux send-keys -t \"$tmux_pane\" 'vim -c \"execute \\\"edit \\\" . v:oldfiles[0] | normal '\''0\"' C-m" >/dev/null 2>&1 &) diff --git a/fedora/.local/bin/rg b/fedora/.local/bin/rg Binary files differnew file mode 100755 index 0000000..477c475 --- /dev/null +++ b/fedora/.local/bin/rg diff --git a/fedora/.local/bin/rga b/fedora/.local/bin/rga Binary files differnew file mode 100755 index 0000000..545efba --- /dev/null +++ b/fedora/.local/bin/rga diff --git a/fedora/.local/bin/rga-fzf b/fedora/.local/bin/rga-fzf Binary files differnew file mode 100755 index 0000000..7b86d75 --- /dev/null +++ b/fedora/.local/bin/rga-fzf diff --git a/fedora/.local/bin/rga-fzf-open b/fedora/.local/bin/rga-fzf-open Binary files differnew file mode 100755 index 0000000..71257cd --- /dev/null +++ b/fedora/.local/bin/rga-fzf-open diff --git a/fedora/.local/bin/rga-preproc b/fedora/.local/bin/rga-preproc Binary files differnew file mode 100755 index 0000000..c1ce02f --- /dev/null +++ b/fedora/.local/bin/rga-preproc diff --git a/fedora/.local/bin/sesh b/fedora/.local/bin/sesh Binary files differnew file mode 100755 index 0000000..0355f00 --- /dev/null +++ b/fedora/.local/bin/sesh diff --git a/fedora/.local/bin/sessionizer b/fedora/.local/bin/sessionizer new file mode 100755 index 0000000..93f32b1 --- /dev/null +++ b/fedora/.local/bin/sessionizer @@ -0,0 +1,36 @@ +#!/bin/sh + +sessionizer() { + path="$( + sesh list -d --icons | fzf-tmux \ + -p 80%,70% --no-sort --cycle --ignore-case --ansi --border=sharp --multi --reverse \ + --border-label "╢ TheSiahxyz ╟" \ + --header "^a all ^e sesh ^f zoxide ^g git ^t tmux ^u staged files ^x tmux kill M-cr open in editor ^/ help" \ + --prompt "💡 " \ + --bind "ctrl-a:change-prompt(💡 )+reload(sesh list -d -H --icons)" \ + --bind "ctrl-e:change-prompt(📑 )+reload(sesh list -d -c -H --icons)" \ + --bind "ctrl-f:change-prompt(🔎 )+reload(sesh list -d -z -H --icons)" \ + --bind "ctrl-g:change-prompt( )+reload(fd -H -d 1 -d -t d -E .Trash -E .git -E .cache . $HOME/Private/repos $HOME/Public/repos | sed 's|$HOME|~|g')" \ + --bind "ctrl-t:change-prompt(🪟 )+reload(sesh list -d -t --icons)" \ + --bind "ctrl-v:execute($EDITOR ${0})+abort" \ + --bind 'ctrl-x:execute(tmux kill-session -t "$(echo {} | cut -d" " -f2-)")+reload(sesh list -d --icons)' \ + --bind "alt-enter:execute($EDITOR {})+abort" \ + --bind 'ctrl-/:change-prompt(❓ )+reload(echo "^a all +^e sesh config +^f zoxide +^g git +^t tmux +^x tmux kill +M-cr open in editor +^/ help")' \ + --preview-window 'right:45%' \ + --preview 'sesh preview {}' + )" 2>/dev/null + + case "$path" in + ^*) sessionizer ;; + *) sesh connect "$path" >/dev/null 2>&1 && exit ;; + esac +} + +sessionizer diff --git a/fedora/.local/bin/tmuxopen b/fedora/.local/bin/tmuxopen index 5362215..87e4f36 100755 --- a/fedora/.local/bin/tmuxopen +++ b/fedora/.local/bin/tmuxopen @@ -16,7 +16,7 @@ wrapper() { echo " Ctrl+d Search directories" echo "" echo "Environment Variables:" - echo " NVIM_SEARCH_REGISTRY Set to the search query, allowing Neovim to highlight matches" + echo " VIM_SEARCH_REGISTRY Set to the search query, allowing Neovim to highlight matches" echo "" echo "Example:" echo " tmuxopen # Run the normal search and open" @@ -79,32 +79,32 @@ wrapper() { --prompt "🔎 " } - set_nvim_search_variable() { + set_vim_search_variable() { raw_output="$1" tmp_content_query="/tmp/search-content-query-$$" if [ -f "$tmp_content_query" ]; then saved_query=$(cat "$tmp_content_query" 2>/dev/null) if [ -n "$saved_query" ]; then - export NVIM_SEARCH_REGISTRY="$saved_query" + export VIM_SEARCH_REGISTRY="$saved_query" return fi fi query=$(echo "$raw_output" | head -n1) - export NVIM_SEARCH_REGISTRY="$query" + export VIM_SEARCH_REGISTRY="$query" } - open_files_in_nvim() { + open_files_in_vim() { pane="$1" shift file_indices="$*" - nvim_cmd="nvim" + vim_cmd="vim" for index in $file_indices; do file=$(echo "$files" | awk -v idx="$index" '{print $idx}') line=$(echo "$lines" | awk -v idx="$index" '{print $idx}') - nvim_cmd="$nvim_cmd +$line $file" + vim_cmd="$vim_cmd +$line $file" done - nvim_cmd="$nvim_cmd -c 'let @/=\"$NVIM_SEARCH_REGISTRY\"'" - tmux send-keys -t "$pane" "$nvim_cmd" C-m + vim_cmd="$vim_cmd -c 'let @/=\"$VIM_SEARCH_REGISTRY\"'" + tmux send-keys -t "$pane" "$vim_cmd" C-m } # Parse command line arguments @@ -123,7 +123,7 @@ wrapper() { done raw_output=$(get_fzf_output) - set_nvim_search_variable "$raw_output" + set_vim_search_variable "$raw_output" # Split the newline-delimited output into an array, skipping the first line (query) selections=$(echo "$raw_output" | sed 1d) @@ -158,42 +158,42 @@ EOF fi if [ "$count" -eq 1 ]; then - open_files_in_nvim "$(tmux display-message -p '#P')" 1 + open_files_in_vim "$(tmux display-message -p '#P')" 1 else window_name="$(date +%s)" tmux new-window -n "$window_name" case "$count" in 2) tmux split-window -t "$window_name" -h -p 50 - open_files_in_nvim "$window_name.1" 1 - open_files_in_nvim "$window_name.2" 2 + open_files_in_vim "$window_name.1" 1 + open_files_in_vim "$window_name.2" 2 tmux select-pane -t "$window_name.1" ;; 3) tmux split-window -t "$window_name" -h -p 50 tmux split-window -t "$window_name.2" -v -p 50 - open_files_in_nvim "$window_name.1" 1 - open_files_in_nvim "$window_name.2" 2 - open_files_in_nvim "$window_name.3" 3 + open_files_in_vim "$window_name.1" 1 + open_files_in_vim "$window_name.2" 2 + open_files_in_vim "$window_name.3" 3 ;; *) tmux split-window -t "$window_name" -h -p 50 tmux split-window -t "$window_name.1" -v -p 50 tmux split-window -t "$window_name.3" -v -p 50 - open_files_in_nvim "$window_name.1" 1 - open_files_in_nvim "$window_name.2" 2 - open_files_in_nvim "$window_name.3" 3 + open_files_in_vim "$window_name.1" 1 + open_files_in_vim "$window_name.2" 2 + open_files_in_vim "$window_name.3" 3 remaining_indices="" for i in $(seq 4 "$count"); do remaining_indices="$remaining_indices $i" done - open_files_in_nvim "$window_name.4" "$remaining_indices" + open_files_in_vim "$window_name.4" "$remaining_indices" ;; esac fi } -for cmd in rg fzf bat tmux nvim; do +for cmd in rg fzf bat tmux vim; do if ! command -v $cmd >/dev/null 2>&1; then echo "Error: $cmd not found" >&2 exit 1 diff --git a/fedora/.local/bin/ya b/fedora/.local/bin/ya Binary files differnew file mode 100755 index 0000000..2701e30 --- /dev/null +++ b/fedora/.local/bin/ya diff --git a/fedora/.local/bin/yazi b/fedora/.local/bin/yazi Binary files differnew file mode 100755 index 0000000..0c01561 --- /dev/null +++ b/fedora/.local/bin/yazi diff --git a/fedora/.local/bin/zoxide b/fedora/.local/bin/zoxide Binary files differnew file mode 100755 index 0000000..e7ba833 --- /dev/null +++ b/fedora/.local/bin/zoxide diff --git a/fedora/Dockerfile b/fedora/Dockerfile index 0a08f75..090a48a 100644 --- a/fedora/Dockerfile +++ b/fedora/Dockerfile @@ -6,7 +6,7 @@ LABEL name="$NAME" \ summary="Fedora toolbox container" \ maintainer="TheSiahxyz" -ENV EDITOR=nvim +ENV EDITOR=vim ENV NODE_VERSION=21.7.1 |
