diff --git a/modules/shell/nu.nix b/modules/shell/nu.nix index 30b4347..54ec9a8 100644 --- a/modules/shell/nu.nix +++ b/modules/shell/nu.nix @@ -13,14 +13,14 @@ pkgs.pueue ]; home.file."shell-startup" = { - source = ../../other/scripts/desktop/shell-startup.nu; + source = ./nu/shell-startup.nu; target = ".config/nushell/shell-startup.nu"; }; programs.nushell = { enable = true; package = config.users.defaultUserShell; - configFile.source = ../../other/config.nu; - envFile.source = ../../other/env.nu; + configFile.source = ./nu/config.nu; + envFile.source = ./nu/env.nu; extraConfig = '' plugin add ${pkgs.nushellPlugins.query}/bin/nu_plugin_query; plugin add ${pkgs.nushellPlugins.polars}/bin/nu_plugin_polars; @@ -30,7 +30,9 @@ plugin use polars; plugin use formats; - nu ${../../other/scripts/desktop/shell-startup.nu}; + source ${./nu/custom_commands.nu}; + source ${./nu/aliases.nu}; + nu ${./nu/shell-startup.nu}; ''; extraEnv = '' ''; diff --git a/modules/shell/nu/aliases.nu b/modules/shell/nu/aliases.nu new file mode 100644 index 0000000..5e1287b --- /dev/null +++ b/modules/shell/nu/aliases.nu @@ -0,0 +1,28 @@ + +alias gnix = cd ~/nix-configs; +alias grepo = cd ~/Documents/repos; +alias wh = wormhole-rs; + +alias gg = gitui; +alias ga = git add; +alias gc = git commit; +alias gca = git commit --all; +alias gp = git push; +alias gl = git pull; +alias gs = git status; +alias clip = xclip -selection c; + +alias cr = cargo run; +alias cl = cargo clippy; +alias cb = cargo build; +alias cch = cargo check; + +alias togglecaps = xdotool key Caps_Lock; +alias TOGGLECAPS = togglecaps; + +alias bash = echo $"(ansi red)no, fuck that shit!"; +alias sh = echo $"(ansi red)no, fuck that shit!"; +alias zsh = echo $"(ansi red)no, fuck that shit!"; +alias fish = echo $"(ansi red)no, fuck that shit!"; + +alias px = pulsemixer; diff --git a/other/config.nu b/modules/shell/nu/config.nu similarity index 61% rename from other/config.nu rename to modules/shell/nu/config.nu index 275be1a..c2348f0 100644 --- a/other/config.nu +++ b/modules/shell/nu/config.nu @@ -101,95 +101,3 @@ $env.config = { pre_execution: [{ $env.CMD_COUNT = $env.CMD_COUNT + 1; }] # run before the repl input is run } } - - -# start_zellij - -def nsp [ - ...programs: string -] { - nix shell ...($programs | each {|it| $"nixpkgs#($it)" }) -} - -def nr [ - program: string -] { - nix run $"nixpkgs#($program)" -} - -def lcr [ - file_extension: string -] { - ls **/* - | where name ends-with $".($file_extension)" - | par-each {|file| - open $file.name - | lines --skip-empty - | length } - | math sum -} - -def glog [ - amount: int -] { - git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n $amount - | lines - | split column "»¦«" commit subject name email date -} - -def typed [ - name: string -] { - touch $"($name).typ" - typst compile $"($name).typ" - mprocs --names Editor,Viewer,Notify $"hx '($name).typ'" $"while true; do mupdf-x11 '($name).pdf' && break; done" $"while inotifywait -e modify '($name).pdf' ; do pkill -HUP mupdf; done" -} - -def nev [ unit = day ] { - ( ( open Docs/dates.csv - | update datetime {|it| $it.datetime | into datetime } - | first - ).datetime - (date now) - ) - | into duration - | format duration $unit -} - -# TODO: intermediate stations -def bx [from: string to: string] { - let map = open ~/Docs/ril100map.json; - let start = $map | get ($from | str upcase) | first; - let dest = $map | get ($to | str upcase) | first; - - let url = $"https://bahn.expert/routing/($start)/($dest)/0/"; - print $url; - ^bash -c $"nohup chromium '($url)' &"; -} - -alias gnix = cd ~/nix-configs; -alias grepo = cd ~/Documents/repos; -alias wh = wormhole-rs; - -alias gg = gitui; -alias ga = git add; -alias gc = git commit; -alias gca = git commit --all; -alias gp = git push; -alias gl = git pull; -alias gs = git status; -alias clip = xclip -selection c; - -alias cr = cargo run; -alias cl = cargo clippy; -alias cb = cargo build; -alias cch = cargo check; - -alias togglecaps = xdotool key Caps_Lock; -alias TOGGLECAPS = togglecaps; - -alias bash = echo $"(ansi red)no, fuck that shit!"; -alias sh = echo $"(ansi red)no, fuck that shit!"; -alias zsh = echo $"(ansi red)no, fuck that shit!"; -alias fish = echo $"(ansi red)no, fuck that shit!"; - -alias px = pulsemixer; diff --git a/modules/shell/nu/custom_commands.nu b/modules/shell/nu/custom_commands.nu new file mode 100644 index 0000000..e3581f3 --- /dev/null +++ b/modules/shell/nu/custom_commands.nu @@ -0,0 +1,67 @@ +# open nix shell with a bunch of programs +def nsp [ + ...programs: string +] { + nix shell ...($programs | each {|it| $"nixpkgs#($it)" }) +} + +# do a nix run of a nix package +def nr [ + program: string +] { + nix run $"nixpkgs#($program)" +} + +# do a recursive line count of a file extension +def lcr [ + file_extension: string +] { + ls **/* + | where name ends-with $".($file_extension)" + | par-each {|file| + open $file.name + | lines --skip-empty + | length } + | math sum +} + +# get parsed git log +def glog [ + amount: int +] { + git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n $amount + | lines + | split column "»¦«" commit subject name email date +} + +# open typst IDE ish setup +def typed [ + name: string +] { + touch $"($name).typ" + typst compile $"($name).typ" + mprocs --names Editor,Viewer,Notify $"hx '($name).typ'" $"while true; do mupdf-x11 '($name).pdf' && break; done" $"while inotifywait -e modify '($name).pdf' ; do pkill -HUP mupdf; done" +} + +# figure out when the next event is +def nev [ unit = day ] { + ( ( open Docs/dates.csv + | update datetime {|it| $it.datetime | into datetime } + | first + ).datetime - (date now) + ) + | into duration + | format duration $unit +} + +# open chromium with bahn.expert opened and ready +# TODO: intermediate stations +def bx [from: string to: string] { + let map = open ~/Docs/ril100map.json; + let start = $map | get ($from | str upcase) | first; + let dest = $map | get ($to | str upcase) | first; + + let url = $"https://bahn.expert/routing/($start)/($dest)/0/"; + print $url; + ^bash -c $"nohup chromium '($url)' &"; +} diff --git a/other/env.nu b/modules/shell/nu/env.nu similarity index 100% rename from other/env.nu rename to modules/shell/nu/env.nu diff --git a/other/scripts/desktop/shell-startup.nu b/modules/shell/nu/shell-startup.nu similarity index 100% rename from other/scripts/desktop/shell-startup.nu rename to modules/shell/nu/shell-startup.nu