From c52c8e12419b471cb975f889fb0411440d459c7c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 24 Oct 2023 08:53:16 +0200 Subject: [PATCH] Fix piping of `logo-ls` command --- scripts/Common/Config/logo-ls/install.sh | 38 ++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/scripts/Common/Config/logo-ls/install.sh b/scripts/Common/Config/logo-ls/install.sh index 5e197f8e..b82179bc 100755 --- a/scripts/Common/Config/logo-ls/install.sh +++ b/scripts/Common/Config/logo-ls/install.sh @@ -1,14 +1,46 @@ #!/bin/bash configFile="/etc/fish/conf.d/logo-ls.fish"; +functionName="_PortValhalla_ls_"; -{ +function dump_header() { echo "# logo-ls"; - echo "alias ls='logo-ls -D'"; +} + +function dump_aliases() { + echo "alias ls='$functionName'"; echo "alias ll='ls -al'"; echo "alias l='ls'"; +} + +{ + dump_header; + echo "function $functionName"; + echo " if [ -t 1 ]"; + echo ' logo-ls -D $argv;'; + echo " else"; + echo " alias ls=ls;"; + echo ' ls --color=auto $argv;'; + echo " alias ls='$functionName';"; + echo " end"; + echo "end"; + echo ""; + dump_aliases; } | sudo tee "$configFile" > /dev/null; if ! grep "\blogo-ls\b" ~/.bashrc > /dev/null then - cat "$configFile" | tee -a ~/.bashrc > /dev/null; + { + echo ""; + dump_header; + echo "function ${functionName}() {"; + echo " if [ -t 1 ]"; + echo " then"; + echo ' logo-ls -D "$@";'; + echo " else"; + echo ' ls --color=auto "$@";' + echo " fi;" + echo "}"; + echo ""; + dump_aliases; + } | tee -a ~/.bashrc > /dev/null; fi;