From b16fa1ba6e8c711dc164abe337d842107fdd39f3 Mon Sep 17 00:00:00 2001 From: elwrcl Date: Sun, 2 Aug 2026 19:30:03 +0300 Subject: [PATCH] nu --- .../home-nushell-commandline-copy.ulu.nix | 14 ++- modules/home/home-nushell-keybinds.ulu.nix | 32 +++++ modules/home/home-nushell.ulu.nix | 110 ++++++++++++++---- modules/home/home-shell-tools.ulu.nix | 1 + 4 files changed, 128 insertions(+), 29 deletions(-) create mode 100644 modules/home/home-nushell-keybinds.ulu.nix diff --git a/modules/home/home-nushell-commandline-copy.ulu.nix b/modules/home/home-nushell-commandline-copy.ulu.nix index e382241..bba464f 100644 --- a/modules/home/home-nushell-commandline-copy.ulu.nix +++ b/modules/home/home-nushell-commandline-copy.ulu.nix @@ -1,12 +1,16 @@ { ... }: { flake.homeModules.home-nushell-commandline-copy = - { ... }: + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe'; + wlCopy = getExe' pkgs.wl-clipboard "wl-copy"; + in { - programs.nushell.extraConfig = '' - use std/clip - def nu-highlight-default [] { + home.packages = [ pkgs.wl-clipboard ]; + programs.nushell.extraConfig = '' + def nu-highlight-default [] { let input = $in $env.config.color_config = {} $input | nu-highlight @@ -17,7 +21,7 @@ | nu-highlight-default | [ "```ansi" $in "```" ] | str join (char nl) - | clip copy --ansi + | ^${wlCopy} } $env.config.keybindings ++= [ diff --git a/modules/home/home-nushell-keybinds.ulu.nix b/modules/home/home-nushell-keybinds.ulu.nix new file mode 100644 index 0000000..c5f6a28 --- /dev/null +++ b/modules/home/home-nushell-keybinds.ulu.nix @@ -0,0 +1,32 @@ +{ ... }: +{ + flake.homeModules.home-nushell-keybinds = + { ... }: + { + programs.nushell.extraConfig = '' + $env.config.keybindings ++= [ + { + name: jj_status + modifier: control + keycode: char_g + mode: [ emacs vi_insert vi_normal ] + event: { send: executehostcommand, cmd: "jj status" } + } + { + name: jj_log + modifier: alt + keycode: char_l + mode: [ emacs vi_insert vi_normal ] + event: { send: executehostcommand, cmd: "jj log" } + } + { + name: jj_diff + modifier: alt + keycode: char_d + mode: [ emacs vi_insert vi_normal ] + event: { send: executehostcommand, cmd: "jj diff" } + } + ] + ''; + }; +} diff --git a/modules/home/home-nushell.ulu.nix b/modules/home/home-nushell.ulu.nix index dec9808..ebab0cd 100644 --- a/modules/home/home-nushell.ulu.nix +++ b/modules/home/home-nushell.ulu.nix @@ -11,19 +11,38 @@ ll = "eza -lah --icons --group-directories-first"; la = "eza -a --icons --group-directories-first"; lt = "eza --tree --level=2 --icons"; + tree = "eza --tree --git-ignore --group-directories-first"; + cat = "bat"; - df = "df -h"; - du = "du -h"; - free = "free -h"; + df = "^df -h"; + du = "^du -h"; + free = "^free -h"; rm = "trash-put"; + sysinfo = "fastfetch"; monitor = "sudo btop"; ports = "sudo ss -tulpn"; myip = "curl ifconfig.me"; + + js = "jj status"; + jl = "jj log"; + jd = "jj diff"; + jc = "jj commit"; + jp = "jj git push"; + jf = "jj git fetch"; + gs = "git status"; ga = "git add"; gp = "git push"; gl = "git log --oneline --graph --decorate"; + + #gnu + gfind = "^find"; + ggrep = "^grep --color=auto"; + gls = "^ls"; + gdu = "^du"; + gmkdir = "^mkdir"; + ".." = "cd .."; "..." = "cd ../.."; "...." = "cd ../../.."; @@ -32,6 +51,8 @@ environmentVariables = { MESA_SHADER_CACHE_MAX_SIZE = "2G"; MESA_SHADER_CACHE_DIR = "/tmp/mesa_shader_cache"; + FZF_DEFAULT_OPTS = "--height 40% --layout=reverse --border"; + FZF_DEFAULT_COMMAND = "fd --type f --hidden --follow --exclude .git"; }; extraEnv = '' @@ -40,32 +61,73 @@ extraConfig = '' $env.config.show_banner = false - def gc [msg: string] { git commit -m $msg } - def rebuild [] { - git -C ~/copland add -A - git -C ~/copland commit -m "update" - nh os switch + $env.config.history.file_format = "sqlite" + $env.config.history.max_size = 1_000_000 + $env.config.history.isolation = false + + $env.config.edit_mode = "vi" + $env.config.cursor_shape.vi_insert = "line" + $env.config.cursor_shape.vi_normal = "block" + + $env.config.completions.algorithm = "substring" + $env.config.highlight_resolved_externals = true + + def --env mc [path: path] { + mkdir $path + cd $path } - def rebuild-dry [] { nh os switch --dry } - def rebuild-cop [] { - nix flake update --flake ~/copland - git -C ~/copland add -A - git -C ~/copland commit -m $"flake update (date now | format date '%Y-%m-%d')" - nh os switch + def --env mcg [path: path] { + mkdir $path + cd $path + jj git init --colocate } - def extract [file: string] { - let ext = ($file | path parse | get extension) - match $ext { - "gz" => { tar xzf $file }, - "bz2" => { tar xjf $file }, - "tar" => { tar xf $file }, - "zip" => { unzip $file }, - "7z" => { 7z x $file }, - "rar" => { unrar e $file }, - _ => { print $"'($file)' can't be extracted" } + + def rebuild [] { + jj --repository ~/copland status | ignore + nh os switch --accept-flake-config + } + + def rebuild-dry [] { + nh os switch --dry --accept-flake-config + } + + def rebuild-up [] { + nix flake update --flake ~/copland + jj --repository ~/copland status | ignore + nh os switch --accept-flake-config + } + + def extract [file: path] { + let name = ($file | path basename) + match $name { + _ if ($name | str ends-with ".tar.bz2") => { ^tar xjf $file } + _ if ($name | str ends-with ".tar.gz") => { ^tar xzf $file } + _ if ($name | str ends-with ".tar.xz") => { ^tar xJf $file } + _ if ($name | str ends-with ".tar") => { ^tar xf $file } + _ if ($name | str ends-with ".bz2") => { ^bunzip2 $file } + _ if ($name | str ends-with ".gz") => { ^gunzip $file } + _ if ($name | str ends-with ".zip") => { ^unzip $file } + _ if ($name | str ends-with ".7z") => { ^7z x $file } + _ if ($name | str ends-with ".rar") => { ^unrar e $file } + _ => { print $"(ansi red)'($name)' açılamıyor(ansi reset)" } + } + } + + # `which`, with canonicalize . + def realwhich [...applications: string, --all (-a)] { + which --all=$all ...$applications + | update path {|row| + match $row.type { + "external" => { $row.path | path expand } + _ => $row.path + } } } + + if ($"($env.HOME)/.config/copetch/animated-copetch.sh" | path exists) { + ^$"($env.HOME)/.config/copetch/animated-copetch.sh" + } ''; }; }; diff --git a/modules/home/home-shell-tools.ulu.nix b/modules/home/home-shell-tools.ulu.nix index cfb66f5..6315516 100644 --- a/modules/home/home-shell-tools.ulu.nix +++ b/modules/home/home-shell-tools.ulu.nix @@ -8,6 +8,7 @@ programs.zoxide = { enable = true; enableNushellIntegration = true; + options = [ "--cmd cd" ]; }; }; }