Search code examples
ubuntuserverdebianlsnano

Color Highlighting for commands (Ubuntu Highlighting to Debian)?


So I have a Debian 10 server and a Ubuntu 18.04.3 LTS server but with the Ubuntu 18.04.3 LTS server it has color highlighting with ls, nano, etc. but with Debian 10 server it doesn't so is it possible to add Ubuntu 18.04.3 LTS server syntax highlighting and color highlighting for the commands on Debian 10 because I've looked up countless threads and none of them work


Solution

  • You must first know that colors are somehow spoiled under linux users.

    The colors on the output of ls are set in the /etc/DIR_COLORS file. But you said you are looking for nano to be colored.

    To tune up your nano you must edit (or touch if it does not exist) your .nanorc from your folder. If you are looking for syntax highlighting, you must know that nano can do this but it is not activated in Debian, please check the folder /usr/share/nano/ and add to your .nanorc the following line:

    include /usr/share/nano/*
    

    this will enable some colors in files where nano detects the right shebang.

    But there are also people who like to do it themselves, with their own hands, nanually, you understand..., for those I found this very nice version in archive.org, and I also tuned up mine ...

    ## Here is an example for Bourne shell scripts.
    ##
    syntax "bash" "\.sh$"
    header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
    icolor brightgreen "^[0-9A-Z_]+\(\)"
    color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
    color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
    color green "-[Ldefgruwx]\>"
    color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
    color brightblue "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|make|mkdir|mv|rm|sed|set|tar|touch|umask|unset)\>"
    color brightyellow ""(\\.|[^"])*""
    icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
    color brightyellow "'(\\.|[^'])*'"
    color cyan "(^|[[:space:]])#.*$"
    color ,green "[[:space:]]+$"