7

Recently I installed the Powerline in the linux to enhance the look and feel of my terminal. It works great, however, it display 3 levels of directories in the prompt while traversing. Consider below example

unikx> ...>Dir1>Dir2>Dir3

where unikx is my username and Dir3 is my current working directory. The problem is, I have a habit of giving long names to directories. So due to above behaviour of Powerline showing 3 levels, I dont have enough space on that current line to write my commands and eventually my commands appear in the next line which I dont like.

So how do I customize powerline to show only 2 or current dir in the prompt like below:

unikx> ...>Dir3 

or

unikx> ...>Dir2>Dir3

Thanks.

1 Answer 1

4

I think the setting you're looking for is in something like

<powerline_install_dir>/config_files/themes/shell/__main__.json

on this line:

"dir_limit_depth": 3

(Note that your installation may be different from mine so you might have to search for the file.)

See Powerline quick setup guide. This reddit post might also help. (If you're in a hurry edit that file directly.)

FYI, a simple alternative is the powerline command's --width flag which takes max width of the prompt in columns/characters. E.g. powerline --width 40 .... This will dynamically resize segments of the prompt as needed which usually means shrinking the path segment.

You probably won't know if you like it until you try it. That way you can see exactly how it behaves for different console widths, different paths, with whatever other segments you are displaying, etc.

I couldn't find a straightforward way to set this but looking at the code it seems that setting COLUMNS=X (X is desired width) in your environment before invoking the powerline.sh startup script will do the trick.

8
  • Thanks, I will try this. Before I try, I just want to know that after executing the powerline --width 40, what should i do to revert back incase i dont find it appropriate ?
    – uNIKx
    Oct 21, 2017 at 14:07
  • I am using Bash, and the following lines are written in my .bashrc if [ -f which powerline-daemon ]; then powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 . /usr/share/powerline/bash/powerline.sh fi I am newbie in linux and all this :-P
    – uNIKx
    Oct 21, 2017 at 14:22
  • Hmm. For --width try adding this immediately before the powerline-daemon call: export COLUMNS=99 (replace 99 with whatever you want).
    – B Layer
    Oct 21, 2017 at 15:02
  • I am struggling with this path <python-dir>/site-packages/powerline/config_files/themes/shell/__main__.json. I am unable to find my <python-dir>.
    – uNIKx
    Oct 22, 2017 at 14:01
  • :-( I ran the find command, no luck. The prompt doesnt show anything.
    – uNIKx
    Oct 22, 2017 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.