mirror of
https://codeberg.org/hyperreal/nushell-config
synced 2024-11-01 16:53:12 +01:00
Update
This commit is contained in:
parent
c8eceb6841
commit
406b019fec
122
config.nu
122
config.nu
@ -7,6 +7,11 @@ def 'is-installed' [ app: string ] {
|
|||||||
((which $app | length) > 0)
|
((which $app | length) > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Global vars and consts
|
||||||
|
let hostn = (sys | get host.hostname)
|
||||||
|
const MODDIR = ($nu.default-config-dir | path join "modules")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# MODULES
|
# MODULES
|
||||||
#
|
#
|
||||||
@ -20,13 +25,39 @@ use ~/.config/nushell/modules/ultimate-extractor.nu extract
|
|||||||
# ssh
|
# ssh
|
||||||
use ~/.config/nushell/modules/ssh.nu
|
use ~/.config/nushell/modules/ssh.nu
|
||||||
|
|
||||||
|
# Source distro-specific modules
|
||||||
|
const DEBIAN_CONF = ($MODDIR | path join "debian.nu")
|
||||||
|
const REDHAT_CONF = ($MODDIR | path join "redhat.nu")
|
||||||
|
const DISTRO_CONFIG = if ("/etc/debian_version" | path exists) {
|
||||||
|
$DEBIAN_CONF
|
||||||
|
} else if ("/etc/redhat-release" | path exists) {
|
||||||
|
$REDHAT_CONF
|
||||||
|
} else {
|
||||||
|
$nu.env-path
|
||||||
|
}
|
||||||
|
source $DISTRO_CONFIG
|
||||||
|
|
||||||
#
|
#
|
||||||
# ALIASES / CUSTOM COMMANDS
|
# ALIASES / CUSTOM COMMANDS
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Custom commands for 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 }
|
||||||
|
|
||||||
# weather
|
# weather
|
||||||
export alias weather = get_weather
|
export alias weath = get_weather
|
||||||
|
|
||||||
|
# firewalld aliases
|
||||||
|
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
|
||||||
|
|
||||||
# Git aliases
|
# Git aliases
|
||||||
export alias ga = git add
|
export alias ga = git add
|
||||||
@ -47,54 +78,30 @@ export alias ll = ls -l
|
|||||||
export alias lal = ls -al
|
export alias lal = ls -al
|
||||||
export alias lse = ^ls -lZ
|
export alias lse = ^ls -lZ
|
||||||
|
|
||||||
# Doom Emacs
|
# Copy trimmed GPG fingerprint to clipboard
|
||||||
def doomdoc [] { ~/.config/emacs/bin/doom doctor }
|
def gpgfpr [] {
|
||||||
def dsync [] { ~/.config/emacs/bin/doom sync }
|
gpg -K --with-colons
|
||||||
def dclean [] { ~/.config/emacs/bin/doom clean }
|
| jc --gpg
|
||||||
def dcomp [] { ~/.config/emacs/bin/doom compile }
|
| from json
|
||||||
def dpurge [] { ~/.config/emacs/bin/doom purge }
|
| get 1.user_id
|
||||||
def denv [] { ~/.config/emacs/bin/doom env }
|
| xclip -sel clipboard
|
||||||
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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
# Copy SSH public key to clipboard
|
||||||
def pubkey [] { open --raw ~/.ssh/id_ed25519.pub | str trim | xclip -selection clipboard }
|
def pubkey [] {
|
||||||
|
open --raw ~/.ssh/id_ed25519.pub
|
||||||
|
| str trim
|
||||||
|
| xclip -selection clipboard
|
||||||
|
}
|
||||||
|
|
||||||
# Get public ip info
|
# Get public ip info
|
||||||
def pubip [] { curl --silent ipinfo.io | from json }
|
def pubip [] { curl --silent ipinfo.io | from json }
|
||||||
|
|
||||||
# Get Mullvad info
|
# Get Mullvad info
|
||||||
def amimullvad [] { curl -sSL https://am.i.mullvad.net/json | from json }
|
def amimullvad [] {
|
||||||
|
curl -sSL https://am.i.mullvad.net/json
|
||||||
|
| from json
|
||||||
|
}
|
||||||
|
|
||||||
# Uptime info
|
# Uptime info
|
||||||
def upt [] { jc uptime | from json }
|
def upt [] { jc uptime | from json }
|
||||||
@ -103,16 +110,28 @@ def upt [] { jc uptime | from json }
|
|||||||
def dfj [] { 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 [] { 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
|
||||||
|
}
|
||||||
|
|
||||||
# /etc/passwd
|
# /etc/passwd
|
||||||
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 [] { jc lsof -i | from json }
|
def netcons [] { jc lsof -i | from json }
|
||||||
@ -121,7 +140,11 @@ def netcons [] { jc lsof -i | from json }
|
|||||||
def tulp [] { jc ss -tulp | from json }
|
def tulp [] { jc ss -tulp | from json }
|
||||||
|
|
||||||
# Open ports
|
# Open ports
|
||||||
def openports [] { sudo jc lsof -i | 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 jc lsof -nP | from json }
|
def lsock [] { sudo jc lsof -nP | from json }
|
||||||
@ -142,7 +165,10 @@ def --env mkd [path] { mkdir $path; cd $path }
|
|||||||
def pids [cmd] { ps | where name == "$cmd" }
|
def pids [cmd] { ps | where name == "$cmd" }
|
||||||
|
|
||||||
# Get time in specific time zone
|
# Get time in specific time zone
|
||||||
def whattimein [string] { date now | date to-timezone $string }
|
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 }
|
||||||
@ -198,7 +224,7 @@ def yaml2json [filename: path] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Download a file with httpie
|
# Download a file with httpie
|
||||||
def htdl [url: string] {
|
def httpie [url: string] {
|
||||||
^http -d $url
|
^http -d $url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
env.nu
22
env.nu
@ -51,7 +51,7 @@ def is-container [] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def create_user_host [] {
|
def create_user_host [] {
|
||||||
let user_host = (ansi red) + (whoami) + (ansi reset) + '@' + (ansi blue) + (sys | get host.hostname) + (ansi reset)
|
let user_host = (ansi red) + (whoami) + (ansi reset) + '@' + (ansi "#89b4fa") + (sys | get host.hostname) + (ansi reset)
|
||||||
let container_segment = (ansi green_bold) + "⬢ " + (ansi reset)
|
let container_segment = (ansi green_bold) + "⬢ " + (ansi reset)
|
||||||
let user_host_segment = (if (is-container) { ($container_segment + $user_host) | str join } else { $user_host })
|
let user_host_segment = (if (is-container) { ($container_segment + $user_host) | str join } else { $user_host })
|
||||||
|
|
||||||
@ -99,7 +99,21 @@ $env.NU_PLUGIN_DIRS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Doom Emacs
|
# Doom Emacs
|
||||||
$env.DOOMDIR = ($env.HOME | path join 'sync/doom')
|
$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:
|
# Various paths
|
||||||
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
$env.CARGO_HOME = ($env.HOME | path join ".cargo")
|
||||||
|
|
||||||
|
# PATH
|
||||||
|
use std "path add"
|
||||||
|
path add ($env.CARGO_HOME | path join "bin")
|
||||||
|
path add ($env.HOME | path join "go" "bin")
|
||||||
|
path add ($env.HOME | path join "bin")
|
||||||
|
path add ($env.HOME | path join ".local" "bin")
|
||||||
|
path add /usr/bin
|
||||||
|
path add /usr/sbin
|
||||||
|
path add /usr/local/bin
|
||||||
|
$env.PATH = ($env.PATH | uniq)
|
||||||
|
|
||||||
|
# LS_COLORS using vivid
|
||||||
|
$env.LS_COLORS = (vivid generate catppuccin-mocha | str trim)
|
||||||
|
14
modules/debian.nu
Normal file
14
modules/debian.nu
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 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
|
6
modules/redhat.nu
Normal file
6
modules/redhat.nu
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# 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
|
Loading…
Reference in New Issue
Block a user