mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-05 03:32:34 +01:00
nushell: use dropin configs
This commit is contained in:
parent
d018b81707
commit
eb249b60ce
3 changed files with 48 additions and 36 deletions
6
.config/nushell/conf.d/98-aliases.nu
Normal file
6
.config/nushell/conf.d/98-aliases.nu
Normal file
|
@ -0,0 +1,6 @@
|
|||
def l [path: glob = "."] { ls $path | sort-by type }
|
||||
def ll [path: glob = "."] { ls -la $path | sort-by type }
|
||||
def la [path: glob = "."] { ls -a $path | sort-by type }
|
||||
alias nv = nvim
|
||||
alias nvide = & neovide "--no-fork"
|
||||
|
29
.config/nushell/conf.d/99-utils.nu
Normal file
29
.config/nushell/conf.d/99-utils.nu
Normal file
|
@ -0,0 +1,29 @@
|
|||
def --env mkdircd [p: string] {
|
||||
mkdir $p
|
||||
cd $p
|
||||
}
|
||||
|
||||
def wldd [path: string] {
|
||||
match (which $path) {
|
||||
[{ path: $p }] => { ldd $p },
|
||||
_ => { error make { msg: $"No external command ($path)" } },
|
||||
}
|
||||
}
|
||||
|
||||
def viewdoc [f: path] {
|
||||
let inp = $f | path parse
|
||||
|
||||
match $inp.extension {
|
||||
$e if $e in [ "doc", "docx", "odt", "ppt", "pptx", "odp" ] => {
|
||||
let outp = { extension: "pdf", parent: "/tmp", stem: $inp.stem } | path join
|
||||
libreoffice --convert-to pdf $f --outdir /tmp
|
||||
try { zathura $outp }
|
||||
rm $outp
|
||||
},
|
||||
"pdf" => { zathura $f },
|
||||
"html" => { openbrowser $"file://($f | path expand)" }
|
||||
$e if $e in [ "png", "webp", "jpg", "jpeg", "ff", "bmp" ] => { nsxiv $f },
|
||||
_ => { mpv $f },
|
||||
}
|
||||
}
|
||||
|
|
@ -36,39 +36,16 @@ $env.config = {
|
|||
]
|
||||
}
|
||||
|
||||
# Aliases
|
||||
def l [path: glob = "."] { ls $path | sort-by type }
|
||||
def ll [path: glob = "."] { ls -la $path | sort-by type }
|
||||
def la [path: glob = "."] { ls -a $path | sort-by type }
|
||||
alias nv = nvim
|
||||
alias nvide = & neovide "--no-fork"
|
||||
|
||||
# Misc functions
|
||||
def --env mkdircd [p: string] {
|
||||
mkdir $p
|
||||
cd $p
|
||||
}
|
||||
|
||||
def wldd [path: string] {
|
||||
match (which $path) {
|
||||
[{ path: $p }] => { ldd $p },
|
||||
_ => { error make { msg: $"No external command ($path)" } },
|
||||
}
|
||||
}
|
||||
|
||||
def viewdoc [f: path] {
|
||||
let inp = $f | path parse
|
||||
|
||||
match $inp.extension {
|
||||
$e if $e in [ "doc", "docx", "odt", "ppt", "pptx", "odp" ] => {
|
||||
let outp = { extension: "pdf", parent: "/tmp", stem: $inp.stem } | path join
|
||||
libreoffice --convert-to pdf $f --outdir /tmp
|
||||
try { zathura $outp }
|
||||
rm $outp
|
||||
},
|
||||
"pdf" => { zathura $f },
|
||||
"html" => { openbrowser $"file://($f | path expand)" }
|
||||
$e if $e in [ "png", "webp", "jpg", "jpeg", "ff", "bmp" ] => { nsxiv $f },
|
||||
_ => { mpv $f },
|
||||
}
|
||||
}
|
||||
<!
|
||||
local prefix = ".config/nushell/conf.d/"
|
||||
local dropins = {}
|
||||
for f in cg.fileIter() do
|
||||
if f.path:find(prefix, 1, true) == 1 then
|
||||
table.insert(dropins, f.path:sub(#prefix))
|
||||
end
|
||||
end
|
||||
table.sort(dropins, function(a, b) return a < b end)
|
||||
!>
|
||||
<! for _, d in ipairs(dropins) do !>
|
||||
source conf.d<% d %>
|
||||
<! end !>
|
||||
|
|
Loading…
Reference in a new issue