diff --git a/020_batcat.sh b/020_batcat.sh index 93085c7..740a6b8 100644 --- a/020_batcat.sh +++ b/020_batcat.sh @@ -251,23 +251,23 @@ conf_print_bat_config() { #--map-syntax ".ignore:Git Ignore" EOF } -conf_print_bat_config | tee ${BAT_HOME}/config +conf_print_bat_config | tee "${BAT_HOME}/config" conf_print_bat_aliases() { - cat </dev/null; then + cat <<'EOF' +if [ -x "$(command -v bat)" ]; then alias bat='bat' -else + export MANPAGER="sh -c 'col -bx | bat -l man -p'" +elif [ -x "$(command -v batcat)" ]; then alias bat='batcat' + export MANPAGER="sh -c 'col -bx | batcat -l man -p'" fi - -export MANPAGER="sh -c 'col -bx | bat -l man -p'" export MANROFFOPT="-c" EOF } -conf_print_bat_aliases | tee ${DEST}/.zsh_aliases.d/004_batcat.sh +conf_print_bat_aliases | tee "${DEST}/.zsh_aliases.d/004_batcat.zsh" -source ${DEST}/.zsh_aliases.d/004_batcat.sh +source "${DEST}/.zsh_aliases.d/004_batcat.sh" batcat cache --build batcat --list-themes | grep "Catppuccin Mocha" diff --git a/020_kitty-terminal.sh b/020_kitty-terminal.sh index c506d3e..fff9ab1 100644 --- a/020_kitty-terminal.sh +++ b/020_kitty-terminal.sh @@ -3,8 +3,8 @@ set -euo pipefail sudo apt-get update -qqq -sudo apt install -y kitty kitty-terminfo kitty-shell-integration fonts-firacode -q - +sudo apt install -y kitty kitty-terminfo kitty-shell-integration fonts-firacode fonts-noto-color-emoji -q +fc-cache -fv # https://sw.kovidgoyal.net/kitty/overview/ # Paths @@ -18,28 +18,39 @@ mkdir -p "${KITTY_HOME}" "${ALIASES_D}" "${ZSHRC_D}" "${SESSIONS_D}" ALIAS_FILE="${ALIASES_D}/003_kitty.zsh" +# Helper function to run functions with sudo +ssudo() { + [[ "$(type -t "$1")" == "function" ]] || { + echo "Not a function" >&2 + return 1 + } + local func="$1" + shift + sudo bash -c "$(declare -f "$func"); $func $(printf '%q ' "$@")" +} +# # OpenGL detection → decide if we force software rendering # Necessary is opengl is <=3.2 should_use_software() { - local gl_version="" local es_version="" + # local gl_version="" # if command -v glxinfo >/dev/null 2>&1; then # gl_version=$(glxinfo | grep -i "OpenGL version string" | head -n 1 | awk -F: '{print $2}') # if [[ "$gl_version" =~ ^([4-9]\.|3\.[3-9]) ]]; then # return 1 # hardware ok # fi # fi - - local max_core=$(glxinfo -B 2>/dev/null | grep "Max core profile" | awk '{print $5}') - printf "max_core: $max_core\n" + local max_core + max_core=$(glxinfo -B 2>/dev/null | grep "Max core profile" | awk '{print $5}') + printf "max_core: %s\n" "${max_core}" if [[ "$max_core" =~ ^([4-9]\.|3\.[3-9]) ]]; then return 1 # Hardware supports OpenGL 3.2+ fi if command -v eglinfo >/dev/null 2>&1; then es_version=$(eglinfo -B 2>/dev/null | grep -i "OpenGL ES profile version" | head -n 1 | grep -oE '[0-9]+\.[0-9]+' || true) - printf "es_version $es_version\n" + printf "es_version %s\n" "${es_version}" if [[ "$es_version" =~ ^[3-9]\. ]]; then return 1 # GLES 3+ usually good enough fi @@ -63,8 +74,8 @@ EOF } conf_print_kitty_wrapper() { - mkdir -p ~/.local/bin - cat >~/.local/bin/kitty <<'EOF' + mkdir -p /usr/local/bin/ + cat >/usr/local/bin/kitty-wrapper <<'EOF' #!/bin/sh export LIBGL_ALWAYS_SOFTWARE=1 exec /usr/bin/kitty "$@" @@ -76,12 +87,19 @@ if should_use_software; then echo "# Forced software rendering due to insufficient OpenGL support" | tee -a "${ALIAS_FILE}" >/dev/null # For xfce4 that ignores user aliases - conf_print_kitty_wrapper - chmod +x ~/.local/bin/kitty + ssudo conf_print_kitty_wrapper + sudo chmod +x "/usr/local/bin/kitty-wrapper" + + # Add to alternatives and select default + # sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/kitty 100 + sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/local/bin/kitty-wrapper 60 + sudo update-alternatives --config x-terminal-emulator + else conf_print_kitty_alias_hw echo "# Using hardware rendering" | tee -a "${ALIAS_FILE}" >/dev/null + sudo update-alternatives --config x-terminal-emulator fi # the terminfo used by kitty is not generally available on @@ -123,8 +141,8 @@ EOF # for kitty terminal sessions # Environment variables to set and files to copy on connection. # https://sw.kovidgoyal.net/kitty/kittens/ssh/ -mkdir -p ${KITTY_HOME} -cat <<-EOF | tee -a ${KITTY_HOME}/ssh.conf >/dev/null +mkdir -p "${KITTY_HOME}" +cat <<-EOF | tee -a "${KITTY_HOME}/ssh.conf" >/dev/null # Copy the files and directories needed to setup some common tools # copy .zshrc .vimrc .vim @@ -145,8 +163,8 @@ cat <<-EOF | tee -a ${KITTY_HOME}/ssh.conf >/dev/null EOF # set up tmuxp like sessions -mkdir -p ${KITTY_HOME}/sessions -cat <<-EOF | tee ${DEST}/.config/kitty/sessions/startup.conf >/dev/null +mkdir -p "${KITTY_HOME}/sessions" +cat <<-EOF | tee "${DEST}/.config/kitty/sessions/startup.conf" >/dev/null # startup.conf new_tab devuan-sdk cd /space/code_repositories/decode-os/os-build-system @@ -180,7 +198,7 @@ conf_print_kitty_shell() { fi EOF } -conf_print_kitty_shell | tee ${DEST}/.zshrc.d/002_kitty-shell.zsh >/dev/null +conf_print_kitty_shell | tee "${DEST}/.zshrc.d/002_kitty-shell.zsh" >/dev/null # kitty specific zsh function eq load a session file on startup. conf_print_kitty_functions() { @@ -193,10 +211,10 @@ conf_print_kitty_functions() { # } EOF } -conf_print_kitty_functions | tee ${DEST}/.zshrc.d/002_kitty-functions.zsh >/dev/null +conf_print_kitty_functions | tee "${DEST}/.zshrc.d/002_kitty-functions.zsh" >/dev/null ## KITTYCONF START -mkdir -p ${KITTY_HOME} +mkdir -p "${KITTY_HOME}" conf_print_kitty_base() { cat <<-EOF # vim:ft=kitty @@ -245,7 +263,7 @@ conf_print_kitty_base() { # Advanced EOF } -conf_print_kitty_base | tee ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_kitty_base | tee "${KITTY_HOME}/kitty.conf" >/dev/null # Choose this if not using zsh or you don't want manual shell integration # # For manual shell integration above comment out the following @@ -262,7 +280,7 @@ conf_print_no-manual_shell_int() { shell_integration disabled EOF } -conf_print_no-manual_shell_int | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_no-manual_shell_int | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # A bunch of people want auto-update in every 'app' # and the others are unix users. Disable the update check completely. @@ -271,7 +289,7 @@ conf_print_update_interval() { update_check_interval 0 EOF } -conf_print_update_interval | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_update_interval | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # default browser and other settings conf_print_defaults() { @@ -287,7 +305,7 @@ conf_print_defaults() { background_opacity 0.85 EOF } -conf_print_defaults | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_defaults | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null conf_print_shortcuts() { cat <<-EOF @@ -298,7 +316,7 @@ conf_print_shortcuts() { map kitty_mod+t new_tab_with_cwd EOF } -conf_print_shortcuts | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_shortcuts | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # https://lyz-code.github.io/blue-book/kitty/#Movement config_print_movement() { @@ -311,7 +329,7 @@ config_print_movement() { map kitty_mod+d scroll_page_down EOF } -config_print_movement | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +config_print_movement | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # scrollback buffer ctrl+shift+h # https://lyz-code.github.io/blue-book/kitty/#the-scrollback-buffer @@ -347,7 +365,7 @@ listen_on unix:/tmp/kitty-remote EOF } -conf_print_scrollback | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_scrollback | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # Scrollback (2026 style with kitty-scrollback.nvim) conf_print_scrollback_lines() { @@ -358,7 +376,7 @@ scrollback_pager_history_size 4 EOF } -conf_print_scrollback_lines | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_scrollback_lines | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null conf_print_scrollback_maps() { cat <<'EOF' @@ -381,7 +399,7 @@ map kitty_mod+question kitty_scrollback_nvim --config search mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output EOF } -conf_print_scrollback_maps | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_scrollback_maps | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null # Some other mapping examples # conf_print_examples() { @@ -444,16 +462,18 @@ conf_print_theme() { # END_KITTY_THEME EOF } -conf_print_theme | tee -a ${KITTY_HOME}/kitty.conf >/dev/null +conf_print_theme | tee -a "${KITTY_HOME}/kitty.conf" >/dev/null ## KITTYCONF END ## Themes # The theme template for submissions. # if the theme doesn't exist, it will be downloaded # and put in the kitty themes directory -if [ ! -f ${KITTY_HOME}/theme-template.conf ]; then +if [ ! -f "${KITTY_HOME}/theme-template.conf" ]; then echo "Downloading theme template" - wget -c -O ${KITTY_HOME}/theme-template.conf https://raw.githubusercontent.com/kovidgoyal/kitty-themes/master/template.conf + wget -c \ + -O "${KITTY_HOME}/theme-template.conf" \ + https://raw.githubusercontent.com/kovidgoyal/kitty-themes/master/template.conf fi conf_print_nord_theme() { @@ -534,7 +554,7 @@ conf_print_nord_theme() { color15 #eceff4 EOF } -conf_print_nord_theme | tee ${KITTY_HOME}/Nord.conf >/dev/null +conf_print_nord_theme | tee "${KITTY_HOME}/Nord.conf" >/dev/null conf_print_nord_theme_custom() { cat <<-EOF @@ -643,7 +663,7 @@ conf_print_nord_theme_custom() { # map kitty_mod+f4 detach_window ask EOF } -conf_print_nord_theme_custom | tee ${KITTY_HOME}/Nord-custom.conf >/dev/null +conf_print_nord_theme_custom | tee "${KITTY_HOME}/Nord-custom.conf" >/dev/null conf_print_monokai_theme() { cat <<-EOF @@ -672,7 +692,7 @@ conf_print_monokai_theme() { selection_foreground #1e1e1e EOF } -conf_print_monokai_theme | tee ${KITTY_HOME}/Dimmed\ Monokai.conf >/dev/null +conf_print_monokai_theme | tee "${KITTY_HOME}/Dimmed Monokai.conf" >/dev/null conf_print_adwaita_theme() { cat <<-EOF @@ -729,7 +749,7 @@ conf_print_adwaita_theme() { color15 #f6f5f4 EOF } -conf_print_adwaita_theme | tee ${KITTY_HOME}/Adwaita\ dark.conf >/dev/null +conf_print_adwaita_theme | tee "${KITTY_HOME}/Adwaita dark.conf" >/dev/null conf_print_macchiato_theme() { cat <<-EOF @@ -815,7 +835,7 @@ conf_print_macchiato_theme() { color15 #A5ADCB EOF } -conf_print_macchiato_theme | tee ${KITTY_HOME}/Catppuccin-Macchiato.config >/dev/null +conf_print_macchiato_theme | tee "${KITTY_HOME}/Catppuccin-Macchiato.config" >/dev/null conf_print_tokyo_night_theme() { cat <<-EOF @@ -871,7 +891,7 @@ conf_print_tokyo_night_theme() { color17 #c53b53 EOF } -conf_print_tokyo_night_theme | tee ${KITTY_HOME}/Tokyo\ Night\ Moon.conf >/dev/null +conf_print_tokyo_night_theme | tee "${KITTY_HOME}/Tokyo Night Moon.conf" >/dev/null cat <<-EOF diff --git a/020_rustup.sh b/020_rustup.sh index b09cded..121758b 100644 --- a/020_rustup.sh +++ b/020_rustup.sh @@ -9,16 +9,26 @@ CARGO_HOME=${DEST}/.cargo sudo apt install rustup lldb # cargo-debstatus if [[ -d ${RUSTUP_HOME} ]]; then - mv ${RUSTUP_HOME} ${RUSTUP_HOME}-backup + mv "${RUSTUP_HOME}" "${RUSTUP_HOME}-backup" fi if [[ -d ${CARGO_HOME} ]]; then - mv ${CARGO_HOME} ${CARGO_HOME}-backup + mv "${CARGO_HOME}" "${CARGO_HOME}-backup" fi -mkdir -p ${DEST}/.cargo ${DEST}/.rustup +mkdir -p "${DEST}/.cargo" "${DEST}/.rustup" # sudo chown -R $(whoami) ${DEST}/.cargo ${DEST}/.rustup +# Add env to zsh +# https://doc.rust-lang.org/cargo/reference/environment-variables.html +conf_print_cargo_env_zshrc() { + cat < " .. tostring(h.link_to) + else + return "" + end +end, 3300, Status.LEFT) + +-- Show user/group of files in status bar +Status:children_add(function() + local h = cx.active.current.hovered + if not h or ya.target_family() ~= "unix" then + return "" + end + + return ui.Line { + ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"), + ":", + ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"), + " ", + } +end, 500, Status.RIGHT) + +-- Show username and hostname in header +Header:children_add(function() + if ya.target_family() ~= "unix" then + return "" + end + return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue") +end, 500, Header.LEFT) + -- 1. Disable the Header (to hide the top-left date) function Header:render() return ui.Line {} end -- 2. Official-style Custom Linemode (Permissions, Size, Date, Branch) -function Linemode:size_and_mtime() +function Linemode:size_and_mtime_1() local year = os.date("%Y") local time = math.floor(self._file.cha.mtime or 0) local time_str = os.date(os.date("%Y", time) == year and "%b %d %H:%M" or "%b %d %Y", time) local size_str = self._file:size() and ya.readable_size(self._file:size()) or "-" - + -- Convert mode to permissions string (rwxr-xr-x format) local function mode_to_perm(mode) if not mode then return "" end @@ -192,7 +269,7 @@ function Linemode:size_and_mtime() end return perm end - + local perm_str = "" if ya.target_family() == "unix" and self._file.cha.mode then local perms = mode_to_perm(self._file.cha.mode) @@ -208,21 +285,40 @@ function Linemode:size_and_mtime() ui.Span(branch_name or ""):fg("blue"), -- Git Branch } end + +-- Active linemode +function Linemode:size_and_mtime() + local year = os.date("%Y") + local time = math.floor(self._file.cha.mtime or 0) + local time_str = os.date(os.date("%Y", time) == year and "%b %d %H:%M" or "%b %d %Y", time) + local size_str = self._file:size() and ya.readable_size(self._file:size()) or "-" + + return ui.Line { + ui.Span(size_str .. " "), + ui.Span(time_str):fg("gray"), + ui.Span(branch_name or ""):fg("blue"), + } +end + +-- detects that you're using Yazi in nvim, the preview is hidden by default +if os.getenv("NVIM") then + require("toggle-pane"):entry("min-preview") +end + EOF } -conf_print_yazi_init | tee "${YAZI_HOME}"/yazi.toml +conf_print_yazi_init | tee "${YAZI_HOME}"/init.lua conf_print_yazi_toml() { cat <<'EOF' -[manager] -linemode = "size_and_mtime" - [mgr] +ratio = [ 1, 4, 3 ] linemode = "size_and_mtime" show_header = true -sort_dir_first = true -sort_by = "alphabetical" -show_symlink = true +sort_dir_first = false +sort_by = "mtime" +sort_reverse = true +show_symlink = false show_hidden = true [plugin] @@ -231,16 +327,6 @@ prepend_fetchers = [ { id = "git", url = "*/", run = "git" }, ] -[[plugin.prepend_fetchers]] -id = "git" -url = "*" -run = "git" - -[[plugin.prepend_fetchers]] -id = "git" -url = "*/" -run = "git" - # --- Official Piper Previewers --- [[plugin.prepend_previewers]] @@ -257,6 +343,11 @@ run = "kra" mime = "image/tiff" run = "magick" +# GIMP imagae format +[[plugin.prepend_previewers]] +mime = "image/x-xcf" +run = "magick" + [[plugin.prepend_previewers]] url = "*.{tif,tiff,TIF,TIFF}" run = "magick" @@ -265,13 +356,13 @@ run = "magick" url = "*.{docx,xlsx,pptx,odt,ods,odp}" run = "office" -[[plugin.prepend_previewers]] -mime = "{image,audio,video}/*" -run = "mediainfo" - -[[plugin.prepend_previewers]] -mime = "application/x-subrip" -run = "mediainfo" +# [[plugin.prepend_previewers]] +# mime = "{image,audio,video}/*" +# run = "mediainfo" +# +# [[plugin.prepend_previewers]] +# mime = "application/x-subrip" +# run = "mediainfo" [[plugin.prepend_previewers]] mime = "application/{*zip,tar,bzip2,7z*,rar,xz,zstd,java-archive}" @@ -280,6 +371,7 @@ run = "ouch" # -------------------------------- [preview] +previewer = "kitten icat --clear --transfer-mode=memory --scale-up --place=\"$COLUMNS\"x\"$LINES\"@(math $EXTERNAL_COLUMNS-$COLUMNS)x0 --align center --stdin=no {}" max_width = 10000 max_height = 10000 @@ -357,9 +449,23 @@ on = "F" run = "plugin fg -- rg" desc = "find file by fzf content" +[[mgr.prepend_keymap]] +on = ["f", "r"] +run = "plugin fr rg" +desc = "Search file by content (rg)" + +[[mgr.prepend_keymap]] +on = ["f", "a"] +run = "plugin fr rga" +desc = "Search file by content (rga)" + [[mgr.prepend_keymap]] on = "z" run = "plugin zoxide" + +[[mgr.prepend_keymap]] +on = "j" +run = "plugin zoxide" desc = "Jump to a directory using zoxide" [[mgr.prepend_keymap]] @@ -372,6 +478,16 @@ on = "C" run = "plugin ouch" desc = "Compress with ouch" +[[mgr.prepend_keymap]] +on = "T" +run = "plugin toggle-pane min-preview" +desc = "Show or hide the preview pane" + +[[mgr.prepend_keymap]] +on = "T" +run = "plugin toggle-pane max-preview" +desc = "Maximize or restore the preview pane" + [[mgr.prepend_keymap]] on = "" run = 'shell "ripdrag \"$@\"" --confirm' @@ -393,6 +509,12 @@ on = "A" run = "create --dir" desc = "Create a new directory" +[[mgr.prepend_keymap]] +on = "!" +for = "unix" +run = 'shell "$SHELL" --block' +desc = "Open $SHELL here" + # NOTE: Yazi doesn't have "undo" for file operations (copy/move/rename) # These are real filesystem changes. To cancel ongoing operations: # 1. Press 'w' to open task manager @@ -508,3 +630,28 @@ function y() { EOF } conf_print_zsh_shell_wrapper | tee "${DEST}"/.zshrc.d/005_yazi_shell.zsh + +conf_print_yazi_desktop() { + cat <>${HOME}/.bashrc # if [[ -d ${HOME}/.zshrc.d ]]; then -# echo 'export PATH=${HOME}/.local/bin:"$PATH"' >>${HOME}/.zshrc.d/001_dot_local_path.sh +# echo 'export PATH=${HOME}/.local/bin:"$PATH"' >>${HOME}/.zshrc.d/001_dot_local_path.zsh # fi # ensure a conda env exists for zephyr python requirements diff --git a/020_zoxide.sh b/020_zoxide.sh index 152e5fa..a607f14 100644 --- a/020_zoxide.sh +++ b/020_zoxide.sh @@ -16,9 +16,11 @@ sudo apt install -y zoxide # * cd now uses zoxide's fuzzy logic. # * cd .. still goes up one directory. # * cd /tmp still goes to an absolute path. -# * But cd foo will jump to your most frequent foo directory, even if it's deep in your file system. +# * But cd foo will jump to your most frequent foo directory, even if it's +# deep in your file system. # -# Note: If you use this, the z command will still exist, but cd becomes your daily driver. +# Note: If you use this, the z command will still exist, but cd becomes your +# daily driver. # Example: Zsh Lazy Load Script # z() { @@ -27,22 +29,27 @@ sudo apt install -y zoxide # $0 "$@" # } -# ⚠️ Warning: The downside of lazy loading is that zoxide won't record directory changes until after you run z for the first time in that session. If you open a terminal, cd around manually, and then close it without ever running z, those paths won't be saved to the database. +# ⚠️ Warning: The downside of lazy loading is that zoxide won't record directory +# changes until after you run z for the first time in that session. If you open +# a terminal, cd around manually, and then close it without ever running z, those +# paths won't be saved to the database. conf_print_zshrc() { cat <<-'EOF' eval "$(zoxide init zsh --cmd cd)" EOF } -conf_print_zshrc | tee ${DEST}/.zshrc.d/004_zoxide.zsh +conf_print_zshrc | tee "${DEST}/.zshrc.d/004_zoxide.zsh" # z and zi aliaes are part of the eval above. # Alias for interactive selection using fzf # alias zi='__zoxide_zi' conf_print_zsh_alias() { cat <<-'EOF' + alias z='__zoxide_z' + alias zi='__zoxide_zi' alias j='z' alias jj='zi' EOF } -conf_print_zsh_alias | tee ${DEST}/.zsh_aliases.d/004_zoxide.zsh +conf_print_zsh_alias | tee "${DEST}/.zsh_aliases.d/004_zoxide.zsh"