Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
A Powerline-style prompt for Bash (github.com/milkbikis)
55 points by milkbikis on Sept 9, 2012 | hide | past | favorite | 28 comments



Clever, but Powerline-themed context around your current shell environment seems more suited to implementation in something like tmux - see https://github.com/erikw/tmux-powerline or http://www.drbunsen.org/text-triumvirate.html


I defenitely like the "make previous return status obvious" thing. Will use that idea in my prompt, thanks.



Thanks. After reading the post, I turned my prompt into that : https://gist.github.com/648a75ec821acff10749

which looks like that : http://i.imgur.com/Qc86I.png

I like having an uri directly pastable to scp. Also, as mentioned in other comments, Having a fixed length prompt on the command line is quite appreciable.

I'm unsatisfied, though, with the need of subshells to draw a single prompt. It's ok for the git part, but I feel like the PROMPT_COMMAND part is a hack, I just can't succeed in making it displays colors (rather than escaped characters) without a subshell.


I don't like the powerline style for displaying the path, but I like it in tmux. It looks really awesome compared to the defaults(green background for the status line).


Anybody else having problems getting it to work? It's just flashing for me. I've installed a patched version of Inconsolata but still no luck.


Note: showing colors in terminals is done through ANSI codes which have varying levels of compatibility with different terminals. For me, this works on an iTerm terminal, with $TERM set to xterm-256color.


Yeah that was the problem. I realized that Snow Leopard's default terminal doesn't have support for ANSI colors..I think. Anyways, if you're on Snow Leopard or earlier versions of Mac OSX, you need to use iTerm2. Also, to make the PS1 smaller, you can delete the two lines in the last method (the constructor I think) that prints the hostname and user. So, delete or comment:

   p.append(' \u ', 250, 240)
   p.append(' \h ', 250, 238)


Yup, just remove/comment out any portions (Powerline calls it segments) you don't like.


Oh, boy, props for getting this working, but this looks really distracting to actually use as a prompt for my tastes.


Yeah, I also have one that fixes the prompt to the top so you only see a small '$' at the current line, but it messes up the terminal history.


I too prefer just PS1='$ ', I want the cursor to be the same distance from the margin every time, to have maximum length for typing without wrapping, and the ability to put in a few separator lines between command output by just tapping Return.

However, for your problem, have you considered the terminal's title instead of the top line of the tty? printf '\033]0;foo\007'


Mine has a bunch of info, then a newline, then ' $'. Being able to see the current git branch is just too useful to drop, but I moving random distances out from the margin between commands.


Hmm, that wouldn't let me keep the colors etc. I'm on iTerm btw, perhaps you mean the title in a screen/tmux session?


No, I meant the window's furniture so no colours. I agree, a tty-wrapper, like tmux, would provide another option.  I don't suppose there are terminals generally about where `tput hs' is true. Have you considered using the end of the prompt line for status, returning to the left for the "$ ", and being happy to do readline's redraw-current-line if you don't like the overwrite should you reach that far?


By messes up terminal history do you mean when you push up in terminal the previous lines that show up are rendered badly or that your actual history is effected in some way?


I used the ANSI control codes for moving the cursor, which seems to overwrite previous lines. Not sure if there's another way to achieve that without overwriting lines though.


Maybe use \033[L (ANSI for insert-line).

Edit: If I understand what you're doing, then maybe you can use this:

    tput ind; tput home; tput il1; echo -n "header"; tput el; tput cup $LINES 0
Use "man terminfo" to lookup things like "il1" and use "infocmp" to see what they translate to in your terminal.


How do you make your $ character appear smaller than usual?


I didn't do anything- maybe it's smaller in Monaco?


You said that you used "a small '$'". How's it any smaller than usual?


Oh, sorry about that. I just meant that it has only a $ sign which makes it small.


Patching my fonts seems a bit excessive just for a fancy prompt.


Why are the colors broken (in ' Library') in the riced up vim?


That's the CtrlP vim plugin, which runs a fuzzy search. In the screenshot I'm in the middle of a search so the matched part is partially highlighted.


Powrlbe is nifty. How do I subscribe to news about new tech stuff like that? I don't remember seeing it here.


I'd like to know too. Just saw it in a dotfile.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: