CLI script works. Alias script broke. Corrective action is?
Solution 1:
Agreed with Kamil: this code contains both single and double quotes. You'll experience quoting hell trying to force it into an alias. Use a function where you can format the commands in a sensible, readable way:
a() {
local cmd1 cmd2 cmd3 cmd4 cmd5 cmd6
clear
ls -1v -w9 -plxhSs --format=single-column --group-directories-first
cmd1=$( ls -qp | grep -c / )
cmd2=$( ls -qp | grep -vc / )
cmd3=$( ls -1 | wc -l )
tput setaf 4
pwd | tr '\n' '\000'
tput sgr0
echo "/"
tput sgr0
printf "%9d%s" $cmd1 " dirs" $cmd2 " reg.files" $cmd3 " files current" | tr '\n' ' '
tput setaf 13
echo " Ctrl-c Cancel"
sleep 1
cmd4=$( find . -type d | wc -l )
cmd5=$( find . -type f | wc -l )
cmd6=$( find . | wc -l )
tput setaf 13
printf "%9d%s" $cmd4 " dirs" $cmd5 " reg.files" $cmd6 " files reclusive"
echo " "
tput setaf 13
pwd | tr '\n' '\000'
tput sgr0
echo "/" | tr '\n' ' '
tput setaf 13
echo "+ recursive"
}