diff options
Diffstat (limited to 'conf.d')
| -rw-r--r-- | conf.d/00functions.fish | 36 | ||||
| -rw-r--r-- | conf.d/00paths.fish | 3 | ||||
| -rw-r--r-- | conf.d/01common.fish | 15 | ||||
| -rw-r--r-- | conf.d/03freebsd.fish | 22 | ||||
| -rw-r--r-- | conf.d/03linux.fish | 52 | ||||
| -rw-r--r-- | conf.d/03macos.fish | 11 | ||||
| -rw-r--r-- | conf.d/03netbsd.fish | 20 | ||||
| -rw-r--r-- | conf.d/03openbsd.fish | 27 | ||||
| -rw-r--r-- | conf.d/04editor.fish | 47 | ||||
| -rw-r--r-- | conf.d/04package.fish | 140 | ||||
| -rw-r--r-- | conf.d/04pager.fish | 53 | ||||
| -rw-r--r-- | conf.d/05browser.fish | 30 | ||||
| -rw-r--r-- | conf.d/05gopher.fish | 13 | ||||
| -rw-r--r-- | conf.d/05graphics.fish | 11 | ||||
| -rw-r--r-- | conf.d/05z.fish | 29 |
15 files changed, 509 insertions, 0 deletions
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 |
