nushell refactoring
This commit is contained in:
parent
636dddce81
commit
e274f0da0a
11 changed files with 247 additions and 215 deletions
|
|
@ -22,8 +22,6 @@ in {
|
||||||
imports = [
|
imports = [
|
||||||
./boxxy.nix
|
./boxxy.nix
|
||||||
(import ./helix.nix {inherit pkgs inputs;})
|
(import ./helix.nix {inherit pkgs inputs;})
|
||||||
# ./plasma.nix
|
|
||||||
# ./firefox.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# home.sessionPath = [
|
# home.sessionPath = [
|
||||||
|
|
@ -34,8 +32,18 @@ in {
|
||||||
source = ./autostart;
|
source = ./autostart;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
};
|
};
|
||||||
home.file.".config/direnv/lib/".source = ./direnv;
|
home.file.".config/direnv/lib/" = {
|
||||||
home.file.".config/direnv/lib/".recursive = true;
|
source = ./direnv;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
home.file.".config/nushell/scripts" = {
|
||||||
|
source = ./nushell/extras;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
home.file.".local/nushell/completions" = {
|
||||||
|
source = ./nushell/completions;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
bacon = {
|
bacon = {
|
||||||
|
|
@ -80,11 +88,7 @@ in {
|
||||||
settings = {
|
settings = {
|
||||||
color = "gruvbox";
|
color = "gruvbox";
|
||||||
flags = {
|
flags = {
|
||||||
battery =
|
battery = true;
|
||||||
# if lib.strings.hasPrefix "NOlaptop" (builtins.readFile /etc/hostname)
|
|
||||||
# then true
|
|
||||||
# else false;
|
|
||||||
true;
|
|
||||||
hide_time = true;
|
hide_time = true;
|
||||||
enable_gpu = true;
|
enable_gpu = true;
|
||||||
};
|
};
|
||||||
|
|
@ -93,7 +97,6 @@ in {
|
||||||
|
|
||||||
direnv = {
|
direnv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableNushellIntegration = true;
|
|
||||||
nix-direnv.enable = true;
|
nix-direnv.enable = true;
|
||||||
config = {
|
config = {
|
||||||
load_dotenv = true;
|
load_dotenv = true;
|
||||||
|
|
@ -127,6 +130,17 @@ in {
|
||||||
mpv = {
|
mpv = {
|
||||||
config = {
|
config = {
|
||||||
demuxer-max-bytes = "10GiB";
|
demuxer-max-bytes = "10GiB";
|
||||||
|
|
||||||
|
alang = "ja,jp,jpn,en,eng";
|
||||||
|
slang = "en,eng";
|
||||||
|
sub-scale = 0.5;
|
||||||
|
|
||||||
|
hr-seek = "yes";
|
||||||
|
|
||||||
|
hwdec = "auto";
|
||||||
|
vo = "gpu-next";
|
||||||
|
|
||||||
|
target-colorspace-hint = "auto";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -149,8 +163,12 @@ in {
|
||||||
configFile.source = ./nushell/config.nu;
|
configFile.source = ./nushell/config.nu;
|
||||||
envFile.source = ./nushell/env.nu;
|
envFile.source = ./nushell/env.nu;
|
||||||
# extraConfig = builtins.readFile ./nushell/stuff.nu;
|
# extraConfig = builtins.readFile ./nushell/stuff.nu;
|
||||||
extraConfig = lib.concatStrings (map builtins.readFile (map (x: ./nushell/extras/. + x) (map (x: "/" + x) (builtins.attrNames (builtins.readDir ./nushell/extras)))));
|
# extraConfig = lib.concatStrings (map builtins.readFile (map (x: ./nushell/extras/. + x) (map (x: "/" + x) (builtins.attrNames (builtins.readDir ./nushell/extras)))));
|
||||||
plugins = with pkgs.nushellPlugins; [
|
plugins = with pkgs.nushellPlugins; [
|
||||||
|
# skim
|
||||||
|
desktop_notifications
|
||||||
|
# highlight
|
||||||
|
# units
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -184,7 +202,6 @@ in {
|
||||||
|
|
||||||
starship = {
|
starship = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableNushellIntegration = true;
|
|
||||||
settings = builtins.fromTOML (builtins.readFile ./starship.toml);
|
settings = builtins.fromTOML (builtins.readFile ./starship.toml);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -213,7 +230,6 @@ in {
|
||||||
|
|
||||||
zoxide = {
|
zoxide = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableNushellIntegration = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
def "nu-complete just" [] {
|
export def "nu-complete just" [] {
|
||||||
(^just --dump --unstable --dump-format json | from json).recipes | transpose recipe data | flatten | where {|row| $row.private == false } | select recipe doc parameters | rename value description
|
(^just --dump --unstable --dump-format json | from json).recipes | transpose recipe data | flatten | where {|row| $row.private == false } | select recipe doc parameters | rename value description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2,82 +2,23 @@
|
||||||
#
|
#
|
||||||
# version = "0.96.1"
|
# version = "0.96.1"
|
||||||
|
|
||||||
# For more information on defining custom themes, see
|
use std/dirs
|
||||||
# https://www.nushell.sh/book/coloring_and_theming.html
|
use theme.nu dark_theme
|
||||||
# And here is the theme collection
|
|
||||||
# https://github.com/nushell/nu_scripts/tree/main/themes
|
use aliases.nu *
|
||||||
let dark_theme = {
|
use nix.nu *
|
||||||
# color for nushell primitives
|
use stuff.nu *
|
||||||
separator: white
|
use tailscale.nu *
|
||||||
leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off
|
|
||||||
header: green_bold
|
source completions-jj.nu
|
||||||
empty: blue
|
source completions-just.nu
|
||||||
# Closures can be used to choose colors for specific values.
|
|
||||||
# The value (in this case, a bool) is piped into the closure.
|
|
||||||
# eg) {|| if $in { 'light_cyan' } else { 'light_gray' } }
|
|
||||||
bool: light_cyan
|
|
||||||
int: white
|
|
||||||
filesize: cyan
|
|
||||||
duration: white
|
|
||||||
date: purple
|
|
||||||
range: white
|
|
||||||
float: white
|
|
||||||
string: white
|
|
||||||
nothing: white
|
|
||||||
binary: white
|
|
||||||
cell-path: white
|
|
||||||
row_index: green_bold
|
|
||||||
record: white
|
|
||||||
list: white
|
|
||||||
block: white
|
|
||||||
hints: dark_gray
|
|
||||||
search_result: { bg: red fg: white }
|
|
||||||
shape_and: purple_bold
|
|
||||||
shape_binary: purple_bold
|
|
||||||
shape_block: blue_bold
|
|
||||||
shape_bool: light_cyan
|
|
||||||
shape_closure: green_bold
|
|
||||||
shape_custom: green
|
|
||||||
shape_datetime: cyan_bold
|
|
||||||
shape_directory: cyan
|
|
||||||
shape_external: cyan
|
|
||||||
shape_externalarg: green_bold
|
|
||||||
shape_external_resolved: light_yellow_bold
|
|
||||||
shape_filepath: cyan
|
|
||||||
shape_flag: blue_bold
|
|
||||||
shape_float: purple_bold
|
|
||||||
# shapes are used to change the cli syntax highlighting
|
|
||||||
shape_garbage: { fg: white bg: red attr: b }
|
|
||||||
shape_glob_interpolation: cyan_bold
|
|
||||||
shape_globpattern: cyan_bold
|
|
||||||
shape_int: purple_bold
|
|
||||||
shape_internalcall: cyan_bold
|
|
||||||
shape_keyword: cyan_bold
|
|
||||||
shape_list: cyan_bold
|
|
||||||
shape_literal: blue
|
|
||||||
shape_match_pattern: green
|
|
||||||
shape_matching_brackets: { attr: u }
|
|
||||||
shape_nothing: light_cyan
|
|
||||||
shape_operator: yellow
|
|
||||||
shape_or: purple_bold
|
|
||||||
shape_pipe: purple_bold
|
|
||||||
shape_range: yellow_bold
|
|
||||||
shape_record: cyan_bold
|
|
||||||
shape_redirection: purple_bold
|
|
||||||
shape_signature: green_bold
|
|
||||||
shape_string: green
|
|
||||||
shape_string_interpolation: cyan_bold
|
|
||||||
shape_table: blue_bold
|
|
||||||
shape_variable: purple
|
|
||||||
shape_vardecl: purple
|
|
||||||
shape_raw_string: light_purple
|
|
||||||
}
|
|
||||||
|
|
||||||
# External completer example
|
# External completer example
|
||||||
# let carapace_completer = {|spans|
|
# let carapace_completer = {|spans|
|
||||||
# carapace $spans.0 nushell ...$spans | from json
|
# carapace $spans.0 nushell ...$spans | from json
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
|
||||||
# The default config record. This is where much of your global configuration is setup.
|
# The default config record. This is where much of your global configuration is setup.
|
||||||
$env.config = {
|
$env.config = {
|
||||||
show_banner: false # true or false to enable or disable the welcome banner at startup
|
show_banner: false # true or false to enable or disable the welcome banner at startup
|
||||||
|
|
@ -194,7 +135,7 @@ $env.config = {
|
||||||
reset_application_mode: true
|
reset_application_mode: true
|
||||||
}
|
}
|
||||||
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
||||||
use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
|
use_kitty_protocol: true # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
|
||||||
highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which.
|
highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which.
|
||||||
recursion_limit: 50 # the maximum number of times nushell allows recursion before stopping it
|
recursion_limit: 50 # the maximum number of times nushell allows recursion before stopping it
|
||||||
|
|
||||||
|
|
@ -822,6 +763,12 @@ $env.config = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir ($nu.data-dir | path join "vendor/autoload")
|
mkdir ($nu.data-dir | path join "vendor/autoload")
|
||||||
starship init nu | save -f ($nu.data-dir | path join "vendor/autoload/starship.nu")
|
starship init nu | save -f ($nu.data-dir | path join "vendor/autoload/starship.nu")
|
||||||
use std/dirs
|
|
||||||
|
source ~/.zoxide.nu
|
||||||
|
export def --wrapped --env z [...rest] {
|
||||||
|
zo ...$rest
|
||||||
|
l
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ $env.NU_PLUGIN_DIRS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
||||||
$env.PATH = ($env.PATH | split row (char esep) | prepend '/home/tao/.local/bin' | prepend '/home/tao/.cargo/bin')
|
$env.PATH = ($env.PATH | split row (char esep))
|
||||||
|
|
||||||
$env.GOPATH = '/home/tao/.go'
|
# $env.GOPATH = '/home/tao/.go'
|
||||||
|
|
||||||
# $env.CARAPACE_BRIDGES
|
# $env.CARAPACE_BRIDGES
|
||||||
mkdir ~/.cache/carapace
|
mkdir ~/.cache/carapace
|
||||||
|
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
alias b = btm
|
|
||||||
alias d = dirs
|
|
||||||
alias da = dirs add
|
|
||||||
alias dg = dirs goto
|
|
||||||
alias dn = dirs next
|
|
||||||
alias dp = dirs prev
|
|
||||||
alias dr = dirs drop
|
|
||||||
alias fetch = fastfetch
|
|
||||||
alias follow = readlink -f
|
|
||||||
alias p = pueue
|
|
||||||
alias snapper = snapper -c home
|
|
||||||
alias zl = zellij
|
|
||||||
|
|
||||||
alias cringe = sudo bootctl set-oneshot auto-windows
|
|
||||||
|
|
||||||
def h [query?: path] {
|
|
||||||
(if ($query != null) {sk -1 -q ($query | path basename)} else {sk -1})
|
|
||||||
| if ($in != "") {
|
|
||||||
hx $in
|
|
||||||
}
|
|
||||||
# | complete
|
|
||||||
# | if $in.exit_code == 0 {
|
|
||||||
# $in.stdout | str trim | hx $in
|
|
||||||
# }
|
|
||||||
}
|
|
||||||
|
|
||||||
def srg [] {
|
|
||||||
sk --ansi -i -c 'rg --color=always --line-number "{}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
alias j = jj
|
|
||||||
alias ja = jj log -r 'all()'
|
|
||||||
alias jc = jj desc
|
|
||||||
alias jd = jj diff
|
|
||||||
alias je = jj edit
|
|
||||||
alias jf = jj git fetch
|
|
||||||
alias jg = jj git clone --colocate
|
|
||||||
alias jp = jj git push
|
|
||||||
alias js = jj status
|
|
||||||
alias jw = jj workspace update-stale
|
|
||||||
alias jt = jj log -r @ -T `description`
|
|
||||||
alias jn = jj next --edit
|
|
||||||
|
|
||||||
def jm --wrapped [-r: string = "@", ...rest] {
|
|
||||||
mut r = $r
|
|
||||||
if (jj log -r @ --no-pager --no-graph --template 'if(empty,"empty")' | $in == "empty") {
|
|
||||||
$r = "@-"
|
|
||||||
}
|
|
||||||
jj bookmark set main -r $r ...$rest
|
|
||||||
jj git push
|
|
||||||
}
|
|
||||||
|
|
||||||
alias la = ls -a
|
|
||||||
alias ll = ls -l
|
|
||||||
alias lal = ls -la
|
|
||||||
alias ccp = cp -prv
|
|
||||||
alias mvp = mv-full -pv
|
|
||||||
|
|
||||||
def --env c [path: path = "~"] {
|
|
||||||
cd $path
|
|
||||||
l
|
|
||||||
}
|
|
||||||
|
|
||||||
def l --wrapped [path: path = ".", ...rest] {
|
|
||||||
ls -t $path ...$rest | insert ext {|row| $row.name | parse "{name}.{ext}" | get ext | get 0? } | sort-by --natural type ext name | reject type ext
|
|
||||||
}
|
|
||||||
|
|
||||||
alias list-automounts = systemctl list-units --type=automount
|
|
||||||
|
|
||||||
def remount [] {
|
|
||||||
let reload = list-automounts | detect columns --guess | drop 5 | get DESCRIPTION | input list --multi
|
|
||||||
for mount in $reload {
|
|
||||||
sudo systemctl restart $mount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def cpedit [file: path] {
|
|
||||||
mv $file $"($file).sym"; cp $"($file).sym" $file; chmod +w $file
|
|
||||||
}
|
|
||||||
|
|
||||||
alias core-job = job
|
|
||||||
alias job = job list
|
|
||||||
82
users/tao/nushell/extras/aliases.nu
Normal file
82
users/tao/nushell/extras/aliases.nu
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
export alias b = btm
|
||||||
|
export alias d = dirs
|
||||||
|
export alias da = dirs add
|
||||||
|
export alias dg = dirs goto
|
||||||
|
export alias dn = dirs next
|
||||||
|
export alias dp = dirs prev
|
||||||
|
export alias dr = dirs drop
|
||||||
|
export alias fetch = fastfetch
|
||||||
|
export alias follow = readlink -f
|
||||||
|
export alias p = pueue
|
||||||
|
export alias snapper = snapper -c home
|
||||||
|
export alias zl = zellij
|
||||||
|
|
||||||
|
export alias cringe = sudo bootctl set-oneshot auto-windows
|
||||||
|
|
||||||
|
export alias la = ls -a
|
||||||
|
export alias ll = ls -l
|
||||||
|
export alias lla = ls -la
|
||||||
|
|
||||||
|
export def --env c [path: path = "~"] {
|
||||||
|
cd $path
|
||||||
|
l
|
||||||
|
}
|
||||||
|
|
||||||
|
export def l --wrapped [path: path = ".", ...rest] {
|
||||||
|
ls -t $path ...$rest | insert ext {|row| $row.name | parse "{name}.{ext}" | get ext | get 0? } | sort-by --natural type ext name | reject type ext
|
||||||
|
}
|
||||||
|
|
||||||
|
export def h [query?: path] {
|
||||||
|
(if ($query != null) {sk -1 -q ($query | path basename)} else {sk -1})
|
||||||
|
| if ($in != "") {
|
||||||
|
hx $in
|
||||||
|
}
|
||||||
|
# | complete
|
||||||
|
# | if $in.exit_code == 0 {
|
||||||
|
# $in.stdout | str trim | hx $in
|
||||||
|
# }
|
||||||
|
}
|
||||||
|
|
||||||
|
export def srg [] {
|
||||||
|
sk --ansi -i -c 'rg --color=always --line-number "{}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
export alias j = jj
|
||||||
|
export alias ja = jj log -r 'all()'
|
||||||
|
export alias jc = jj desc
|
||||||
|
export alias jd = jj diff
|
||||||
|
export alias je = jj edit
|
||||||
|
export alias jf = jj git fetch
|
||||||
|
export alias jg = jj git clone --colocate
|
||||||
|
export alias jp = jj git push
|
||||||
|
export alias js = jj status
|
||||||
|
export alias jw = jj workspace update-stale
|
||||||
|
export alias jt = jj log -r @ -T `description`
|
||||||
|
export alias jn = jj next --edit
|
||||||
|
|
||||||
|
export def jm --wrapped [-r: string = "@", ...rest] {
|
||||||
|
mut r = $r
|
||||||
|
if (jj log -r @ --no-pager --no-graph --template 'if(empty,"empty")' | $in == "empty") {
|
||||||
|
$r = "@-"
|
||||||
|
}
|
||||||
|
jj bookmark set main -r $r ...$rest
|
||||||
|
jj git push
|
||||||
|
}
|
||||||
|
|
||||||
|
export alias list-automounts = systemctl list-units --type=automount
|
||||||
|
|
||||||
|
export def remount [] {
|
||||||
|
let reload = list-automounts | detect columns --guess | drop 5 | get DESCRIPTION | input list --multi
|
||||||
|
for mount in $reload {
|
||||||
|
sudo systemctl restart $mount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export def cpedit [file: path] {
|
||||||
|
mv $file $"($file).sym"; cp $"($file).sym" $file; chmod +w $file
|
||||||
|
}
|
||||||
|
|
||||||
|
export alias core-job = job
|
||||||
|
export alias job = job list
|
||||||
|
|
||||||
|
export alias mpv-hdr-dv = mpv --target-trc=pq --target-prim=bt.2020 --target-peak=800
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
def --wrapped rebuild [--force (-f), subcommand, ...rest] {
|
export def --wrapped rebuild [--force (-f), subcommand, ...rest] {
|
||||||
if not (
|
if not (
|
||||||
df -h | detect columns --guess | where "Mounted on" == "/" or "Mounted on" == "/boot" | get Use% | each {parse "{usage}%" | get usage | into int} | flatten | all {$in < 99}
|
df -h | detect columns --guess | where "Mounted on" == "/" or "Mounted on" == "/boot" | get Use% | each {parse "{usage}%" | get usage | into int} | flatten | all {$in < 99}
|
||||||
) and not $force {
|
) and not $force {
|
||||||
|
|
@ -27,9 +27,9 @@ def --wrapped rebuild [--force (-f), subcommand, ...rest] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alias nd = nix develop
|
export alias nd = nix develop
|
||||||
|
|
||||||
def ns [...packages: string] {
|
export def ns [...packages: string] {
|
||||||
let packages = $packages | each {$"nixpkgs#($in)"}
|
let packages = $packages | each {$"nixpkgs#($in)"}
|
||||||
nix shell ...$packages
|
nix shell ...$packages
|
||||||
}
|
}
|
||||||
|
|
@ -38,16 +38,17 @@ def ns [...packages: string] {
|
||||||
# nix search nixpkgs $package
|
# nix search nixpkgs $package
|
||||||
# }
|
# }
|
||||||
|
|
||||||
def post-rebuild [] {
|
export def post-rebuild [] {
|
||||||
rm -r ~/.config/helix/runtime/grammars/
|
rm -r ~/.config/helix/runtime/grammars/
|
||||||
hx --grammar fetch; hx --grammar build
|
hx --grammar fetch; hx --grammar build
|
||||||
rustup update
|
rustup update
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_gen [] {
|
export def get_gen [] {
|
||||||
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations | detect columns --guess -n | last | get column0
|
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations | detect columns --guess -n | last | get column0
|
||||||
}
|
}
|
||||||
def bump [...rest] {
|
|
||||||
|
export def bump [...rest] {
|
||||||
cd /home/tao/projects/NOflake/
|
cd /home/tao/projects/NOflake/
|
||||||
mut r = "@"
|
mut r = "@"
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -80,11 +81,10 @@ def bump [...rest] {
|
||||||
nvd history
|
nvd history
|
||||||
}
|
}
|
||||||
|
|
||||||
alias rb = rebuild boot
|
export alias rb = rebuild boot
|
||||||
alias rs = rebuild switch
|
export alias rs = rebuild switch
|
||||||
|
|
||||||
def gc [] {
|
export def gc [] {
|
||||||
sudo nix-collect-garbage -d
|
sudo nix-collect-garbage -d
|
||||||
snapper clear
|
snapper clear
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
def done [] {
|
export def done [] {
|
||||||
toastify send -a "" done
|
toastify send -a "" done
|
||||||
}
|
}
|
||||||
|
|
||||||
def "config stuff" [] {
|
export def "config stuff" [] {
|
||||||
hx ~/projects/NOflake/users/tao/nushell/stuff.nu
|
hx ~/projects/NOflake/users/tao/nushell/stuff.nu
|
||||||
}
|
}
|
||||||
|
|
||||||
def fixme [] {
|
export def fixme [] {
|
||||||
let items = rg "FIXME|TODO" --json
|
let items = rg "FIXME|TODO" --json
|
||||||
| lines
|
| lines
|
||||||
| each {from json}
|
| each {from json}
|
||||||
|
|
@ -24,26 +24,24 @@ def fixme [] {
|
||||||
hx ($items | get $sel | $"($in.text):($in.line_number)")
|
hx ($items | get $sel | $"($in.text):($in.line_number)")
|
||||||
}
|
}
|
||||||
|
|
||||||
source ~/.zoxide.nu
|
export def "snapper list" [] {
|
||||||
def --wrapped --env z [...rest] {
|
|
||||||
zo ...$rest
|
|
||||||
l
|
|
||||||
}
|
|
||||||
|
|
||||||
def "snapper list" [] {
|
|
||||||
snapper --csvout list | from csv | reject config subvolume default user used-space userdata active
|
snapper --csvout list | from csv | reject config subvolume default user used-space userdata active
|
||||||
}
|
}
|
||||||
|
|
||||||
def "snapper clear" [] {
|
export def "snapper clear" [] {
|
||||||
let list = snapper --csvout list | from csv | reject config subvolume default user used-space userdata active | skip 1
|
let list = snapper --csvout list | from csv | reject config subvolume default user used-space userdata active | skip 1
|
||||||
|
|
||||||
let first = $list | first
|
let first = $list | first
|
||||||
let last = $list | last
|
let last = $list | last
|
||||||
|
|
||||||
snapper delete $"($first.number)-($last.number)"
|
if $first != $last {
|
||||||
|
snapper delete $"($first.number)-($last.number)"
|
||||||
|
} else {
|
||||||
|
snapper delete $first
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def "fans" [duty?: int] {
|
export def "fans" [duty?: int] {
|
||||||
match (hostname) {
|
match (hostname) {
|
||||||
"NOcomputer" => {
|
"NOcomputer" => {
|
||||||
let mode_path: path = (glob "/sys/devices/platform/nct6775.656/hwmon/hwmon*/pwm2_enable" | get 0)
|
let mode_path: path = (glob "/sys/devices/platform/nct6775.656/hwmon/hwmon*/pwm2_enable" | get 0)
|
||||||
|
|
@ -61,15 +59,15 @@ def "fans" [duty?: int] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alias louder = fans 100
|
export alias louder = fans 100
|
||||||
alias loud = fans
|
export alias loud = fans
|
||||||
alias quiet = fans 42
|
export alias quiet = fans 42
|
||||||
|
|
||||||
def asciicam [] {
|
export def asciicam [] {
|
||||||
$env.DISPLAY = null
|
$env.DISPLAY = null
|
||||||
mpv -vo caca av://v4l2:/dev/video0 --demuxer-lavf-o=input_format=mjpeg --profile=low-latency e>| /dev/null
|
mpv -vo caca av://v4l2:/dev/video0 --demuxer-lavf-o=input_format=mjpeg --profile=low-latency e>| /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
def sunu [command] {
|
export def sunu [command] {
|
||||||
sudo nu --stdin --commands $command
|
sudo nu --stdin --commands $command
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# see if others see us connecting from a mullvad exit node
|
# see if others see us connecting from a mullvad exit node
|
||||||
def check-mullvad [] {
|
export def check-mullvad [] {
|
||||||
print -n "checking mullvad status"
|
print -n "checking mullvad status"
|
||||||
mut check = false
|
mut check = false
|
||||||
mut j = null
|
mut j = null
|
||||||
|
|
@ -13,7 +13,7 @@ def check-mullvad [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# switch to a specific exit node, or none
|
# switch to a specific exit node, or none
|
||||||
def te [exit_node: string = ""] {
|
export def te [exit_node: string = ""] {
|
||||||
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
|
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
|
||||||
print "stop summoning first!"
|
print "stop summoning first!"
|
||||||
return false
|
return false
|
||||||
|
|
@ -30,7 +30,7 @@ def te [exit_node: string = ""] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# list all mullvad exit nodes
|
# list all mullvad exit nodes
|
||||||
def tx [] {
|
export def tx [] {
|
||||||
tailscale exit-node list
|
tailscale exit-node list
|
||||||
| lines
|
| lines
|
||||||
| drop 4
|
| drop 4
|
||||||
|
|
@ -42,7 +42,7 @@ tailscale exit-node list
|
||||||
}
|
}
|
||||||
|
|
||||||
# sort mullvad exit nodes by fastest ping
|
# sort mullvad exit nodes by fastest ping
|
||||||
def tsp [] {
|
export def tsp [] {
|
||||||
tx
|
tx
|
||||||
| where COUNTRY == USA
|
| where COUNTRY == USA
|
||||||
| par-each {
|
| par-each {
|
||||||
|
|
@ -66,18 +66,18 @@ tx
|
||||||
}
|
}
|
||||||
|
|
||||||
# switch to a random mullvad exit node
|
# switch to a random mullvad exit node
|
||||||
def tr [] {
|
export def tr [] {
|
||||||
tx
|
tx
|
||||||
| get (random int 0..($in | length))
|
| get (random int 0..($in | length))
|
||||||
| te $in.IP
|
| te $in.IP
|
||||||
| return $in
|
| return $in
|
||||||
}
|
}
|
||||||
|
|
||||||
alias t = tailscale
|
export alias t = tailscale
|
||||||
alias ts = tailscale status
|
export alias ts = tailscale status
|
||||||
alias tu = tailscale up
|
export alias tu = tailscale up
|
||||||
alias td = tailscale down
|
export alias td = tailscale down
|
||||||
alias ta = tailscale exit-node suggest
|
export alias ta = tailscale exit-node suggest
|
||||||
alias tt = tailscale switch --list | detect columns | input list -d Tailnet | get ID | t switch $in
|
export alias tt = tailscale switch --list | detect columns | input list -d Tailnet | get ID | t switch $in
|
||||||
|
|
||||||
alias wno = ssh root@whyfi "etherwake -i br-lan 04:42:1A:E7:62:C3"
|
export alias wno = ssh root@whyfi "etherwake -i br-lan 04:42:1A:E7:62:C3"
|
||||||
|
|
|
||||||
71
users/tao/nushell/extras/theme.nu
Normal file
71
users/tao/nushell/extras/theme.nu
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# For more information on defining custom themes, see
|
||||||
|
# https://www.nushell.sh/book/coloring_and_theming.html
|
||||||
|
# And here is the theme collection
|
||||||
|
# https://github.com/nushell/nu_scripts/tree/main/themes
|
||||||
|
export const dark_theme = {
|
||||||
|
# color for nushell primitives
|
||||||
|
separator: white
|
||||||
|
leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off
|
||||||
|
header: green_bold
|
||||||
|
empty: blue
|
||||||
|
# Closures can be used to choose colors for specific values.
|
||||||
|
# The value (in this case, a bool) is piped into the closure.
|
||||||
|
# eg) {|| if $in { 'light_cyan' } else { 'light_gray' } }
|
||||||
|
bool: light_cyan
|
||||||
|
int: white
|
||||||
|
filesize: cyan
|
||||||
|
duration: white
|
||||||
|
date: purple
|
||||||
|
range: white
|
||||||
|
float: white
|
||||||
|
string: white
|
||||||
|
nothing: white
|
||||||
|
binary: white
|
||||||
|
cell-path: white
|
||||||
|
row_index: green_bold
|
||||||
|
record: white
|
||||||
|
list: white
|
||||||
|
block: white
|
||||||
|
hints: dark_gray
|
||||||
|
search_result: { bg: red fg: white }
|
||||||
|
shape_and: purple_bold
|
||||||
|
shape_binary: purple_bold
|
||||||
|
shape_block: blue_bold
|
||||||
|
shape_bool: light_cyan
|
||||||
|
shape_closure: green_bold
|
||||||
|
shape_custom: green
|
||||||
|
shape_datetime: cyan_bold
|
||||||
|
shape_directory: cyan
|
||||||
|
shape_external: cyan
|
||||||
|
shape_externalarg: green_bold
|
||||||
|
shape_external_resolved: light_yellow_bold
|
||||||
|
shape_filepath: cyan
|
||||||
|
shape_flag: blue_bold
|
||||||
|
shape_float: purple_bold
|
||||||
|
# shapes are used to change the cli syntax highlighting
|
||||||
|
shape_garbage: { fg: white bg: red attr: b }
|
||||||
|
shape_glob_interpolation: cyan_bold
|
||||||
|
shape_globpattern: cyan_bold
|
||||||
|
shape_int: purple_bold
|
||||||
|
shape_internalcall: cyan_bold
|
||||||
|
shape_keyword: cyan_bold
|
||||||
|
shape_list: cyan_bold
|
||||||
|
shape_literal: blue
|
||||||
|
shape_match_pattern: green
|
||||||
|
shape_matching_brackets: { attr: u }
|
||||||
|
shape_nothing: light_cyan
|
||||||
|
shape_operator: yellow
|
||||||
|
shape_or: purple_bold
|
||||||
|
shape_pipe: purple_bold
|
||||||
|
shape_range: yellow_bold
|
||||||
|
shape_record: cyan_bold
|
||||||
|
shape_redirection: purple_bold
|
||||||
|
shape_signature: green_bold
|
||||||
|
shape_string: green
|
||||||
|
shape_string_interpolation: cyan_bold
|
||||||
|
shape_table: blue_bold
|
||||||
|
shape_variable: purple
|
||||||
|
shape_vardecl: purple
|
||||||
|
shape_raw_string: light_purple
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue