User: Password:
|
|
Subscribe / Log in / New account

Setting prompt not trivial

Setting prompt not trivial

Posted May 20, 2005 18:18 UTC (Fri) by diehl (guest, #6413)
Parent article: Fish - The friendly interactive shell

One aspect of fish which I find problematic right now is that the default prompt
displays your current directory, which is fine, except that after you get deep into
a directory tree you use up most of you command line on the prompt. This
aspect coupled to the lack of multiline editing, means that you find you cannot
edit a recalled command because it wraps to 2 lines and you cannot edit the first
part of the command anymore.

So I decided to try to reset my prompt to not include the PWD. I guess I just
don't understand the syntax, because I could not do it. The documentation says
the default prompt is:

set FISH_PROMPT "whoami; echo \@; hostname\|cut -d . -f 1; echo \\" \"; set_color
green; pwd; set_color normal; echo '\> ';"

Unfortunately I don't completely understand what is going on this this line, for
example, the purpose of: echo \\ which looks like you are echoing a "\" which
must be escaped, but apparently not because you do not see a "\" in the
command prompt. Anyway, I tried to reduce this to:

set FISH_PROMPT "whoami; echo \@; hostname\|cut -d . -f 1; echo '\> '"

This will generate an error:

Unknown command 'hostname|cut'

I could not figure out any way to remove the pwd part and get the hostname|cut
part to work. Even if you just remove the "pwd;" for some reason you still get
the default prompt.


(Log in to post comments)

Setting prompt not trivial

Posted May 21, 2005 0:52 UTC (Sat) by liljencrantz (guest, #28458) [Link]

Oops. That is an error in the documentation. The thing is that some characters have to be escaped with backslashes in the documentation, but I've obviously escaped too many characters. Simply a case of bad proofreading of the documentation.

This should work:

set FISH_PROMPT "whoami; echo '@'; hostname |cut -d . -f 1; echo '> '"

I will fix this in the manual. The pipeline in hostname is for computers that have long hostnames like 'gacrux.nada.kth.se'.

I am also planning on supporting multiline editing and smart line usage, so that when the cursor reaches the end of the line, the entire row is shifted to the left and the beginning of the line is removed.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds