nu: Copy basic sh aliases

Held back a little by the issue that you can't really set aliases
conditionally (yet?) in nushell, which is kind of fundamental to my
zsh/sh alias setup. If a program exists, we add some nice aliases -- if
not, we simply degrade gracefully and don't add anything.

PR to track issue:
https://github.com/nushell/nushell/issues/5068
This commit is contained in:
Marty Oehme 2025-11-29 15:58:51 +01:00
parent dc8030f905
commit dc71f747da
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 63 additions and 15 deletions

View file

@ -8,7 +8,10 @@ exist() { type "$1" >/dev/null 2>&1; }
unalias -a unalias -a
if alias v >/dev/null 2>&1; then if alias v >/dev/null 2>&1; then
if exist vim; then if exist nvim; then
alias v="nvim"
alias vim="vi"
elif exist vim; then
alias v="vim" alias v="vim"
else else
alias v="vi" alias v="vi"

View file

@ -0,0 +1,59 @@
alias ":q" = exit # quit nushell
def --wrapped vim [...rest] {
let cmds = which nvim vim vi | where path != ""
if ($cmds | is-empty) {
error make {msg: "No vi-like binary found."}
}
let c = $cmds | first | get path
^$c ...$rest
}
alias v = vim # start ideal vim (nvim/vim/vi)
alias l = ls # list files
alias L = ls --all # list files including hidden
alias ll = ls **/* # list files recursively
alias LL = ls --all **/* # list files recursively including hidden
# can additionally support `eza` output when
# PR https://github.com/eza-community/eza/issues/768 lands
# make directory
alias md = mkdir
# make and enter directory
def --env mcd [path: path] {
mkdir $path
cd $path
}
alias cl = clear # clear screen
# FIXME: cll functionality seems hard to accomplish?
alias myip = http get icanhazip.com # return current ip
def --env --wrapped vmm [...rest] {
if (which vifm | is-not-empty) {
let rest = $rest | each {path expand}
vifm ...$rest $env.PWD
} else {
print "No vifm executable found."
}
}
alias vm = vifm
def --wrapped iv [...rest] {
let cmds = which vimiv imv nsxiv sxiv feh | where path != ""
if ($cmds | is-empty) {
error make {msg: "No image viewer binary found."}
}
let c = $cmds | first | get path
^$c ...$rest
}
alias db = distrobox
alias sc = sc-im
# job control
# TODO: requires minimum nushell: 0.103 for job control, how to check for it?
alias fg = job unfreeze

View file

@ -146,17 +146,3 @@ $env.config.keybindings = [
} }
} }
] ]
alias l = ls
alias cl = clear
alias md = mkdir
def --env mcd [path: path] {
mkdir $path
cd $path
}
alias v = nvim
# requires minimum nushell: 0.103 for job control
alias fg = job unfreeze