diff options
46 files changed, 1763 insertions, 2000 deletions
diff --git a/ar/.config/lf/lfrc b/ar/.config/lf/lfrc index 06a13b0..64416d3 100644 --- a/ar/.config/lf/lfrc +++ b/ar/.config/lf/lfrc @@ -432,7 +432,7 @@ cmd zi ${{ cmd follow_link %{{ lf -remote "send ${id} select '$(readlink $f)'" }} -cmd lastnvim ${{ +cmd lastfiles ${{ list=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) file=$(printf "%s" "$list" | while read -r file; do [ -f "$file" ] && printf "%s\n" "$file" @@ -516,7 +516,7 @@ map <delete> delete; clear; save-select map <enter> $$EDITOR "$f" map <c-v> push :!nvim<space> map vlf edit-config -map vll lastnvim +map vll lastfiles map vln $$EDITOR "$(nvim -u NONE --headless +'lua io.write(vim.v.oldfiles[1] .. "\n")' +qa)" # Extract diff --git a/ar/.config/shell/aliasrc b/ar/.config/shell/aliasrc index 119a5b3..55f04e7 100644 --- a/ar/.config/shell/aliasrc +++ b/ar/.config/shell/aliasrc @@ -288,7 +288,7 @@ 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 vll='lastfiles -l' alias vln='$EDITOR -c '\''execute "edit " . v:oldfiles[0] | normal ''0'\' # nxsiv diff --git a/ar/.config/shell/bm-files b/ar/.config/shell/bm-files index 200cedd..fc8bce1 100644 --- a/ar/.config/shell/bm-files +++ b/ar/.config/shell/bm-files @@ -26,10 +26,12 @@ vns ${XDG_CONFIG_HOME:-${HOME}/.config}/newsboat/config vnu ${XDG_CONFIG_HOME:-${HOME}/.config}/newsboat/urls # Newsboat url (RSS reader) vqt ${XDG_CONFIG_HOME:-${HOME}/.config}/qutebrowser/config.py # Qutebrowser config Vsm /etc/samba/smb.conf # Samba config +vsa ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc # Aliases used by shell (and potentially other shells) vse ${XDG_CONFIG_HOME:-${HOME}/.config}/sesh/sesh.toml # Sesh config vsf ${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless/surf/config.def.h # Surf: a simple browser vsl ${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless/slock/config.def.h # Slock: lock screen -vsp ${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/snippets # Snippets +vsn ${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/snippets # Snippets +vsp ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile # Shell profile used for system vss ${XDG_CONFIG_HOME:-${HOME}/.config}/starship/starship.toml # Starship vst ${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless/st/config.def.h # St: a simple terminal vsx ${XDG_CONFIG_HOME:-${HOME}/.config}/nsxiv/exec/key-handler # Nsxiv (image viewer) key/script handler @@ -47,8 +49,6 @@ vxp ${XDG_CONFIG_HOME:-${HOME}/.config}/x11/xprofile vxr ${XDG_CONFIG_HOME:-${HOME}/.config}/x11/xresources # Colors, themes and variables for X11 vyk ${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/keymap-default.toml # Yazi keymap vyz ${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/yazi.toml # Yazi config -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/ar/.config/vim/init.vim b/ar/.config/vim/init.vim index fbb9097..66507d5 100644 --- a/ar/.config/vim/init.vim +++ b/ar/.config/vim/init.vim @@ -439,8 +439,8 @@ let g:which_key_map['w'] = { " 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/ar/.config/vim/vimrc b/ar/.config/vim/vimrc index 0535aec..0a76953 100644 --- a/ar/.config/vim/vimrc +++ b/ar/.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/ar/.config/zsh/keymaps.zsh b/ar/.config/zsh/keymaps.zsh index efd9e04..81b3027 100644 --- a/ar/.config/zsh/keymaps.zsh +++ b/ar/.config/zsh/keymaps.zsh @@ -165,7 +165,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^ulf\n' # bindkey -s '^G' '^uyazi\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -182,7 +182,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z 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' 'lastnvim -l' + 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' @@ -312,7 +312,7 @@ else bindkey -s '^D' '^ucdi\n' bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^ulf\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -326,7 +326,7 @@ else bindkey -s '^X^F' '^ugitfiles\n' bindkey -s '^X^G' '^urgafiles ' bindkey -s '^X^L' '^ugloac\n' - bindkey -s '^X^N' '^ulastnvim -l\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' diff --git a/ar/.local/bin/iwaf b/ar/.local/bin/iwaf index 89b10b2..52d879f 100755 --- a/ar/.local/bin/iwaf +++ b/ar/.local/bin/iwaf @@ -80,7 +80,7 @@ main() { # Configure environment variables export LANG='en_US.UTF-8' export LC_ALL='en_US.UTF-8' - export WINEARCH='win32' + export WINEARCH='win64' export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/soop" # Install diff --git a/ar/.local/bin/lastnvim b/ar/.local/bin/lastfiles index b1ab6c9..b1ab6c9 100755 --- a/ar/.local/bin/lastnvim +++ b/ar/.local/bin/lastfiles diff --git a/ar/.local/bin/qndl b/ar/.local/bin/qndl index 7054541..46b4aa8 100755 --- a/ar/.local/bin/qndl +++ b/ar/.local/bin/qndl @@ -9,9 +9,7 @@ case "$BROWSER" in # *qutebrowser*) cookies="chromium:~/.local/share/qutebrowser" ;; esac -if [ -n "$cookies" ]; then - ytdl_cmd_base="$ytdl_cmd_base --cookies-from-browser \"$cookies\"" -fi +[ -n "$cookies" ] && ytdl_cmd_base="$ytdl_cmd_base --cookies-from-browser \"$cookies\"" shift $((OPTIND - 1)) @@ -106,7 +104,9 @@ case $url in ;; esac -simulation_cmd="$simulation_cmd --cookies-from-browser $cookies $url" +[ -n "$cookies" ] && simulation_cmd="$simulation_cmd --cookies-from-browser $cookies $url" || + simulation_cmd="$simulation_cmd $url" + ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\" \"$url\"" # Notify and perform simulation to get filename (feedback to user) diff --git a/ar/.local/bin/shortcuts b/ar/.local/bin/shortcuts index ab5e69d..af4ad58 100755 --- a/ar/.local/bin/shortcuts +++ b/ar/.local/bin/shortcuts @@ -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/.config/bash/bash_profile b/fedora/.config/bash/bash_profile index 068e3f5..4938bb5 100644 --- a/fedora/.config/bash/bash_profile +++ b/fedora/.config/bash/bash_profile @@ -1,34 +1,107 @@ -#!/bin/sh +#!/bin/bash umask 022 -####################################################### -# EXPORTS -####################################################### +################################################### +### --- 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 ':' -)" +unsetopt PROMPT_SP 2>/dev/null + +################################################### +### --- 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" ####################################################### # Source global/local definitions @@ -38,3 +111,4 @@ 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" +[ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f bmshortcuts >/dev/null 2>&1 diff --git a/fedora/.config/bash/bashrc b/fedora/.config/bash/bashrc index 2c60286..95a1c38 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,11 @@ bind '"\C-g":"lfcd\n"' eval "$(dircolors)" +[ -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/keymaps.bash b/fedora/.config/bash/keymaps.bash index cf355ad..91b3cad 100644 --- a/fedora/.config/bash/keymaps.bash +++ b/fedora/.config/bash/keymaps.bash @@ -11,101 +11,133 @@ 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 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)) } # ---------- 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 +146,15 @@ 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,44 +165,44 @@ 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 # ---------- 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' @@ -187,14 +219,14 @@ 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-_":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-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' diff --git a/fedora/.config/bash/scripts.bash b/fedora/.config/bash/scripts.bash index fa0abbc..76644e3 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,61 @@ 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)" +} + +########################################################################################### +########################################################################################### +### --- DISTRIBUTION --- ### # Show the current distribution distribution() { local dtype @@ -206,34 +228,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 +314,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 +345,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 +383,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 deleted file mode 100644 index 677943a..0000000 --- a/fedora/.config/shell/profile +++ /dev/null @@ -1,151 +0,0 @@ -################################################### -### --- PROFILE --- ### -################################################### -[ "$(tty)" = "/dev/tty1" ] && set -e # Exit immediately if a command exits with a non-zero status. - -################################################### -### --- 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 ':' -)" - -unsetopt PROMPT_SP 2>/dev/null - -################################################### -### --- DEFAULT PROGRAMS --- ### -################################################### -export EDITOR="nvim" -export EDITOR2="vim" -# export FILE_MANAGER="lf $(lf -version)" -export KEYTIMEOUT=10 -export SUDO_EDITOR=$EDITOR -export TERM="xterm-256color" -export VISUAL=$EDITOR - -################################################### -### --- 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" - -################################################### -### --- DEFAULT ENV PATHES FOR ALL PROGRAMS --- ### -################################################### -### --- ANDROID --- ### -export ANDROID_SDK_HOME="$XDG_CONFIG_HOME/android" - -### --- ANSIBLE --- ### -export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible/ansible.cfg" - -### --- BAT --- ### -export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/bat/config" - -### --- CARGO --- ### -export CARGO_HOME="$XDG_DATA_HOME/cargo" - -### --- DICS --- ### -export DICS="/usr/share/stardict/dic/" - -### --- ELECTRUM --- ### -export ELECTRUMDIR="$XDG_DATA_HOME/electrum" - -### --- HISTORY --- ### -export HISTFILE="$XDG_DATA_HOME/history/sh_history" - -### --- INPUTRC --- ### -export INPUTRC="$XDG_CONFIG_HOME/shell/inputrc" - -### --- JAVA --- ### -export AWT_TOOLKIT="MToolkit wmname LG3D" # May have to install wmname -export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm - -### --- 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" -} - -### --- NPM --- ### -export NPM_CONFIG_USERCONFIG="~/.config/npm/.npmrc" - -### --- NVM --- ### -export NVM_DIR="$XDG_CONFIG_HOME/nvm" - -### --- 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 - -### --- POWERLEVEL10K --- ### -export POWERLEVEL9K_INSTALLATION_DIR="/usr/share/zsh-theme-powerlevel10k" - -### --- PYTHON --- ### -export PYTHONPYCACHEPREFIX=$XDG_CACHE_HOME/python -export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc" - -### --- RUST --- ### -export RUSTUP_HOME="$XDG_DATA_HOME/rustup" - -### --- SQLITE --- ### -export SQLITE_HISTORY="$XDG_DATA_HOME/history/sqlite_history" - -### --- 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' - -### --- VIRTUAL ENVIRONMENT --- ### -export WORKON_HOME="$XDG_DATA_HOME/venvs" - -### --- VISUAL STUDIO CODE --- ### -export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" - -### --- WGET --- ### -export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" - -### --- ZSH --- ### -export ZDOTDIR="$XDG_CONFIG_HOME/zsh" -export ZPLUGINDIR="$XDG_SCRIPTS_HOME/zsh" - -### --- 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..d12ce78 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 @@ -35,17 +24,6 @@ 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 = {} - " }}} @@ -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/.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/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/mac/.local/bin/lastnvim b/fedora/.local/bin/lastfiles index b1ab6c9..082b004 100755 --- a/mac/.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/rgafiles b/fedora/.local/bin/rgafiles index e8b5e72..ac4471b 100755 --- a/fedora/.local/bin/rgafiles +++ b/fedora/.local/bin/rgafiles @@ -17,7 +17,7 @@ usage() { echo "Examples:" echo " ${0##*/} -p TODO 'KEYWORD' # Search for 'KEYWORD' in files tagged with 'TODO' in the project directories" echo " ${0##*/} -l -p 'KEYWORD' # List files associated with the default 'PROJECT' tag and 'KEYWORD'" - echo " ${0##*/} 'KEYWORD' # Open files containing 'KEYWORD' in nvim" + echo " ${0##*/} 'KEYWORD' # Open files containing 'KEYWORD' in vim" exit 0 } @@ -86,7 +86,7 @@ list_or_open_project_files() { if [ "$list_mode" -eq 1 ]; then echo "$rga_output" else - # Otherwise, open the files with nvim + # Otherwise, open the files with vim set -- "$(printf "%s\n" "$rga_output")" openfiles "$@" fi 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/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 diff --git a/global/Music/.music.txt b/global/Music/.music.txt index fc75322..a64bfc5 100644 --- a/global/Music/.music.txt +++ b/global/Music/.music.txt @@ -913,3 +913,4 @@ youtube 2ej_A1xctPg youtube edJ1dXbaqak youtube Qe8fa4b5xNU youtube RgKAFK5djSk +youtube 6wmuFMBouyQ diff --git a/mac/.config/lf/lfrc b/mac/.config/lf/lfrc index f7cb423..c9b2d36 100644 --- a/mac/.config/lf/lfrc +++ b/mac/.config/lf/lfrc @@ -432,7 +432,7 @@ cmd zi ${{ cmd follow_link %{{ lf -remote "send ${id} select '$(readlink $f)'" }} -cmd lastnvim ${{ +cmd lastfiles ${{ list=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) file=$(printf "%s" "$list" | while read -r file; do [ -f "$file" ] && printf "%s\n" "$file" @@ -516,7 +516,7 @@ map <delete> delete; clear; save-select map <enter> $$EDITOR "$f" map <c-v> push :!nvim<space> map vlf edit-config -map vll lastnvim +map vll lastfiles map vln $$EDITOR "$(nvim -u NONE --headless +'lua io.write(vim.v.oldfiles[1] .. "\n")' +qa)" # Extract diff --git a/mac/.config/shell/aliasrc b/mac/.config/shell/aliasrc index 2163e68..6dcdf7d 100644 --- a/mac/.config/shell/aliasrc +++ b/mac/.config/shell/aliasrc @@ -292,7 +292,7 @@ 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 vll='lastfiles -l' alias vln='$EDITOR -c '\''execute "edit " . v:oldfiles[0] | normal ''0'\' # nxsiv diff --git a/mac/.config/shell/bm-files b/mac/.config/shell/bm-files index 17aefce..aabc278 100644 --- a/mac/.config/shell/bm-files +++ b/mac/.config/shell/bm-files @@ -25,10 +25,12 @@ vnp ${XDG_CONFIG_HOME:-${HOME}/.config}/ncmpcpp/config vns ${XDG_CONFIG_HOME:-${HOME}/.config}/newsboat/config # Newsboat config (RSS reader) vnu ${XDG_CONFIG_HOME:-${HOME}/.config}/newsboat/urls # Newsboat url (RSS reader) vqt $HOME/.qutebrowser/config.py # Qutebrowser config +vsa ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/aliasrc # Aliases used by shell (and potentially other shells) vse ${XDG_CONFIG_HOME:-${HOME}/.config}/sesh/sesh.toml # Sesh config vsh $HOME/.ssh/config # SSH config vsk ${XDG_CONFIG_HOME:-${HOME}/.config}/sketchybar/sketchybarrc # Sketchybar config -vsp ${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/snippets # Snippets +vsn ${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/snippets # Snippets +vsp ${XDG_CONFIG_HOME:-${HOME}/.config}/shell/profile # Shell profile used for system vss ${XDG_CONFIG_HOME:-${HOME}/.config}/starship/starship.toml # Starship vsx ${XDG_CONFIG_HOME:-${HOME}/.config}/nsxiv/exec/key-handler # Nsxiv (image viewer) key/script handler vtc ${XDG_CONFIG_HOME:-${HOME}/.config}/task/taskrc # Task config @@ -43,8 +45,6 @@ vvw ${XDG_DATA_HOME:-${HOME}/.local/share}/vimwiki/index.md vyc ${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/yazi.toml # Yazi config vyi ${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/init.lua # Yazi init for plugins vyk ${XDG_CONFIG_HOME:-${HOME}/.config}/yazi/keymap-default.toml # Yazi key config -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/mac/.config/vim/vimrc b/mac/.config/vim/vimrc index 0535aec..0a76953 100644 --- a/mac/.config/vim/vimrc +++ b/mac/.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/mac/.config/zsh/keymaps.zsh b/mac/.config/zsh/keymaps.zsh index 6653e44..583b8e4 100644 --- a/mac/.config/zsh/keymaps.zsh +++ b/mac/.config/zsh/keymaps.zsh @@ -164,7 +164,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z bindkey -s '^D' '^ucdi\n' bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^uyazi\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -180,7 +180,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z 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' 'lastnvim -l' + 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' @@ -310,7 +310,7 @@ else bindkey -s '^D' '^ucdi\n' bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^uyazi\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -324,7 +324,7 @@ else bindkey -s '^X^F' '^ugitfiles\n' bindkey -s '^X^G' '^urgafiles ' bindkey -s '^X^L' '^ugloac\n' - bindkey -s '^X^N' '^ulastnvim -l\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' diff --git a/mac/.local/bin/bmshortcuts b/mac/.local/bin/bmshortcuts index 2a8d3fa..af4ad58 100755 --- a/mac/.local/bin/bmshortcuts +++ b/mac/.local/bin/bmshortcuts @@ -10,7 +10,13 @@ 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="$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" @@ -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/lastnvim b/mac/.local/bin/lastfiles index b1ab6c9..b1ab6c9 100755 --- a/fedora/.local/bin/lastnvim +++ b/mac/.local/bin/lastfiles |
