문제

How we can automatically change the terminal title as current directory name. I have below command in my cshrc file

alias precmd 'echo -n "\033]0;${PWD}\a"'

But it is displaying the full path instead of current directory path. So I wants to update the title with current directory.

Also please Let me know if we can display the title with current directory plus its parent directory name?

for example if the full directory path is /user/shibin/code/cpp/ I need to change the terminal name as either /cpp or /code/cpp

Thank You

도움이 되었습니까?

해결책 2

FYI,

If you wants to set the terminal title as /code/cpp in my above question, do this :

alias precmd 'echo -n "\033]0;`pwd | rev | cut -d/ -f1,2 | rev`\a"'

if you change the filed from -f1,2 to -f1,3 then you can set the title as shibin/code/cpp and so on...

다른 팁

You can get the last element from a directory path with basename(1), so the following should work with tcsh:

alias precmd 'echo -n "\033]0;`basename ${PWD}`\a"'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top