I'm not quite sure what you want with your last sentence, sorry ;)
I'm assuming you want
ll to have the functionality of
ls -Alh except when it is called by
ll -f - in that case it should only list hidden directories. If that's not what you were looking for, it should be relatively easy to adjust. Just add all your flags that have special meaning to the
getopts command, and then write a case for each of those flags. The default case should always be
break, so that if you pass a flag that doesn't have a special meaning for your function, then
ls -Alh gets executed.
In any case, here's a script you can source to define a function called
ll (aliases are not powerful to do what you want). You must source, i.e.
source <script> the script, so the function gets defined. Be careful to do
unalias ll before sourcing the script or unexpected things might happen.
while getopts ":f" opt; do
case $opt in
command ls -Ald .*/
command ls -Alh "$@"
This will cause
ll -f to behave as
ls -Ald .*/ which lists all hidden directories. If you give
ll a flag that is not
-f it will default to call
ls -Alh "$@" (
$@ simply stands for "all arguments"). For example, if you write
ll -d Desktop,
ls -Alhd Desktop will get executed. If no flags are passed to
ll, it will just execute
ls -Alh "$@".