$env.config.buffer_editor = 'nvim' $env.config.show_banner = false # ---- Aliases ---- alias vim = nvim alias vi = nvim alias eml = aerc alias tinypng = tinifier alias lg = lazygit alias rm = trash alias you-get = you-get --cookies ~/.local/share/you-get/www.bilibili.com_cookies.txt alias fjc = fj --host codeberg.org alias fjs = fj --host src.eltr.ac alias plantuml = java -jar ~/.local/jar/plantuml.jar alias hugo-tag = uv run ~/Projects/snippets/hugo-tag-wrangler/script.py alias vimulti = bb ~/Projects/vimulti/vimulti.clj alias nvimj = vimulti java-edition alias switch-proxy = bb ~/Projects/snippets/QoL/switch-proxy.clj alias swp = switch-proxy alias mvn = mvn -gs .config/maven/settings.xml alias wtr = weather alias nuconf = config nu alias nuenv = config env alias ssh = ghostty +ssh # --- Network proxy ---- $env.no_proxy = 'localhost,127.0.0.1' def pon [] { $env.http_proxy = 'http://127.0.0.1:7890' $env.https_proxy = 'http://127.0.0.1:7890' $env.all_proxy = 'socks5://127.0.0.1:7890' } def poff [] { $env.http_proxy = '' $env.https_proxy = '' $env.all_proxy = '' } ## default on pon # ---- Custom commands ---- # Remind to use mosh instead of ssh def ssh [...rest: string] { print "⚠️ You should use mosh!" ^ssh ...$rest } # cd into one dir and list its content def peek [...paths: path] { if ($paths | is-empty) { print $"📂 Subdirectories of ($env.PWD):" ls | where type == dir | get name | print } else { for dir in $paths { if ($dir | path type) == dir { print $"📁 ($dir):" facad $dir print "" } else { print $"peek: '($dir)' is not a directory" } } } } # mkdir and cd def --env mkcd [dir: path] { mkdir $dir cd $dir } # cd ../ def --env back [] { cd .. } # git visualization def gitvis [] { git log --oneline --graph --all --decorate } def git-reauthor [] { git commit --amend --reset-author --no-edit } # check what apps are not managed by homebrew def brewoutcasts [] { let apps = (ls /Applications | where type == dir and name ends-with '.app') let total = ($apps | length) let formulae = (brew list --formula | str trim) let casks = (brew list --cask | str trim) mut unmanaged = [] for app in $apps { let name = ($app.name | str replace -r '\.app$' '') let base = ($name | str lowercase) let normalized = (match $base { 'hidden bar' => 'hiddenbar' 'helium' => 'helium-browser' _ => ($base | str replace -a ' ' '-' | str replace -a '.' '-') }) if $base == 'safari' { continue } let managed = ($formulae | any {|f| ($f | str lowercase) == $normalized }) or ($casks | any {|c| ($c | str lowercase) == $normalized }) if (not $managed) { print $"\n($name) is NOT managed by Homebrew" print $"-- Searching Homebrew for ($name)..." brew search $normalized | print $unmanaged = ($unmanaged | append $name) } } print "" print $"-- Summary: ($unmanaged | length) out of ($total) applications are not managed by Homebrew" } # yazi: cd into the dir yazi was closed in def --env y [...args: string] { let tmp = (mktemp -t 'yazi-cwd.XXXXXX' | str trim) command yazi ...$args --cwd-file=$tmp let cwd = (open --raw $tmp | str trim) if ($cwd | is-not-empty) and ($cwd != $env.PWD) { cd $cwd } rm -f $tmp } def weather [] { curl wttr.in/Shapingba } # thefuck is a bash/zsh hook; nu shim shows the suggested fix def fuck [] { let last = (history | get command | str trim | last) thefuck $last } # ---- Startup side effects ---- try { ^ssh-add ~/.ssh/id_ed25519_git o+e>| null } catch { } # ---- zoxide ---- if (which zoxide | is-not-empty) { mkdir ~/.config/nushell/autoload zoxide init nushell | save -f ~/.config/nushell/autoload/zoxide.nu } # ---- mise ---- if (which mise | is-not-empty) { mkdir ~/.config/nushell/autoload mise activate nu | str replace -a 'str upcase' 'str uppercase' | save -f ~/.config/nushell/autoload/mise.nu }