# Nushell Config File # # version = "0.90.1" # Command existence checker function def 'is-installed' [ app: string ] { ((which $app | length) > 0) } # Git aliases export alias ga = git add export alias gcl = git clone export alias gcmsg = git commit -m export alias gd = git diff export alias gl = git pull export alias gp = git push export alias gr = git remote export alias grbi = git rebase -i export alias grm = git rm export alias grv = git remote -v export alias gst = git status # Doom Emacs def doomdoc [] { ~/.config/emacs/bin/doom doctor } def dsync [] { ~/.config/emacs/bin/doom sync } def dclean [] { ~/.config/emacs/bin/doom clean } def dcomp [] { ~/.config/emacs/bin/doom compile } def dpurge [] { ~/.config/emacs/bin/doom purge } def denv [] { ~/.config/emacs/bin/doom env } def dupgrade [] { ~/.config/emacs/bin/doom upgrade } # firewalld export alias fw = sudo firewall-cmd export alias fwp = sudo firewall-cmd --permanent export alias fwr = sudo firewall-cmd --reload export alias fwrp = sudo firewall-cmd --runtime-to-permanent # Execute bash on host (atomic desktop) export alias hostexec = distrobox-host-exec bash # Aliases for APT export alias acs = sudo apt-cache search export alias acp = sudo apt-cache policy export alias afs = sudo apt-file search export alias afu = sudo apt-file update export alias aac = sudo apt autoclean export alias agc = sudo apt clean export alias agi = sudo apt install export alias agli = sudo apt list --installed export alias agp = sudo apt purge export alias agr = sudo apt remove export alias agu = sudo apt update export alias agud = sudo apt update and sudo apt dist-upgrade export alias agar = sudo apt autoremove # Aliases for DNF export alias dnfc = sudo dnf clean all export alias dnfi = sudo dnf install export alias dnfu = sudo dnf update export alias dnfr = sudo dnf remove export alias dnfs = sudo dnf search # Copy SSH public key to clipboard def pubkey [] { open --raw ~/.ssh/id_ed25519.pub | str trim | xclip -selection clipboard } # Get public ip info def pubip [] { curl --silent ipinfo.io | from json } # Get Mullvad info def amimulvad [] { curl -sSL https://am.i.mullvad/json | from json } # Uptime info def upt [] { uptime | jc --uptime | from json } # df info def dfj [] { df | jc --df | from json } # /etc/fstab info def etc-fstab [] { open --raw /etc/fstab | jc --fstab | from json } # memory free info def memfree [] { free | jc --free | from json } # /etc/group def etc-group [] { open --raw /etc/group | jc --group | from json } # /etc/passwd def etc-passwd [] { open --raw /etc/passwd | jc --passwd | from json } # Network connections def netcons [] { lsof -i | jc --lsof | from json } # Ports def tulp [] { ss -tulp | jc --ss | from json } # Open ports def openports [] { sudo lsof -i | jc --lsof | from json | find "LISTEN" } # List sockets in use def lsock [] { sudo lsof -i P | jc --lsof | from json } # List UDP sockets in use def lsocku [] { sudo lsof -nP | jc --lsof | from json | find "UDP" } # List TCP sockets in use def lsockt [] { sudo lsof -nP | jc --lsof | from json | find "TCP" } # Print timestamp as %FT%T%:z def tstampz [] { date now | format date "%FT%T%:z" } # Create new directory and enter it def --env mkd [path] { mkdir $path; cd $path } # Display pid info of command def pids [cmd] { ps | where name == "$cmd" } # Get time in specific time zone def whattimein [string] { date now | date to-timezone $string } # cd to home and clear screen def --env rsrc [] { cd $env.HOME; clear } # Convert filename to given case # Ex. caseify camel hello_world.txt # => helloWorld.txt # Based on https://github.com/nushell/nu_scripts/blob/main/sourced/cool-oneliners/file_convert_naming_case.nu def caseify [case: string, filename: path] { let ext = (echo $filename | path parse | get extension) let cur_stem = (echo $filename | path parse | get stem) let new_name = match $case { "camel" => (((echo $cur_stem | str camel-case) + "." + $ext) | str join), "kebab" => (((echo $cur_stem | str kebab-case) + "." + $ext) | str join), "lower" => (((echo $cur_stem | str downcase) + "." + $ext) | str join), "pascal" => (((echo $cur_stem | str pascal-case) + "." + $ext) | str join), "screamsnake" => (((echo $cur_stem | str screaming-snake-case) + "." + $ext) | str join), "snake" => (((echo $cur_stem | str snake-case) + "." + $ext) | str join), _ => "Invalid case option" } mv $filename $new_name } # weather use ~/.config/nushell/modules/get-weather.nu get_weather export alias weather = get_weather # ultimate-extractor use ~/.config/nushell/modules/ultimate-extractor.nu extract def x [path] { extract $path } # ssh use ~/.config/nushell/modules/ssh.nu def nussh [] { let ssh_host = (ssh ssh-list | get Host | input list $"(ansi yellow)Which host to SSH into?(ansi reset)") if ($ssh_host | describe) != "string" { echo "Operation cancelled" return } ssh $ssh_host } def nulicense [] { let licenses = (http get https://api.github.com/licenses) let license_name = ($licenses | get name | input list $"(ansi yellow)Choose an open source license:(ansi reset)") if ($license_name | describe) != "string" { echo "Operation cancelled" return } let license_body = (http get ($licenses | where name == $license_name).url.0).body $license_body | save --raw -f LICENSE } def yaml2json [filename: path] { let stem = (echo $filename | path parse | get stem) open --raw $filename | from yaml | to json | save --raw ($stem + ".json" | str join) } $env.config = { rm: { always_trash: true } table: { show_empty: false } keybindings: [ { name: nussh modifier: alt keycode: char_s mode: [emacs vi_normal vi_insert] event: { send: executehostcommand cmd: nussh } } ] }