1

When I type in xfce4-terminal the command:

ls -pltrh --color=always --time-style="+%d-%b-%Y $newline%H:%M" | grep --color=never -v / | cut -d ' ' -f6- 
echo -e -n '\033[1;5;36m'"Diretório §⮕ " 
echo -e -n '\033[1;5;33m'
pwd
echo -e '\033[00m'

it works flawless, but I couldn't succeed to set an alias in ~/.bashrc, it gives an error regarding to | cut -d ' ' -f6- part of the command (alias not found).

How can I fix that? Or should I change completely this command?

OS: Xubuntu 16.04.6

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
  • The standard way is to just [escape the quotes](https://unix.stackexchange.com/a/30904/209677) (also [here](https://unix.stackexchange.com/a/23349/209677)). You can also use a function or [something else](https://askubuntu.com/questions/754781/alias-nested-string/754799#754799). – Pablo Bianchi May 08 '19 at 21:56
  • it should work as well, thks , but using function as xenoid suggested works perfect and no too much edit escaping quotes and so on... – vladimir pavloski May 09 '19 at 13:25

1 Answers1

2

To quote the Bash reference:

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command

So this is meant for rather simple cases. You can define this as a function in .bashrc:

function showdir {
    ls -pltrh --color=always --time-style="+%d-%b-%Y $newline%H:%M" | grep --color=never -v / | cut -d ' ' -f6- ;
    echo -e -n '\033[1;5;36m'"Diretório §⮕ " ;
    echo -e -n '\033[1;5;33m'; 
    pwd;
    echo -e '\033[00m'
}
xenoid
  • 5,376
  • 2
  • 16
  • 34