better ls for nu and other
This commit is contained in:
parent
da44ce7fa9
commit
b01e0cbf90
3 changed files with 53 additions and 31 deletions
6
flake.lock
generated
6
flake.lock
generated
|
@ -153,11 +153,11 @@
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1751940880,
|
"lastModified": 1752027847,
|
||||||
"narHash": "sha256-lzPU5X3b8w68mUsGHgkRDOJ1DK+gzfov91vsBx2dsAM=",
|
"narHash": "sha256-v+WdGcG0ra7YIyI2HruIYqWWxSXBEaG8UStzjAmkkHk=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "emacs-overlay",
|
"repo": "emacs-overlay",
|
||||||
"rev": "82937ee6d83abf5a9a5a8ae05329c37c0e9380cf",
|
"rev": "5a64a848253e773d14dffe72e95bf302932e6d02",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -18,20 +18,6 @@ def --env doomup [...args] {
|
||||||
systemctl --user restart emacs.service
|
systemctl --user restart emacs.service
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: is there a way to passthrough args?
|
|
||||||
def ls [...p] {
|
|
||||||
let pattern = if ($p | is-empty) { [ '.' ] } else { $p }
|
|
||||||
nuls -lm ...$pattern | select name size modified mode user | update modified {format date "%Y-%m-%d %H:%M:%S"}
|
|
||||||
}
|
|
||||||
|
|
||||||
def lla [...p] {
|
|
||||||
let pattern = if ($p | is-empty) { [ '.' ] } else { $p }
|
|
||||||
nuls -alm ...$pattern | select name size modified mode user | update modified {format date "%Y-%m-%d %H:%M:%S"}
|
|
||||||
}
|
|
||||||
|
|
||||||
alias "ll" = ls
|
|
||||||
alias "la" = lla
|
|
||||||
|
|
||||||
# def --env pullall [] {
|
# def --env pullall [] {
|
||||||
|
|
||||||
# }
|
# }
|
||||||
|
@ -43,3 +29,53 @@ def pdf-compress [...args] {
|
||||||
def nh-switch-gc [...args] {
|
def nh-switch-gc [...args] {
|
||||||
nh os switch; nh clean all --keep 3 --nogcroots; nix store optimise;
|
nh os switch; nh clean all --keep 3 --nogcroots; nix store optimise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let external_completer = {|spans|
|
||||||
|
match $spans.0 {
|
||||||
|
_ => $fish_completer
|
||||||
|
} | do $in $spans
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# List the filenames, sizes, and modification times of items in a directory.
|
||||||
|
@category filesystem
|
||||||
|
@search-terms dir
|
||||||
|
@example "List the files in the current directory" { ls }
|
||||||
|
@example "List visible files in a subdirectory" { ls subdir }
|
||||||
|
@example "List visible files with full path in the parent directory" { ls -f .. }
|
||||||
|
@example "List Rust files" { ls *.rs }
|
||||||
|
@example "List files and directories whose name do not contain 'bar'" { ls | where name !~ bar }
|
||||||
|
@example "List the full path of all dirs in your home directory" { ls -a ~ | where type == dir }
|
||||||
|
@example "List only the names (not paths) of all dirs in your home directory which have not been modified in 7 days" { ls -as ~ | where type == dir and modified < ((date now) - 7day) }
|
||||||
|
@example "Recursively list all files and subdirectories under the current directory using a glob pattern" { ls -a **/* }
|
||||||
|
@example "Recursively list *.rs and *.toml files using the glob command" { ls ...(glob **/*.{rs,toml}) }
|
||||||
|
@example "List given paths and show directories themselves" { ['/path/to/directory' '/path/to/file'] | each {|| ls -D $in } | flatten }
|
||||||
|
def ls [
|
||||||
|
--all (-a), # Show hidden files
|
||||||
|
--long (-l), # Get all available columns for each entry (slower; columns are platform-dependent)
|
||||||
|
--short-names (-s), # Only print the file names, and not the path
|
||||||
|
--full-paths (-f), # display paths as absolute paths
|
||||||
|
--du (-d), # Display the apparent directory size ("disk usage") in place of the directory metadata size
|
||||||
|
--directory (-D), # List the specified directory itself instead of its contents
|
||||||
|
--mime-type (-m), # Show mime-type in type column instead of 'file' (based on filenames only; files' contents are not examined)
|
||||||
|
--threads (-t), # Use multiple threads to list contents. Output will be non-deterministic.
|
||||||
|
...pattern: glob, # The glob pattern to use.
|
||||||
|
]: [nothing -> table] {
|
||||||
|
let pattern = if ($pattern | is-empty) { ['.'] } else { $pattern }
|
||||||
|
(
|
||||||
|
nuls
|
||||||
|
--all=$all
|
||||||
|
--long
|
||||||
|
--short-names=$short_names
|
||||||
|
--full-paths=$full_paths
|
||||||
|
--du=$du
|
||||||
|
--directory=$directory
|
||||||
|
--mime-type
|
||||||
|
--threads=$threads
|
||||||
|
...$pattern
|
||||||
|
) | select name size modified mode user | update modified {format date "%Y-%m-%d %H:%M:%S"}
|
||||||
|
}
|
||||||
|
|
||||||
|
alias "ll" = ls
|
||||||
|
alias "la" = ls -a
|
||||||
|
alias "lla" = la
|
||||||
|
|
|
@ -18,17 +18,3 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let zoxide_completer = {|spans|
|
|
||||||
$spans | skip 1 | zoxide query -l ...$in | lines | each {|line| $line | str replace $env.HOME '~' } | where {|x| $x != $env.PWD}
|
|
||||||
}
|
|
||||||
|
|
||||||
let external_completer = {|spans|
|
|
||||||
|
|
||||||
match $spans.0 {
|
|
||||||
|
|
||||||
# use zoxide completions for zoxide commands
|
|
||||||
z | zi => $zoxide_completer
|
|
||||||
__zoxide_z | __zoxide_zi => $zoxide_completer
|
|
||||||
_ => $fish_completer
|
|
||||||
} | do $in $spans
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue