1. Code Used

1: ls --color -h --group-directories-first

2: alias p='ls --color -h --group-directories-first'

2. Example

Usually, when you type a simple ls command in the bash terminal your files will be displayed alphabetically:


If you want your files sorted with the directory listings first, you can use the following command:

ls --color -h --group-directories-first

This gives the following result:


Given that this is a pretty long command to type in constantly, you might set it as an alias:

alias p='ls --color -h --group-directories-first'

Now you can type ls for the regular (alphabetic) listing and p for the directories-first listing: