diff --git a/config/shell/.config/starship.toml b/config/shell/.config/starship.toml index 9713dd4..c58405d 100644 --- a/config/shell/.config/starship.toml +++ b/config/shell/.config/starship.toml @@ -1,4 +1,4 @@ -"$schema" = 'https://starship.rs/config-schema.json' +"$schema" = "https://starship.rs/config-schema.json" format = """ $os\ @@ -8,6 +8,7 @@ $directory\ $shell\ $git_branch\ $git_status\ +$direnv\ $c\ $rust\ $golang\ @@ -25,7 +26,7 @@ right_format = """ $status\ $cmd_duration""" -palette = 'catppuccin-mocha' +palette = "catppuccin-mocha" add_newline = false @@ -35,297 +36,306 @@ $character""" [os] disabled = false -style = "fg:accent" +style = "fg:accent" [os.symbols] -Alpaquita = " " -Alpine = " " -AlmaLinux = " " -Amazon = " " -Android = " " -AOSC = " " -Arch = " " -Artix = " " -CachyOS = " " -CentOS = " " -Debian = " " -DragonFly = " " -Elementary = " " -Emscripten = " " -EndeavourOS = " " -Fedora = " " -FreeBSD = " " -Garuda = "󰛓 " -Gentoo = " " -HardenedBSD = "󰞌 " -Illumos = "󰈸 " -Ios = "󰀷 " -Kali = " " -Linux = " " -Mabox = " " -Macos = " " -Manjaro = " " -Mariner = " " -MidnightBSD = " " -Mint = " " -NetBSD = " " -NixOS = " " -Nobara = " " -OpenBSD = "󰈺 " -openSUSE = " " -OracleLinux = "󰌷 " -Pop = " " -Raspbian = " " -Redhat = " " +Alpaquita = " " +Alpine = " " +AlmaLinux = " " +Amazon = " " +Android = " " +AOSC = " " +Arch = " " +Artix = " " +CachyOS = " " +CentOS = " " +Debian = " " +DragonFly = " " +Elementary = " " +Emscripten = " " +EndeavourOS = " " +Fedora = " " +FreeBSD = " " +Garuda = "󰛓 " +Gentoo = " " +HardenedBSD = "󰞌 " +Illumos = "󰈸 " +Ios = "󰀷 " +Kali = " " +Linux = " " +Mabox = " " +Macos = " " +Manjaro = " " +Mariner = " " +MidnightBSD = " " +Mint = " " +NetBSD = " " +NixOS = " " +Nobara = " " +OpenBSD = "󰈺 " +openSUSE = " " +OracleLinux = "󰌷 " +Pop = " " +Raspbian = " " +Redhat = " " RedHatEnterprise = " " -RockyLinux = " " -Redox = "󰀘 " -Solus = "󰠳 " -SUSE = " " -Ubuntu = " " -Unknown = " " -Void = " " -Windows = "󰍲 " -Zorin = " " +RockyLinux = " " +Redox = "󰀘 " +Solus = "󰠳 " +SUSE = " " +Ubuntu = " " +Unknown = " " +Void = " " +Windows = "󰍲 " +Zorin = " " [username] show_always = true -style_user = "fg:accent" -style_root = "fg:red" -format = '[$user]($style)' +style_user = "fg:accent" +style_root = "fg:red" +format = "[$user]($style)" [hostname] ssh_only = false -style = "fg:accent" -format = '[@$hostname]($style)' - +style = "fg:accent" +format = "[@$hostname]($style)" [directory] -style = "fg:teal" -format = "[  $path ]($style)" +style = "fg:teal" +format = "[  $path ]($style)" truncation_length = 3 truncation_symbol = "…/" [directory.substitutions] "Documents" = "󰈙 " "Downloads" = " " -"Music" = "󰝚 " -"Pictures" = " " +"Music" = "󰝚 " +"Pictures" = " " "Developer" = "󰲋 " [shell] -disabled = false -format = '[❯ $indicator ]($style)' -style = "fg:sky" -bash_indicator = "bash" -fish_indicator = "fish" -zsh_indicator = "zsh" +disabled = false +format = "[❯ $indicator ]($style)" +style = "fg:sky" +bash_indicator = "bash" +fish_indicator = "fish" +zsh_indicator = "zsh" powershell_indicator = "pwsh" -pwsh_indicator = "pwsh" +pwsh_indicator = "pwsh" [git_branch] symbol = "" -style = "fg:yellow" -format = '[❯ $symbol $branch ]($style)' +style = "fg:yellow" +format = "[❯ $symbol $branch ]($style)" [git_status] -style = "fg:yellow" -format = '[($all_status$ahead_behind )]($style)' +style = "fg:yellow" +format = "[($all_status$ahead_behind )]($style)" + +[direnv] +disabled = false +symbol = "󰐃" +style = "fg:peach" +format = "[❯ $symbol( $loaded/$allowed) ]($style)" +allowed_msg = "allowed" +not_allowed_msg = "disallowed" +denied_msg = "denied" +loaded_msg = "loaded" +unloaded_msg = "unloaded" [nodejs] symbol = "" -style = "fg:green" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:green" +format = "[❯ $symbol( $version) ]($style)" [c] symbol = "" -style = "fg:blue" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:blue" +format = "[❯ $symbol( $version) ]($style)" [rust] symbol = "" -style = "fg:peach" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:peach" +format = "[❯ $symbol( $version) ]($style)" [golang] symbol = "" -style = "fg:sky" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:sky" +format = "[❯ $symbol( $version) ]($style)" [php] symbol = "" -style = "fg:lavender" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:lavender" +format = "[❯ $symbol( $version) ]($style)" [java] symbol = "" -style = "fg:maroon" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:maroon" +format = "[❯ $symbol( $version) ]($style)" [kotlin] symbol = "" -style = "fg:mauve" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:mauve" +format = "[❯ $symbol( $version) ]($style)" [haskell] symbol = "" -style = "fg:pink" -format = '[❯ $symbol( $version) ]($style)' +style = "fg:pink" +format = "[❯ $symbol( $version) ]($style)" [python] symbol = "" -style = "fg:blue" +style = "fg:blue" format = '[❯ $symbol( $version)(\(#$virtualenv\)) ]($style)' [docker_context] symbol = "" -style = "fg:sapphire" -format = '[❯ $symbol( $context) ]($style)' +style = "fg:sapphire" +format = "[❯ $symbol( $context) ]($style)" [conda] -symbol = "  " -style = "fg:sapphire" -format = '[$symbol$environment ]($style)' +symbol = "  " +style = "fg:sapphire" +format = "[$symbol$environment ]($style)" ignore_base = false [line_break] disabled = false [status] -disabled = false +disabled = false success_style = "fg:accent" failure_style = "fg:red" -format = '[$status ]($style)' - +format = "[$status ]($style)" [character] -disabled = false -success_symbol = '[#](bold fg:accent)' -error_symbol = '[#](bold fg:red)' -vimcmd_symbol = '[❮](bold fg:green)' -vimcmd_replace_one_symbol = '[❮](bold fg:lavender)' -vimcmd_replace_symbol = '[❮](bold fg:lavender)' -vimcmd_visual_symbol = '[❮](bold fg:yellow)' +disabled = false +success_symbol = '[\$](bold fg:accent)' +error_symbol = '[\$](bold fg:red)' +vimcmd_symbol = "[❮](bold fg:green)" +vimcmd_replace_one_symbol = "[❮](bold fg:lavender)" +vimcmd_replace_symbol = "[❮](bold fg:lavender)" +vimcmd_visual_symbol = "[❮](bold fg:yellow)" [cmd_duration] -min_time = 0 +min_time = 0 show_milliseconds = true -format = "[in $duration]($style)" -style = "fg:accent" -disabled = false +format = "[in $duration]($style)" +style = "fg:accent" +disabled = false [palettes.catppuccin-mocha] rosewater = "#f5e0dc" -flamingo = "#f2cdcd" -pink = "#f5c2e7" -mauve = "#cba6f7" -red = "#f38ba8" -maroon = "#eba0ac" -peach = "#fab387" -yellow = "#f9e2af" -green = "#a6e3a1" -teal = "#94e2d5" -sky = "#89dceb" -sapphire = "#74c7ec" -blue = "#89b4fa" -lavender = "#b4befe" -text = "#cdd6f4" -subtext1 = "#bac2de" -subtext0 = "#a6adc8" -overlay2 = "#9399b2" -overlay1 = "#7f849c" -overlay0 = "#6c7086" -surface2 = "#585b70" -surface1 = "#45475a" -surface0 = "#313244" -base = "#1e1e2e" -mantle = "#181825" -crust = "#11111b" -accent = "#89b4fa" +flamingo = "#f2cdcd" +pink = "#f5c2e7" +mauve = "#cba6f7" +red = "#f38ba8" +maroon = "#eba0ac" +peach = "#fab387" +yellow = "#f9e2af" +green = "#a6e3a1" +teal = "#94e2d5" +sky = "#89dceb" +sapphire = "#74c7ec" +blue = "#89b4fa" +lavender = "#b4befe" +text = "#cdd6f4" +subtext1 = "#bac2de" +subtext0 = "#a6adc8" +overlay2 = "#9399b2" +overlay1 = "#7f849c" +overlay0 = "#6c7086" +surface2 = "#585b70" +surface1 = "#45475a" +surface0 = "#313244" +base = "#1e1e2e" +mantle = "#181825" +crust = "#11111b" +accent = "#89b4fa" [palettes.catppuccin-frappe] rosewater = "#f2d5cf" -flamingo = "#eebebe" -pink = "#f4b8e4" -mauve = "#ca9ee6" -red = "#e78284" -maroon = "#ea999c" -peach = "#ef9f76" -yellow = "#e5c890" -green = "#a6d189" -teal = "#81c8be" -sky = "#99d1db" -sapphire = "#85c1dc" -blue = "#8caaee" -lavender = "#babbf1" -text = "#c6d0f5" -subtext1 = "#b5bfe2" -subtext0 = "#a5adce" -overlay2 = "#949cbb" -overlay1 = "#838ba7" -overlay0 = "#737994" -surface2 = "#626880" -surface1 = "#51576d" -surface0 = "#414559" -base = "#303446" -mantle = "#292c3c" -crust = "#232634" -accent = "#8caaee" +flamingo = "#eebebe" +pink = "#f4b8e4" +mauve = "#ca9ee6" +red = "#e78284" +maroon = "#ea999c" +peach = "#ef9f76" +yellow = "#e5c890" +green = "#a6d189" +teal = "#81c8be" +sky = "#99d1db" +sapphire = "#85c1dc" +blue = "#8caaee" +lavender = "#babbf1" +text = "#c6d0f5" +subtext1 = "#b5bfe2" +subtext0 = "#a5adce" +overlay2 = "#949cbb" +overlay1 = "#838ba7" +overlay0 = "#737994" +surface2 = "#626880" +surface1 = "#51576d" +surface0 = "#414559" +base = "#303446" +mantle = "#292c3c" +crust = "#232634" +accent = "#8caaee" [palettes.catppuccin-latte] rosewater = "#dc8a78" -flamingo = "#dd7878" -pink = "#ea76cb" -mauve = "#8839ef" -red = "#d20f39" -maroon = "#e64553" -peach = "#fe640b" -yellow = "#df8e1d" -green = "#40a02b" -teal = "#179299" -sky = "#04a5e5" -sapphire = "#209fb5" -blue = "#1e66f5" -lavender = "#7287fd" -text = "#4c4f69" -subtext1 = "#5c5f77" -subtext0 = "#6c6f85" -overlay2 = "#7c7f93" -overlay1 = "#8c8fa1" -overlay0 = "#9ca0b0" -surface2 = "#acb0be" -surface1 = "#bcc0cc" -surface0 = "#ccd0da" -base = "#eff1f5" -mantle = "#e6e9ef" -crust = "#dce0e8" -accent = "#1e66f5" +flamingo = "#dd7878" +pink = "#ea76cb" +mauve = "#8839ef" +red = "#d20f39" +maroon = "#e64553" +peach = "#fe640b" +yellow = "#df8e1d" +green = "#40a02b" +teal = "#179299" +sky = "#04a5e5" +sapphire = "#209fb5" +blue = "#1e66f5" +lavender = "#7287fd" +text = "#4c4f69" +subtext1 = "#5c5f77" +subtext0 = "#6c6f85" +overlay2 = "#7c7f93" +overlay1 = "#8c8fa1" +overlay0 = "#9ca0b0" +surface2 = "#acb0be" +surface1 = "#bcc0cc" +surface0 = "#ccd0da" +base = "#eff1f5" +mantle = "#e6e9ef" +crust = "#dce0e8" +accent = "#1e66f5" [palettes.catppuccin-macchiato] rosewater = "#f4dbd6" -flamingo = "#f0c6c6" -pink = "#f5bde6" -mauve = "#c6a0f6" -red = "#ed8796" -maroon = "#ee99a0" -peach = "#f5a97f" -yellow = "#eed49f" -green = "#a6da95" -teal = "#8bd5ca" -sky = "#91d7e3" -sapphire = "#7dc4e4" -blue = "#8aadf4" -lavender = "#b7bdf8" -text = "#cad3f5" -subtext1 = "#b8c0e0" -subtext0 = "#a5adcb" -overlay2 = "#939ab7" -overlay1 = "#8087a2" -overlay0 = "#6e738d" -surface2 = "#5b6078" -surface1 = "#494d64" -surface0 = "#363a4f" -base = "#24273a" -mantle = "#1e2030" -crust = "#181926" -accent = "#8aadf4" +flamingo = "#f0c6c6" +pink = "#f5bde6" +mauve = "#c6a0f6" +red = "#ed8796" +maroon = "#ee99a0" +peach = "#f5a97f" +yellow = "#eed49f" +green = "#a6da95" +teal = "#8bd5ca" +sky = "#91d7e3" +sapphire = "#7dc4e4" +blue = "#8aadf4" +lavender = "#b7bdf8" +text = "#cad3f5" +subtext1 = "#b8c0e0" +subtext0 = "#a5adcb" +overlay2 = "#939ab7" +overlay1 = "#8087a2" +overlay0 = "#6e738d" +surface2 = "#5b6078" +surface1 = "#494d64" +surface0 = "#363a4f" +base = "#24273a" +mantle = "#1e2030" +crust = "#181926" +accent = "#8aadf4" diff --git a/config/shell/.config/zsh/conf.d/50-prompt.zsh b/config/shell/.config/zsh/conf.d/50-prompt.zsh index 505d6b5..0143066 100644 --- a/config/shell/.config/zsh/conf.d/50-prompt.zsh +++ b/config/shell/.config/zsh/conf.d/50-prompt.zsh @@ -40,7 +40,7 @@ if (( $+commands[starship] )); then uy_starship_accent "${STARSHIP_CONFIG:-$HOME/.config/starship.toml}" && uy_accent=$REPLY - PROMPT="%F{${uy_accent:-blue}}#%f " zle .reset-prompt + PROMPT="%F{${uy_accent:-blue}}$%f " zle .reset-prompt } autoload -Uz add-zle-hook-widget diff --git a/config/yazi/.config/yazi/package.toml b/config/yazi/.config/yazi/package.toml index b17bf9c..69116ff 100644 --- a/config/yazi/.config/yazi/package.toml +++ b/config/yazi/.config/yazi/package.toml @@ -1,11 +1,11 @@ [[plugin.deps]] use = "yazi-rs/plugins:git" -rev = "9014ed2" -hash = "88e56a64b7ce7c4314427452343fef17" +rev = "b9598e6" +hash = "ce259b12c503a33a18a861052fa582b7" [[plugin.deps]] use = "yazi-rs/plugins:smart-enter" -rev = "9014ed2" +rev = "b9598e6" hash = "187cc58ba7ac3befd49c342129e6f1b6" [[plugin.deps]] diff --git a/config/yazi/.config/yazi/plugins/git.yazi/README.md b/config/yazi/.config/yazi/plugins/git.yazi/README.md index bb923b0..f9fc3ae 100644 --- a/config/yazi/.config/yazi/plugins/git.yazi/README.md +++ b/config/yazi/.config/yazi/plugins/git.yazi/README.md @@ -25,13 +25,11 @@ And register it as fetchers in your `~/.config/yazi/yazi.toml`: ```toml [[plugin.prepend_fetchers]] -id = "git" # Remove if Yazi > v26.1.22 url = "*" run = "git" group = "git" [[plugin.prepend_fetchers]] -id = "git" # Remove if Yazi > v26.1.22 url = "*/" run = "git" group = "git" diff --git a/config/yazi/.config/yazi/plugins/git.yazi/main.lua b/config/yazi/.config/yazi/plugins/git.yazi/main.lua index 19f5c44..865e08d 100644 --- a/config/yazi/.config/yazi/plugins/git.yazi/main.lua +++ b/config/yazi/.config/yazi/plugins/git.yazi/main.lua @@ -28,6 +28,29 @@ local PATTERNS = { { "[AD][AD]", CODES.updated }, } +local function theme() + local t = th.git or {} + return { + [CODES.unknown] = t.unknown or ui.Style(), + [CODES.ignored] = t.ignored or ui.Style():fg("darkgray"), + [CODES.untracked] = t.untracked or ui.Style():fg("magenta"), + [CODES.modified] = t.modified or ui.Style():fg("yellow"), + [CODES.added] = t.added or ui.Style():fg("green"), + [CODES.deleted] = t.deleted or ui.Style():fg("red"), + [CODES.updated] = t.updated or ui.Style():fg("yellow"), + [CODES.clean] = t.clean or ui.Style(), + }, { + [CODES.unknown] = t.unknown_sign or "", + [CODES.ignored] = t.ignored_sign or " ", + [CODES.untracked] = t.untracked_sign or "? ", + [CODES.modified] = t.modified_sign or " ", + [CODES.added] = t.added_sign or " ", + [CODES.deleted] = t.deleted_sign or " ", + [CODES.updated] = t.updated_sign or " ", + [CODES.clean] = t.clean_sign or "", + } +end + ---@param line string ---@return CODES, string local function match(line) @@ -161,27 +184,10 @@ local function setup(st, opts) opts = opts or {} opts.order = opts.order or 1500 - local t = th.git or {} - local styles = { - [CODES.unknown] = t.unknown or ui.Style(), - [CODES.ignored] = t.ignored or ui.Style():fg("darkgray"), - [CODES.untracked] = t.untracked or ui.Style():fg("magenta"), - [CODES.modified] = t.modified or ui.Style():fg("yellow"), - [CODES.added] = t.added or ui.Style():fg("green"), - [CODES.deleted] = t.deleted or ui.Style():fg("red"), - [CODES.updated] = t.updated or ui.Style():fg("yellow"), - [CODES.clean] = t.clean or ui.Style(), - } - local signs = { - [CODES.unknown] = t.unknown_sign or "", - [CODES.ignored] = t.ignored_sign or " ", - [CODES.untracked] = t.untracked_sign or "? ", - [CODES.modified] = t.modified_sign or " ", - [CODES.added] = t.added_sign or " ", - [CODES.deleted] = t.deleted_sign or " ", - [CODES.updated] = t.updated_sign or " ", - [CODES.clean] = t.clean_sign or "", - } + local styles, signs = theme() + ps.sub("theme", function() + styles, signs = theme() + end) Linemode:children_add(function(self) if not self._file.in_current then diff --git a/memo/terminals.md b/memo/terminals.md index d6a6c6d..0dd8195 100644 --- a/memo/terminals.md +++ b/memo/terminals.md @@ -97,17 +97,17 @@ TTY 本质为内核中的双向通信管道与数据处理层. 在如今的日 ### Shell -Shell 是运行在 TTY **Slave** 端的命令行解释器, 负责: +Shell 是运行在 PTY **Slave** 端的命令行解释器, 负责: - 解析用户输入的命令; - 通过 `fork()` 和 `exec()` 等系统调用来启动子进程或执行内置命令; -- 将子进程的输出通过 TTY **Slave** 端发送回终端模拟器的 **Master** 端进行显示; +- 将子进程的输出通过 PTY **Slave** 端发送回终端模拟器的 **Master** 端进行显示; - 管理前台和后台进程组, 处理信号传递等. -值得注意的是, **Canonical Mode** 下 shell 中输入命令后的"回显"并不是 shell 自己完成的, 而必须通过 TTY 的 **Line Discipline**. 当用户输入字符时, Line Discipline 会将其回显到终端模拟器(或 sshd), 以便用户看到自己输入的内容. +值得注意的是, **Canonical Mode** 下 shell 中输入命令后的"回显"并不是 shell 自己完成的, 而必须通过 PTY 的 **Line Discipline**. 当用户输入字符时, Line Discipline 会将其回显到终端模拟器(或 sshd), 以便用户看到自己输入的内容. 但同时, 很多 TUI 程序以及带有自动补全等高级功能的现代 shell 通常会在启动时将终端设置为 **Raw Mode**, 以便能够更灵活地处理用户输入. @@ -273,7 +273,7 @@ support_sixel=0 response="" while true; do - IFS= read -r -N 1 -t "$TIMEOUT" char || { + IFS= read -r -N 1 -t "$TIMEOUT" char < /dev/tty || { [ -z "$char" ] && break } @@ -603,7 +603,7 @@ Unicode Placeholders 是 Kitty 图像协议中处理如何放置图像的方法 绝大多数终端模拟器都提供了类似的选项, 如 Kitty 可以通过设置 `shell fish` 自动启动 fish, 对于 WezTerm 则为 `config.default_prog = { "/usr/bin/fish" }`. - 这是兼容性最好的方法, 因为它完全不会影响原有登录终端的任何配置, 同时也完全不影响日常使用. 唯一的麻烦点在于对于每个终端模拟器(也包括 TTY 与 Kmscon 之类, 如果用到的话)需要单独配置. + 这是兼容性最好的方法, 因为它完全不会影响原有登录终端的任何配置, 同时也完全不影响日常使用. 唯一的麻烦点在于对于每个终端模拟器(也包括 VT 与 Kmscon 之类, 如果用到的话)需要单独配置. - 在 .bashrc 中自动启用 fish @@ -628,7 +628,7 @@ Unicode Placeholders 是 Kitty 图像协议中处理如何放置图像的方法 ## GPU 加速 -虽然听起来高大上, 也是很多终端模拟器写在 Description 里的核心特性之一, 但是在实际使用场景中就我个人经验而言影响并没有想象中那么巨大. 终端模拟器所主要面对的仍然是纯文本场景, 最多换一换颜色, 滚一滚屏幕, 这对于现代 CPU 来说并没有很吃力. 但"更好的渲染性能"甚至不是 GPU 加速的唯一目的, 例如 Ghostty 可以通过 shader 实现各种炫酷的视觉效果, 渲染性能反而是次要的. 因此, 在选择终端模拟器时, 是否支持 GPU 加速可以作为一个参考因素, 但并不应该是唯一的决定因素. +虽然听起来高大上, 也是很多终端模拟器写在 Description 里的核心特性之一, 但是在实际使用场景中就我个人经验而言影响并没有想象中那么巨大. 终端模拟器所主要面对的仍然是纯文本场景, 最多换一换颜色, 滚一滚屏幕, 这对于现代 CPU 来说并没有很吃力. 但"更好的渲染性能"并非 GPU 加速的唯一目的, 例如 Ghostty 可以通过 shader 实现各种炫酷的视觉效果, 渲染性能反而是次要的. 因此, 在选择终端模拟器时, 是否支持 GPU 加速可以作为一个参考因素, 但并不应该是唯一的决定因素. ## 单独聊聊 @@ -643,10 +643,10 @@ Unicode Placeholders 是 Kitty 图像协议中处理如何放置图像的方法 - 自定义 Shader - 简单如光标跳转动画, 复杂如全局光效, 从 CRT 到 Glitchy, 可玩性极高. + 简单如光标跳转动画, 复杂如全局光效, 也有 CRT 和 Glitchy 等经典视效, 可玩性极高. - [0xhckr/ghostty-shaders](https://github.com/0xhckr/ghostty-shaders) 包含很多现成的 shader, 可以直接拿来使用. - - [KroneCorylus/ghostty-shader-playground](https://github.com/KroneCorylus/ghostty-shader-playground) 是一个 shader 预览和编辑器, 同时提供了包括光标跳转动画在内的 shader. + - [KroneCorylus/ghostty-shader-playground](https://github.com/KroneCorylus/ghostty-shader-playground) 是一个 shader 预览和编辑器, 同时提供了包括光标跳转动画在内的常用 shader. - Cons - 不稳定