diff --git a/config.nu b/config.nu index 20b82eb..ab9f95e 100644 --- a/config.nu +++ b/config.nu @@ -17,13 +17,51 @@ # You can remove these comments if you want or leave # them for future reference. -# you have to oh-my-posh init nu --config -# after that you can --> -source ~/.oh-my-posh.nu +# ╭─────────────────────────────────────────────────────╮ +# │ Define a helper function to check command existence │ +# ╰─────────────────────────────────────────────────────╯ +def command_exists [cmd: string] { + not (which $cmd | is-empty) +} -# you have to zoxide init nushell | safe -f ~/.zoxide.nu -# after that you can --> -source ~/.zoxide.nu +# ╭───────────────────────────╮ +# │ oh-my-posh initialistaion │ +# ╰───────────────────────────╯ +if (command_exists oh-my-posh) { + if ($"~/.oh-my-posh.nu" | path exists) == true { + source ~/.oh-my-posh.nu + } +} + +# ╭───────────────────────╮ +# │ zoxide initialistaion │ +# ╰───────────────────────╯ +if (command_exists zoxide) { + if ($"~/.zoxide.nu" | path exists) { + source ~/.zoxide.nu + } else { + zoxide init nushell | save -f ~/.zoxide.nu + source ~/.zoxide.nu + } +} + +alias untar = tar -xf +alias .. = cd .. +alias www = curl wttr.in/Ulm +alias ip = ip --color=always + +if (command_exists git) { + alias g = git + alias gs = git status -sb + alias gsl = git status + # alias gm = git checkout main ; git merge + alias gc = git clone --recurse-submodule + alias gd = git diff + # alias gp = git submodule update --init --recursive ; git pull --recurse-submodule + # alias gsu = git submodule foreach git pull ; git submodule update --init --recursive ; git add . ; git commit -m ' update: submodules' ; echo '-- Committed changes, pushing now..' ; sleep 0.3 ; git push + alias gcm = git commit -m + alias gpu = git push --recurse-submodule=on-demand +} $env.config.history.file_format = "sqlite" $env.config.history.max_size = 5_000_000