In my .bashrc, I got this:
PS1="[\w $]"
And every time when I cd to a dir with a deep level, the shell prompt almost takes up the whole line, (terminal size: 80*24), like:
[/level_a_dir/level_b_dir/level_c_dir/level_d_dir/level_e_dir $]
Question
I want to cut the prompt short if the pwd is longer than 20 chars, just keep the last dir, like:
[.../level_e_dir $]
#[/level_a_dir/level_b_dir/level_c_dir/level_d_dir] is replaced with ...
How to do it?
I have done it in the following way.
First you have to create a shell script, truncate.sh:
Next you have to replace your PS1: