Fix piping of logo-ls command

This commit is contained in:
Manuel Thalmann 2023-10-24 08:53:16 +02:00
parent 78e0c19d34
commit c52c8e1241

View file

@ -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;