all repos — dotfiles-base @ 98caf2e73ce0d48b583d5f3bb4a481bd70a18572

base important configs that can safely be used almost anywhere

Add misc. fish functions
x1phosura x1phosura@x1phosura.zone
Sun, 02 Feb 2025 15:37:55 -0800
commit

98caf2e73ce0d48b583d5f3bb4a481bd70a18572

parent

9b5c5097036c1fe1dd91f26aa0d2decd6f122405

A .config/fish/functions/bin2hex.fish

@@ -0,0 +1,10 @@

+ +# Note: has a limit of like 10k or something, I forget +function bin2hex --description '' + if test (count $argv) -ne 1 + echo "usage: $(status current-command) [path of file to hexdump]" + return 1 + end + + hexdump -v -e '1/1 "%02x"' "$argv[1]" # ex. -> 48656c6c6f20... +end
A .config/fish/functions/fzvim.fish

@@ -0,0 +1,13 @@

+function fzvim --description 'Picks file path with fzf and opens in $EDITOR' + set -f file_path "$(fzf)" + + if test -f "$file_path" + echo "Editing $file_path..." + $EDITOR "$file_path" + else if test "$file_path" = "" # no entries chosen from fzf + : # do nothing + else + echo "$file_path not found." + end +end +
A .config/fish/functions/hex2bin.fish

@@ -0,0 +1,9 @@

+# Note: has a limit of like 10k or something, I forget +function hex2bin --description '' + if test (count $argv) -ne 1 + echo "usage: $(status current-command) [path of file containing hex digits to bindump]" + return 1 + end + + sed 's/\([0-9A-F]\{2\}\)/\\\\\\\x\1/gI' "$argv[1]" | xargs printf +end
A .config/fish/functions/mkcd.fish

@@ -0,0 +1,16 @@

+function mkcd --description 'Make directory and cd into it. Note: STILL has one edge case (if argument contains '..' AND goes through symlink)' + if test (count $argv) -ne 1 + return 1 + end + + #case "$1" in /*) :;; *) set -- "./$1";; esac # for weird directories "-xx/" + switch "$argv[1]" + case /* + set -f dest "$argv[1]" + case '*' + set -f dest "./$argv[1]" + end + + mkdir -p "$dest" && cd "$dest" +end +
A .config/fish/functions/printx509.fish

@@ -0,0 +1,10 @@

+function printx509 --description "Helper to pretty-print DER/PEM-encoded X.509 certificates" + if test (count $argv) -eq 0 + echo "usage: $0 [path(s) to one or more certificates to pretty-print...] " + return 1 + end + for cert in $argv + # TODO: verify filetype of certificate + openssl x509 -text -noout -in $cert + end +end
A .config/fish/functions/public-ip.fish

@@ -0,0 +1,4 @@

+function public-ip --description 'Fetch current public IP address' + curl 'http://icanhazip.com/' + #curl 'https://j3s.sh/ip.html' +end
A .config/fish/functions/scan-for-printers.fish

@@ -0,0 +1,3 @@

+function scan-for-printers --description 'Look for printers on the connected LAN' + sudo lpinfo -v +end
A .config/fish/functions/wifi-strength.fish

@@ -0,0 +1,3 @@

+function wifi-strength --description 'Get WiFi statistics in real time' + watch -n 1 cat /proc/net/wireless +end