From e7764f9b08072cfb67c2d3ecf075df9a80aee6fd Mon Sep 17 00:00:00 2001 From: Deposite Pirate Date: Sun, 12 Jan 2025 14:40:33 +0100 Subject: Import config. --- .gitignore | 3 + conf.d/00functions.fish | 36 +++++++++++ conf.d/00paths.fish | 3 + conf.d/01common.fish | 15 +++++ conf.d/03freebsd.fish | 22 +++++++ conf.d/03linux.fish | 52 ++++++++++++++++ conf.d/03macos.fish | 11 ++++ conf.d/03netbsd.fish | 20 +++++++ conf.d/03openbsd.fish | 27 +++++++++ conf.d/04editor.fish | 47 +++++++++++++++ conf.d/04package.fish | 140 +++++++++++++++++++++++++++++++++++++++++++ conf.d/04pager.fish | 53 ++++++++++++++++ conf.d/05browser.fish | 30 ++++++++++ conf.d/05gopher.fish | 13 ++++ conf.d/05graphics.fish | 11 ++++ conf.d/05z.fish | 29 +++++++++ functions/chext.fish | 12 ++++ functions/fish_greeting.fish | 27 +++++++++ functions/fish_prompt.fish | 27 +++++++++ functions/mcd.fish | 4 ++ functions/mkhomedirs.fish | 24 ++++++++ functions/rchmod.fish | 11 ++++ functions/renlow.fish | 21 +++++++ functions/shcmds.fish | 57 ++++++++++++++++++ functions/test-net.fish | 58 ++++++++++++++++++ themes/wip.theme | 37 ++++++++++++ 26 files changed, 790 insertions(+) create mode 100644 .gitignore create mode 100644 conf.d/00functions.fish create mode 100644 conf.d/00paths.fish create mode 100644 conf.d/01common.fish create mode 100644 conf.d/03freebsd.fish create mode 100644 conf.d/03linux.fish create mode 100644 conf.d/03macos.fish create mode 100644 conf.d/03netbsd.fish create mode 100644 conf.d/03openbsd.fish create mode 100644 conf.d/04editor.fish create mode 100644 conf.d/04package.fish create mode 100644 conf.d/04pager.fish create mode 100644 conf.d/05browser.fish create mode 100644 conf.d/05gopher.fish create mode 100644 conf.d/05graphics.fish create mode 100644 conf.d/05z.fish create mode 100644 functions/chext.fish create mode 100644 functions/fish_greeting.fish create mode 100644 functions/fish_prompt.fish create mode 100644 functions/mcd.fish create mode 100644 functions/mkhomedirs.fish create mode 100644 functions/rchmod.fish create mode 100644 functions/renlow.fish create mode 100644 functions/shcmds.fish create mode 100644 functions/test-net.fish create mode 100644 themes/wip.theme diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f5bbdaf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.fish +fish_variables +fishd.* diff --git a/conf.d/00functions.fish b/conf.d/00functions.fish new file mode 100644 index 0000000..f390b29 --- /dev/null +++ b/conf.d/00functions.fish @@ -0,0 +1,36 @@ +function alias_if --description "Alias if a program exists" + if test (count $argv) -lt 2 + return + end + if command -sq $argv[1] + if test (count $argv) -gt 2 + alias $argv[2] "$argv[1] $argv[3..-1]" + else + alias $argv[2] "$argv[1]" + end + end +end + +function alias_if_not --description "Alias if a program doesn't exist" + if test (count $argv) -lt 2 + return + end + if not command -sq $argv[1] + if test (count $argv) -gt 2 + alias $argv[1] "$argv[2] $argv[3..-1]" + else + alias $argv[1] "$argv[2]" + end + end +end + +function find_prog --description "Find one or more programs in \$PATH" + for prog in $argv + for search_path in $PATH + if test -x "$search_path/$prog" + echo -n "$prog" + return + end + end + end +end diff --git a/conf.d/00paths.fish b/conf.d/00paths.fish new file mode 100644 index 0000000..ddab1fd --- /dev/null +++ b/conf.d/00paths.fish @@ -0,0 +1,3 @@ +if test -d '/opt/homebrew/bin'; and string match -q -e 'Darwin' (uname) + fish_add_path --prepend --global --path '/opt/homebrew/bin' +end diff --git a/conf.d/01common.fish b/conf.d/01common.fish new file mode 100644 index 0000000..2d93d9c --- /dev/null +++ b/conf.d/01common.fish @@ -0,0 +1,15 @@ +if status is-interactive + +alias_if doas sudo + +alias l 'ls' +alias du 'du -h' +alias md 'mkdir' +alias rd 'rmdir' + +if command -sq tree + alias lta 'tree -a' + alias llta 'tree -apugsh' +end + +end diff --git a/conf.d/03freebsd.fish b/conf.d/03freebsd.fish new file mode 100644 index 0000000..b81eb2f --- /dev/null +++ b/conf.d/03freebsd.fish @@ -0,0 +1,22 @@ +if status is-interactive; and string match -q -e 'FreeBSD' (uname) + +alias nproc "sysctl -n hw.ncpu" +alias free "vmstat" +alias lsusb "usbconfig list" +alias lspci "pciconf -lv" +alias lsmod "kldstat" +alias insmod "kldload" + +if command -sq colorls + alias ls 'colorls -G -F' + alias ll 'colorls -G -F -l' + alias la 'colorls -G -F -a' + alias lla 'colorls -G -F -l -a' +else + alias ls 'ls -F' + alias la 'ls -F -a' + alias ll 'ls -F -l' + alias lla 'ls -F -l -a' +end + +end diff --git a/conf.d/03linux.fish b/conf.d/03linux.fish new file mode 100644 index 0000000..9822da4 --- /dev/null +++ b/conf.d/03linux.fish @@ -0,0 +1,52 @@ +if status is-interactive; and string match -q -e 'Linux' (uname) + +if command -sq dircolors; and test -f ~/.config/dircolors + eval (dircolors -c ~/.config/dircolors) +end + +alias ls 'ls --color=auto -F' +alias la 'ls --color=auto -F -a' +alias ll 'ls --color=auto -F -l' +alias lla 'ls --color=auto -F -l -a' + +alias grep 'grep --color=auto' +alias diff 'diff --color=auto' + +alias ff 'find . -type f -name' +alias fd 'find . -type d -name' +alias fbs 'find . -xtype l' + +alias who 'who -H -w -u' + +alias free 'free -h' +alias df 'df -Th' +alias ps 'ps -ejH' +alias lsof 'lsfd' + +# If we have iproute2 +if command -sq ip + alias ip "ip -c" + alias sockstat "ss -4 -6 -l -r -p" + + alias_if_not route ip route + alias_if_not ifconfig ip link + alias_if_not netstat ss -4 -6 -l -r -p +end + +# If we have systemd +if command -sq systemctl + alias pss "systemd-cgls" + alias ipconfig "networkctl -a status" + + if not fish_is_root_user + alias showdnscache "sudo resolvectl show-cache" + alias cleardnscache "sudo resolvectl flush-caches" + else + alias showdnscache "resolvectl show-cache" + alias cleardnscache "resolvectl flush-caches" + end + + alias_if_not nslookup systemd-resolve +end + +end diff --git a/conf.d/03macos.fish b/conf.d/03macos.fish new file mode 100644 index 0000000..41e58d4 --- /dev/null +++ b/conf.d/03macos.fish @@ -0,0 +1,11 @@ +if status is-interactive; and string match -q -e 'Darwin' (uname) + +alias ff "find . -type f -name" +alias fd "find . -type d -name" +alias grep "grep --color=auto" + +alias nproc "sysctl -n hw.ncpu" +alias lsblk "diskutil list" +alias route "netstat -nr" + +end diff --git a/conf.d/03netbsd.fish b/conf.d/03netbsd.fish new file mode 100644 index 0000000..e2248a7 --- /dev/null +++ b/conf.d/03netbsd.fish @@ -0,0 +1,20 @@ +if status is-interactive; and string match -q -e 'NetBSD' (uname) + +alias nproc "sysctl -n hw.ncpu" +alias free "vmstat" +alias lsusb "usbdevs" +alias lspci "pcictl pci0 list" + +if command -sq colorls + alias ls 'colorls -G -F' + alias ll 'colorls -G -F -l' + alias la 'colorls -G -F -a' + alias lla 'colorls -G -F -l -a' +else + alias ls 'ls -F' + alias la 'ls -F -a' + alias ll 'ls -F -l' + alias lla 'ls -F -l -a' +end + +end diff --git a/conf.d/03openbsd.fish b/conf.d/03openbsd.fish new file mode 100644 index 0000000..a6f773a --- /dev/null +++ b/conf.d/03openbsd.fish @@ -0,0 +1,27 @@ +if status is-interactive; and string match -q -e 'OpenBSD' (uname) + +alias nproc 'sysctl -n hw.ncpu' +alias free 'vmstat' +alias lsof 'fstat' +alias lsblk 'sysctl hw.disknames' +alias lspci 'pcidump' + +alias ff 'find . -type f -name' +alias fd 'find . -type d -name' +alias fbs 'find . -type l' + +alias route 'netstat -nr' + +if command -sq colorls + alias ls 'colorls -G -F' + alias ll 'colorls -G -F -l' + alias la 'colorls -G -F -a' + alias lla 'colorls -G -F -l -a' +else + alias ls 'ls -F' + alias la 'ls -F -a' + alias ll 'ls -F -l' + alias lla 'ls -F -l -a' +end + +end diff --git a/conf.d/04editor.fish b/conf.d/04editor.fish new file mode 100644 index 0000000..a7aaa48 --- /dev/null +++ b/conf.d/04editor.fish @@ -0,0 +1,47 @@ +if status is-interactive + +# Text editors to look for by order of preference +set -f editors 'nvim' 'vim' 'vi' 'micro' 'nano' + +# Find a suitable text editor +set -f found_editor (find_prog $editors) + +if test -n "$found_editor" + + switch $found_editor + case 'nvim' + alias vi nvim + alias vim nvim + alias vicfg 'nvim ~/.config/nvim/init.vim' + alias vipcfg 'nvim ~/.config/nvim/plugins' + case 'vim' + alias vi vim + alias nvim vim + alias vicfg 'vim ~/.config/vim/init.vim' + alias vipcfg 'vim ~/.config/vim/plugins' + case 'vi' + alias vim vi + alias nvim vi + end + + alias e $found_editor + + # If $EDITOR is unset, set it + if test -z "$EDITOR" + set -x EDITOR $found_editor + end + +end + +if command -sq neovide + alias xvi neovide + alias gvi neovide + alias xeditor neovide +end + +alias_if nano edit +alias_if micro edit + +alias cfg 'editor ~/.config/fish/config.fish' + +end diff --git a/conf.d/04package.fish b/conf.d/04package.fish new file mode 100644 index 0000000..20e0e16 --- /dev/null +++ b/conf.d/04package.fish @@ -0,0 +1,140 @@ +if status is-interactive + +function handle_linux + +# If we have pacman +if command -sq pacman + + alias lspkg 'pacman -Q --color=always | rawpager' + alias lspkgi 'pacman -Qett --color=always | rawpager' + alias lspkgo 'pacman -Qdt' + alias pkginfo 'pacman -Qi' + alias pkgsearch 'pacman -Ss' + alias whatpkg 'pacman -Qo' + + if fish_is_root_user + alias pkgadd 'pacman -S' + alias pkgrm 'pacman -Rs' + alias pkgupd 'pacman -Syyu' + alias pkgclean 'paccache -k 0 -r' + alias confnew 'find /etc -type f -name "*.pacnew"' + else + alias pkgadd 'sudo pacman -S' + alias pkgrm 'sudo pacman -Rs' + alias pkgupd 'sudo pacman -Syyu' + alias pkgclean 'sudo paccache -k 0 -r' + alias confnew 'sudo find /etc -type f -name "*.pacnew"' + end + + function is-installed + pacman -Qq $argv &>/dev/null + end +end + +# If we have apk + +end + +function handle_macos + +# If we have Homebrew +if command -sq brew + alias lspkg 'brew list ; echo ; brew info' + alias pkginfo 'brew info' + alias pkgsearch 'brew search' + + alias pkgadd 'brew install' + alias pkgrm 'brew uninstall' + alias pkgupd 'brew update ; echo ; brew upgrade' +end + +# If we have MacPorts +if command -sq port + alias lspkg 'port installed' + alias lspkgo 'port list rleaves' + alias pkginfo 'port info' + alias pkgsearch 'port search' + + if fish_is_root_user + alias pkgadd 'port install' + alias pkgrm 'port uninstall' + alias pkgupd 'port upgrade outdated' + else + alias pkgadd 'sudo port install' + alias pkgrm 'sudo port uninstall' + alias pkgupd 'sudo port upgrade outdated' + end +end + +end + +function handle_openbsd + alias lspkg 'pkg_info -A' + alias lspkgo 'pkg_info -t' + alias pkginfo 'pkg_info' + alias pkgsearch 'pkg_info -Q' + + if fish_is_root_user + alias pkgadd 'pkg_add' + alias pkgrm 'pkg_delete' + alias pkgupd 'pkg_add -u' + else + alias pkgadd 'doas pkg_add' + alias pkgrm 'doas pkg_delete' + alias pkgupd 'doas pkg_add -u' + end + +end + +function handle_netbsd + + alias lspkg 'pkgin list' + alias pkginfo 'pkgin pkg-descr' + alias pkgsearch 'pkgin search' + + if fish_is_root_user + alias pkgadd 'pkgin install' + alias pkgrm 'pkgin remove' + alias pkgupd 'pkgin upgrade' + alias pkgclean 'pkgin clean' + else + alias pkgadd 'doas pkgin install' + alias pkgrm 'doas pkgin remove' + alias pkgupd 'doas pkgin upgrade' + alias pkgclean 'doas pkgin clean' + end + +end + +function handle_freebsd + + alias pkginfo 'pkg info' + + if fish_is_root_user + alias pkgadd 'pkg install' + alias pkgrm 'pkg remove' + alias pkgupd 'pkg upgrade' + alias pkgclean 'pkg clean -a' + else + alias pkgadd 'doas pkg install' + alias pkgrm 'doas pkg remove' + alias pkgupd 'doas pkg upgrade' + alias pkgclean 'doas pkg clean -a' + end + +end + +switch (uname) + case 'Linux' + handle_linux + case 'Darwin' + handle_macos + case 'OpenBSD' + handle_openbsd + case 'NetBSD' + handle_netbsd + case 'FreeBSD' + handle_freebsd +end + +end diff --git a/conf.d/04pager.fish b/conf.d/04pager.fish new file mode 100644 index 0000000..688747b --- /dev/null +++ b/conf.d/04pager.fish @@ -0,0 +1,53 @@ +if status is-interactive + +# Pagers to look for by order of preference +set -f pagers 'moar' 'less' 'most' 'more' + +# Find a suitable pager +set -f found_pager (find_prog $pagers) + +if test -n "$found_pager" + + switch $found_pager + case 'moar' + set -x MOAR '--colors=auto --no-linenumbers' + alias less 'moar' + alias most 'moar' + alias more 'moar' + alias pager 'moar' + alias rawpager 'moar' + case 'less' + if test -z "$LESSHISTFILE" + set -x LESSHISTFILE '-' + end + alias most 'less' + alias more 'less' + alias pager 'less' + alias rawpager 'less -r' + case 'most' + if test -z "$MOST_INITFILE" + set -x MOST_INITFILE "$HOME/.config/most/config" + end + alias more 'most' + alias less 'most' + alias pager 'most' + alias rawpager 'most' + case 'more' + alias less 'more' + alias most 'more' + alias pager 'more' + alias rawpager 'more' + end + + if command -sq 'bat' + set -x MANROFFOPT '-c' + set -x MANPAGER 'fish -c "col -bx | bat -l man -p"' + end + + # If $PAGER is unset, set it + if test -z "$PAGER" + set -x PAGER $found_pager + end +end + +end diff --git a/conf.d/05browser.fish b/conf.d/05browser.fish new file mode 100644 index 0000000..4266374 --- /dev/null +++ b/conf.d/05browser.fish @@ -0,0 +1,30 @@ +if status is-interactive; and not fish_is_root_user + +if test -z "$HOMEPAGE" + set -x HOMEPAGE "https://html.duckduckgo.com" +end + +# Console browser to look for by order of preference +set -f browsers 'links' 'w3m' 'elinks' 'lynx' + +# Find a suitable console web browser +set -f found_browser (find_prog $browsers) + +if test -n "$found_browser" + + # If $BROWSER is unset, set it + if test -z "$BROWSER" + set -x BROWSER $found_browser + end + + function www --description "Browse the WWW" + if test -z $argv + $BROWSER $HOMEPAGE + return + end + + $BROWSER $argv + end +end + +end diff --git a/conf.d/05gopher.fish b/conf.d/05gopher.fish new file mode 100644 index 0000000..d1526d6 --- /dev/null +++ b/conf.d/05gopher.fish @@ -0,0 +1,13 @@ +if status is-interactive; and not fish_is_root_user + +# Console gopher browser to look for by order of preference +set -f browsers 'ncgopher' + +# Find a suitable console web browser +set -f found_browser (find_prog $browsers) + +if test -n "$found_browser" + alias gopher "$found_browser" +end + +end diff --git a/conf.d/05graphics.fish b/conf.d/05graphics.fish new file mode 100644 index 0000000..8f801e2 --- /dev/null +++ b/conf.d/05graphics.fish @@ -0,0 +1,11 @@ +if status is-interactive; and not fish_is_root_user + +set -f imgviewers 'viu' 'timg' + +set -f found_imgviewer (find_prog $imgviewers) + +if test -n "$found_imgviewer" + alias see "$found_imgviewer" +end + +end diff --git a/conf.d/05z.fish b/conf.d/05z.fish new file mode 100644 index 0000000..1a7c516 --- /dev/null +++ b/conf.d/05z.fish @@ -0,0 +1,29 @@ +if status is-interactive + +if command -sq bsdtar + alias uz 'bsdtar -xf' + alias mz 'bsdtar -a -cf' + + if not command -sq unrar + alias unrar 'bsdtar -xf' + end + + if not command -sq 7za + alias 7za 'bsdtar -xf' + end + +end + +# If we have more than one CPU core, use threaded uncompression. +if command -sq nproc + if test (nproc) -gt 1 + alias_if xz xz -T 0 + alias_if unxz unxz -T 0 + alias_if unpigz gunzip + alias_if parunzip unzip + alias_if pbzip2 bzip2 + alias_if bzip3 bzip3 -j (nproc) + end +end + +end diff --git a/functions/chext.fish b/functions/chext.fish new file mode 100644 index 0000000..5f8132f --- /dev/null +++ b/functions/chext.fish @@ -0,0 +1,12 @@ +function chext --description 'Change extension of files with an extension' -a sourceext -a targetext + +if test (count $argv) -lt 2 + echo 'Missing argument.' + return 1 +end + +for file in *.$sourceext + echo mv $file (path change-extension $targetext $file) +end + +end diff --git a/functions/fish_greeting.fish b/functions/fish_greeting.fish new file mode 100644 index 0000000..2c8193d --- /dev/null +++ b/functions/fish_greeting.fish @@ -0,0 +1,27 @@ +function fish_greeting + + if not set -q TMUX + + if set -q SSH_CONNECTION + if command -sq fastfetch + fastfetch -c paleofetch.jsonc + end + + if command -sq bsdfetch + bsdfetch + end + end + + if command -sq fortune + if string match -q -e 'Linux' (uname) + echo + fortune linux + echo + else + fortune + end + end + + end + +end diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish new file mode 100644 index 0000000..2504066 --- /dev/null +++ b/functions/fish_prompt.fish @@ -0,0 +1,27 @@ +function fish_prompt --description 'Write out the prompt' + set -l last_pipestatus $pipestatus + set -l last_status $status + set -l normal (set_color normal) + + # Color the prompt differently when we're root + set -l color_cwd $fish_color_cwd + set -l prefix + set -l suffix '>' + if contains -- $USER root toor + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + end + set suffix '#' + end + + # If we're running via SSH, change the host color. + set -l color_host $fish_color_host + if set -q SSH_TTY + set color_host $fish_color_host_remote + end + + # Write pipestatus + set -l prompt_status (__fish_print_pipestatus " [" "]" "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus) + + echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $color_host) (prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal $prompt_status $suffix " " +end diff --git a/functions/mcd.fish b/functions/mcd.fish new file mode 100644 index 0000000..2533622 --- /dev/null +++ b/functions/mcd.fish @@ -0,0 +1,4 @@ +function mcd --description 'Make and cd to a directory' + mkdir -p "$argv" + cd "$argv" +end diff --git a/functions/mkhomedirs.fish b/functions/mkhomedirs.fish new file mode 100644 index 0000000..7052baf --- /dev/null +++ b/functions/mkhomedirs.fish @@ -0,0 +1,24 @@ +function mkhomedirs --description 'Make common directories in $HOME' + +set -f saveumask (umask) +umask 0077 + +mkdir -p \ + ~/Config \ + ~/.config/fish/conf.d \ + ~/.config/fish/functions \ + ~/.local/bin \ + ~/.local/share/nvim/site/pack/local/start \ + ~/.gnupg + +if string match -q -e 'Linux' (uname) + +mkdir -p \ + ~/.local/share/applications \ + ~/.config/systemd/user + +end + +umask $saveumask + +end diff --git a/functions/rchmod.fish b/functions/rchmod.fish new file mode 100644 index 0000000..b54348f --- /dev/null +++ b/functions/rchmod.fish @@ -0,0 +1,11 @@ +function rchmod --description 'Recursively reset premissions of files and folders' + +if not command -sq 'find' + echo "Can't find find." + return 1 +end + +find . -type d -exec chmod 755 {} + +find . -type f -exec chmod 644 {} + + +end diff --git a/functions/renlow.fish b/functions/renlow.fish new file mode 100644 index 0000000..98b0e4c --- /dev/null +++ b/functions/renlow.fish @@ -0,0 +1,21 @@ +function renlow --description 'Rename all files and directories with lowercase characters' + +if not command -sq 'find' + echo "Can't find find." + return 1 +end + +for file in (find . -type f) + set -l element (string split -r -m1 / $file) + mv $file $element[1]/(string lower $element[2]) +end + +set -f dirs (find . -type d) +for dir in $dirs[-1..1] # Rename directories in reverse order + set -l element (string split -r -m1 / $dir) + if not test -z $element[2] # Catch . + mv $dir $element[1]/(string lower $element[2]) + end +end + +end diff --git a/functions/shcmds.fish b/functions/shcmds.fish new file mode 100644 index 0000000..c75b654 --- /dev/null +++ b/functions/shcmds.fish @@ -0,0 +1,57 @@ +function shcmds --description "View installed useful command line programs" + +if not functions -q is-installed + echo "No is-installed function defined." + return 1 +end + +set -f compress 'libarchive' 'bzip3' 'p7zip' 'unrar' +set -f crypt 'age' +set -f shell 'exa' 'tmux' 'walk' 'moar' 'most' 'fcp' 'b3sum' +set -f editor 'neovim' 'micro' 'nano' +set -f file 'mc' 'nnn' +set -f bin 'hexyl' +set -f text 'bat' 'ripgrep' 'sd' 'ugrep' 'grex' 'since' 'difftastic' 'vbindiff' +set -f sys 'htop' 'btop' 'duf' 'ncdu' 'procs' +set -f sec 'hashcat' +set -f img 'viu' 'timg' +set -f markdown 'glow' 'mdcat' +set -f db 'csview' 'textql' +set -f dev 'strace' 'lurk' +set -f www 'links' +set -f mail 'aerc' +set -f gopher 'ncgopher' +set -f gemini 'clagrange' 'amfora' 'ncgopher' +set -f tox 'toxic' +set -f ftp 'lftp' +set -f http 'curlie' 'xh' 'hurl' +set -f mirror 'wget' 'gemget' 'httrack' 'crawley' +set -f dns 'doggo' 'dog' +set -f netmon 'bandwhich' 'iftop' 'netscanner' 'trippy' +set -f netsec 'nmap' 'ngrep' 'rustscan' +set -f sync 'rsync' +set -f man 'tldr' +set -f sound 'sox' 'mp3gain' +set -f graphics 'graphicsmagick' +set -f xorg 'xdotool' 'yank' + +set -f -a mul $img $sound $graphics +set -f -a net $www $mail $gopher $gemini $tox $ftp $http $mirror $dns $netmon $netsec +set -f -a all $net $mul $compress $crypt $shell $editor $file $bin $text $sys $sec $markdown $db $dev $sync $man $xorg + +for element in (string join0 $all | sort -z | uniq -z | string split0) + if is-installed $element + set_color green + printf $element + set_color normal + else + set_color red + printf $element + set_color normal + end + printf ' ' +end + +printf '\n' + +end diff --git a/functions/test-net.fish b/functions/test-net.fish new file mode 100644 index 0000000..93b60aa --- /dev/null +++ b/functions/test-net.fish @@ -0,0 +1,58 @@ +function test-net --description 'Test network connectivity' + +if not command -q 'ip' + echo "Can't find ip." + return 1 +end + +if not command -q 'ping' + echo "Can't find ping." + return 1 +end + +if not command -q 'curl' + echo "Can't find curl." + return 1 +end + +set -l extipurl 'https://ifconfig.io' + +function print_header -a headertext + echo + set_color blue + echo $headertext + set_color normal + echo +end + +function print_ip -a label -a ip + echo -n $label + set_color yellow + echo $ip + set_color normal +end + +function ping_host -a host + echo + set_color green + ping -q -O -c 1 $host + set_color normal +end + +print_header "Testing local connectivity" + +set -l gateway "$(ip -c=never -o route show | awk '/default via/ {print $3}')" + +print_ip 'Gateway: ' "$gateway" +ping_host "$gateway" + +print_header "Testing internet connectivity" + +print_ip 'External IPv4 address: ' "$(curl -s -4 $extipurl)" +print_ip 'External IPv6 address: ' "$(curl -s -6 $extipurl)" + +ping_host 8.8.8.8 + +echo + +end diff --git a/themes/wip.theme b/themes/wip.theme new file mode 100644 index 0000000..f9ebfa2 --- /dev/null +++ b/themes/wip.theme @@ -0,0 +1,37 @@ +fish_color_autosuggestion '555' 'brblack' +fish_color_cancel -r +fish_color_command --bold +fish_color_comment red +fish_color_cwd brblue +fish_color_cwd_root red +fish_color_end brmagenta +fish_color_error brred +fish_color_escape 'bryellow' '--bold' +fish_color_hg_added green +fish_color_hg_clean green +fish_color_hg_copied magenta +fish_color_hg_deleted red +fish_color_hg_dirty red +fish_color_hg_modified yellow +fish_color_hg_renamed magenta +fish_color_hg_unmerged red +fish_color_hg_untracked yellow +fish_color_history_current --bold +fish_color_host yellow +fish_color_host_remote magenta --bold +fish_color_match --background=brblue +fish_color_normal normal +fish_color_operator bryellow +fish_color_param cyan +fish_color_quote yellow +fish_color_redirection brblue +fish_color_search_match 'bryellow' '--background=brblack' +fish_color_selection 'white' '--bold' '--background=brblack' +fish_color_status red +fish_color_user brgreen +fish_color_valid_path --underline +fish_pager_color_completion +fish_pager_color_description 'B3A06D' 'yellow' +fish_pager_color_prefix 'white' '--bold' '--underline' +fish_pager_color_progress 'brwhite' '--background=cyan' +fish_pager_color_selected_background -r -- cgit v1.3.1