samedi 17 janvier 2015

Command prompt (PS1) including the number of files in directory (both hidden and regular entries)


I have finally come up with a favourite PS1 format but I find it takes too long to load. I need help optimizing...


The part that is slowing it down is when I call the external commands in the prompt. I simply want to show the # of entries and # of hidden files of the directory.


I followed these 2 pages as a guide to make the prompt: "External command in prompt" and "customizing bash command prompt blog". I could not get Daniel's "customizing bash command prompt blog" to work any faster than what I came up with.


I sort of combined both methods and came up with the below, which works, but not as fast as I would like...



export PS1="\[\e[2;37m\]\d \[\e[2;37m\] @ \[\e[2;37m\] \t \[\e[2;33m\]> Currently in: \[\e[0;33m\]\w [\$(ls -A | wc -l) entries and \$[\$(ls -A | wc -l) - \$(ls | wc -l)$wc -l)] are hidden] \[\e[0m\]
\[\e[2;36m\]\u\[\e[0;37m\]@\[\e[1;32m\]\h\[\e[0;33m\] \$ \[\e[0m\]"


I am open to any changes to the way of displaying the working directory and # files (both hidden and not), but please do not change even a SPACE in the rest of the prompt! Thanks :)



Aucun commentaire:

Enregistrer un commentaire