mirror of
https://codeberg.org/hyperreal/nushell-config
synced 2024-11-01 16:53:12 +01:00
Update
This commit is contained in:
parent
d84084b691
commit
cb3eaf7db3
75
config.nu
75
config.nu
@ -7,6 +7,27 @@ def 'is-installed' [ app: string ] {
|
|||||||
((which $app | length) > 0)
|
((which $app | length) > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# MODULES
|
||||||
|
#
|
||||||
|
|
||||||
|
# weather
|
||||||
|
use ~/.config/nushell/modules/get-weather.nu get_weather
|
||||||
|
|
||||||
|
# ultimate-extractor
|
||||||
|
use ~/.config/nushell/modules/ultimate-extractor.nu extract
|
||||||
|
|
||||||
|
# ssh
|
||||||
|
use ~/.config/nushell/modules/ssh.nu
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# ALIASES / CUSTOM COMMANDS
|
||||||
|
#
|
||||||
|
|
||||||
|
# weather
|
||||||
|
export alias weather = get_weather
|
||||||
|
|
||||||
# Git aliases
|
# Git aliases
|
||||||
export alias ga = git add
|
export alias ga = git add
|
||||||
export alias gcl = git clone
|
export alias gcl = git clone
|
||||||
@ -20,6 +41,12 @@ export alias grm = git rm
|
|||||||
export alias grv = git remote -v
|
export alias grv = git remote -v
|
||||||
export alias gst = git status
|
export alias gst = git status
|
||||||
|
|
||||||
|
# ls's
|
||||||
|
export alias la = ls -a
|
||||||
|
export alias ll = ls -l
|
||||||
|
export alias lal = ls -al
|
||||||
|
export alias lse = ^ls -lZ
|
||||||
|
|
||||||
# Doom Emacs
|
# Doom Emacs
|
||||||
def doomdoc [] { ~/.config/emacs/bin/doom doctor }
|
def doomdoc [] { ~/.config/emacs/bin/doom doctor }
|
||||||
def dsync [] { ~/.config/emacs/bin/doom sync }
|
def dsync [] { ~/.config/emacs/bin/doom sync }
|
||||||
@ -38,7 +65,7 @@ export alias fwrp = sudo firewall-cmd --runtime-to-permanent
|
|||||||
# Execute bash on host (atomic desktop)
|
# Execute bash on host (atomic desktop)
|
||||||
export alias hostexec = distrobox-host-exec bash
|
export alias hostexec = distrobox-host-exec bash
|
||||||
|
|
||||||
# Aliases for APT
|
# APT
|
||||||
export alias acs = sudo apt-cache search
|
export alias acs = sudo apt-cache search
|
||||||
export alias acp = sudo apt-cache policy
|
export alias acp = sudo apt-cache policy
|
||||||
export alias afs = sudo apt-file search
|
export alias afs = sudo apt-file search
|
||||||
@ -53,7 +80,7 @@ export alias agu = sudo apt update
|
|||||||
export alias agud = sudo apt update and sudo apt dist-upgrade
|
export alias agud = sudo apt update and sudo apt dist-upgrade
|
||||||
export alias agar = sudo apt autoremove
|
export alias agar = sudo apt autoremove
|
||||||
|
|
||||||
# Aliases for DNF
|
# DNF
|
||||||
export alias dnfc = sudo dnf clean all
|
export alias dnfc = sudo dnf clean all
|
||||||
export alias dnfi = sudo dnf install
|
export alias dnfi = sudo dnf install
|
||||||
export alias dnfu = sudo dnf update
|
export alias dnfu = sudo dnf update
|
||||||
@ -67,19 +94,19 @@ def pubkey [] { open --raw ~/.ssh/id_ed25519.pub | str trim | xclip -selection c
|
|||||||
def pubip [] { curl --silent ipinfo.io | from json }
|
def pubip [] { curl --silent ipinfo.io | from json }
|
||||||
|
|
||||||
# Get Mullvad info
|
# Get Mullvad info
|
||||||
def amimulvad [] { curl -sSL https://am.i.mullvad/json | from json }
|
def amimullvad [] { curl -sSL https://am.i.mullvad.net/json | from json }
|
||||||
|
|
||||||
# Uptime info
|
# Uptime info
|
||||||
def upt [] { uptime | jc --uptime | from json }
|
def upt [] { jc uptime | from json }
|
||||||
|
|
||||||
# df info
|
# df info
|
||||||
def dfj [] { df | jc --df | from json }
|
def dfj [] { jc df | from json }
|
||||||
|
|
||||||
# /etc/fstab info
|
# /etc/fstab info
|
||||||
def etc-fstab [] { open --raw /etc/fstab | jc --fstab | from json }
|
def etc-fstab [] { open --raw /etc/fstab | jc --fstab | from json }
|
||||||
|
|
||||||
# memory free info
|
# memory free info
|
||||||
def memfree [] { free | jc --free | from json }
|
def memfree [] { jc free | from json }
|
||||||
|
|
||||||
# /etc/group
|
# /etc/group
|
||||||
def etc-group [] { open --raw /etc/group | jc --group | from json }
|
def etc-group [] { open --raw /etc/group | jc --group | from json }
|
||||||
@ -88,22 +115,22 @@ def etc-group [] { open --raw /etc/group | jc --group | from json }
|
|||||||
def etc-passwd [] { open --raw /etc/passwd | jc --passwd | from json }
|
def etc-passwd [] { open --raw /etc/passwd | jc --passwd | from json }
|
||||||
|
|
||||||
# Network connections
|
# Network connections
|
||||||
def netcons [] { lsof -i | jc --lsof | from json }
|
def netcons [] { jc lsof -i | from json }
|
||||||
|
|
||||||
# Ports
|
# Ports
|
||||||
def tulp [] { ss -tulp | jc --ss | from json }
|
def tulp [] { jc ss -tulp | from json }
|
||||||
|
|
||||||
# Open ports
|
# Open ports
|
||||||
def openports [] { sudo lsof -i | jc --lsof | from json | find "LISTEN" }
|
def openports [] { sudo jc lsof -i | from json | find "LISTEN" }
|
||||||
|
|
||||||
# List sockets in use
|
# List sockets in use
|
||||||
def lsock [] { sudo lsof -i P | jc --lsof | from json }
|
def lsock [] { sudo jc lsof -nP | from json }
|
||||||
|
|
||||||
# List UDP sockets in use
|
# List UDP sockets in use
|
||||||
def lsocku [] { sudo lsof -nP | jc --lsof | from json | find "UDP" }
|
def lsocku [] { sudo jc lsof -nP | from json | find "UDP" }
|
||||||
|
|
||||||
# List TCP sockets in use
|
# List TCP sockets in use
|
||||||
def lsockt [] { sudo lsof -nP | jc --lsof | from json | find "TCP" }
|
def lsockt [] { sudo jc lsof -nP | from json | find "TCP" }
|
||||||
|
|
||||||
# Print timestamp as %FT%T%:z
|
# Print timestamp as %FT%T%:z
|
||||||
def tstampz [] { date now | format date "%FT%T%:z" }
|
def tstampz [] { date now | format date "%FT%T%:z" }
|
||||||
@ -120,6 +147,9 @@ def whattimein [string] { date now | date to-timezone $string }
|
|||||||
# cd to home and clear screen
|
# cd to home and clear screen
|
||||||
def --env rsrc [] { cd $env.HOME; clear }
|
def --env rsrc [] { cd $env.HOME; clear }
|
||||||
|
|
||||||
|
# extract
|
||||||
|
def x [filename: path] { extract $filename }
|
||||||
|
|
||||||
# Convert filename to given case
|
# Convert filename to given case
|
||||||
# Ex. caseify camel hello_world.txt
|
# Ex. caseify camel hello_world.txt
|
||||||
# => helloWorld.txt
|
# => helloWorld.txt
|
||||||
@ -139,26 +169,17 @@ def caseify [case: string, filename: path] {
|
|||||||
mv $filename $new_name
|
mv $filename $new_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# weather
|
# Select a host to SSH into
|
||||||
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 [] {
|
def nussh [] {
|
||||||
let ssh_host = (ssh ssh-list | get Host | input list $"(ansi yellow)Which host to SSH into?(ansi reset)")
|
let ssh_host = (ssh ssh-list | get Host | input list $"(ansi yellow)Which host to SSH into?(ansi reset)")
|
||||||
if ($ssh_host | describe) != "string" {
|
if ($ssh_host | describe) != "string" {
|
||||||
echo "Operation cancelled"
|
echo "Operation cancelled"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ssh $ssh_host
|
autossh -M 0 $ssh_host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Select an open source license and save to LICENSE in current working directory
|
||||||
def nulicense [] {
|
def nulicense [] {
|
||||||
let licenses = (http get https://api.github.com/licenses)
|
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)")
|
let license_name = ($licenses | get name | input list $"(ansi yellow)Choose an open source license:(ansi reset)")
|
||||||
@ -170,11 +191,17 @@ def nulicense [] {
|
|||||||
$license_body | save --raw -f LICENSE
|
$license_body | save --raw -f LICENSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Convert YAML to JSON
|
||||||
def yaml2json [filename: path] {
|
def yaml2json [filename: path] {
|
||||||
let stem = (echo $filename | path parse | get stem)
|
let stem = (echo $filename | path parse | get stem)
|
||||||
open --raw $filename | from yaml | to json | save --raw ($stem + ".json" | str join)
|
open --raw $filename | from yaml | to json | save --raw ($stem + ".json" | str join)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Download a file with httpie
|
||||||
|
def htdl [url: string] {
|
||||||
|
^http -d $url
|
||||||
|
}
|
||||||
|
|
||||||
$env.config = {
|
$env.config = {
|
||||||
rm: {
|
rm: {
|
||||||
always_trash: true
|
always_trash: true
|
||||||
|
5
env.nu
5
env.nu
@ -98,7 +98,8 @@ $env.NU_PLUGIN_DIRS = [
|
|||||||
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
|
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Doom Emacs
|
||||||
|
$env.DOOMDIR = ($env.HOME | path join 'sync/doom')
|
||||||
|
|
||||||
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
||||||
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
||||||
let gopath = ($env.HOME + '/go/bin' | str join)
|
|
||||||
$env.PATH = ($env.PATH | split row (char esep) | prepend $gopath)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user