prompt - Coloring directory name in ksh -
In my current situation, I have several Unix computers with whom I am connected, because on the basis of many different users On the situation, and working machines, through different directories, I have to go through KS.S. I use.
I was recently negligible from my awakening, and I was able to get it to change some color based on my current username and current server, however, I also want to know that my existing The colors will change depending on the directory. For example, if I was in the directory "foo", the signal should be yellow, but if I was in the directory "bar", the signal would be magenta. In both cases, sub-directories should also be counted, so a simple object probe should be sufficient.
The problem I have found, is that when I run my .profile script, it correctly colors the directory-- but whenever I switch to any other directory It is not updated dynamically - and I'm not sure that before I work in all the branches, I was able to print my current working directory correctly, whenever I did Eshika did switch.
I did some googling, and got information for Bash, but ksh is being largely ignored. As I do not understand how to do this, I should be brought into the stack overflu community to add future knowledge to it. Thus, with my long-standing explanation, the "quick version" of my question is as follows:
In ksh, how can I set the current work directory to display and the text Color based on the current working directory? Is this also possible?
Why not use zsh? It's based on ksh, and it's more powerful. In zsh you can write chpwd function, which every time you change the directory in this function you can check your current directory and set the PS1 to whatever you want.
Alternatively (even in installments) you can create a nickname for CD command:
change_my_ps () {PS1 = ...} Better_cd () {builtin CD "$ @" change_my_ps} aka cd = better_cd something like that I'm not sure if this is appropriate, I do not remember the hair syntax.
Comments
Post a Comment