From ca8316b835874f77eb87b77f179ae470d65bea4e Mon Sep 17 00:00:00 2001 From: Deposite Pirate Date: Thu, 4 Dec 2025 21:35:59 +0100 Subject: Refactor ls handling Refactor ls handling and integrate eza. modified: conf.d/02platform.fish --- conf.d/02platform.fish | 93 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 26 deletions(-) (limited to 'conf.d') diff --git a/conf.d/02platform.fish b/conf.d/02platform.fish index a3c8e69..bd0f9f8 100644 --- a/conf.d/02platform.fish +++ b/conf.d/02platform.fish @@ -1,6 +1,6 @@ if status is-interactive - ### Functions + ## Functions function handle_colorls if command -sq colorls @@ -16,30 +16,41 @@ if status is-interactive end end - ### All platforms - - alias_if doas sudo - - alias l 'ls' - alias md 'mkdir' - alias rd 'rmdir' - alias du 'du -h' - - if command -sq tree - alias lta 'tree -a' - alias llta 'tree -apugsh' - end - - if command -sq git - alias fishupd 'pushd ~/.config/fish ; git pull ; popd' - end - - # process viewer to look for by order of preference - set topprg 'htop' 'btop' - set found_topprg (find_prog $topprg) - - if test -n "$found_topprg" - alias top "$found_topprg" + function handle_eza + switch $TERM + case 'xterm-256color' + set -f icons 'yes' + case 'xterm-ghostty' + set -f icons 'yes' + case 'xterm-kitty' + set -f icons 'yes' + case 'tmux-256color' + set -f icons 'yes' + case 'foot' + set -f icons 'yes' + case 'xterm' + set -f icons 'no' + case '*' + set -f icons 'no' + end + + if string match -q -e 'XTerm/OpenBSD' $XTERM_VERSION + set -f icons 'no' + end + + if string match -q -e 'yes' $icons + alias ls 'eza --icons --group' + alias la 'eza --icons --all' + else + alias ls 'eza --group' + alias la 'eza --all' + end + + alias ll 'eza --long --group' + alias lt 'eza --tree' + alias lta 'eza --all --tree' + alias lla 'eza --all --long --group' + alias llta 'eza --all --tree --long --group' end ### Linux @@ -295,7 +306,7 @@ if status is-interactive alias pkgclean 'doas pkg clean -a' end - end # handle_openbsd + end # handle_freebsd switch (uname) case 'Linux' @@ -310,4 +321,34 @@ if status is-interactive handle_freebsd end + ## All platforms + + if command -sq 'eza' + handle_eza + else + if command -sq tree + alias lta 'tree -a' + alias llta 'tree -apugsh' + end + end + + alias l 'ls' + alias md 'mkdir' + alias rd 'rmdir' + alias du 'du -h' + + alias_if doas sudo + + if command -sq git + alias fishupd 'pushd ~/.config/fish ; git pull ; popd' + end + + # process viewer to look for by order of preference + set topprg 'htop' 'btop' + set found_topprg (find_prog $topprg) + + if test -n "$found_topprg" + alias top "$found_topprg" + end + end -- cgit v1.3.1