Here's mine -- mostly stock, but adds last command return code:

function fish_prompt --description 'Write out the prompt'
    # Save our status
    set -l last_status $status

    set -l last_status_string ""
    if [ $last_status -ne 0 ]
        printf "%s(%d)%s " (set_color red --bold) $last_status (set_color
normal)
    end

    # Just calculate these once, to save a few cycles when displaying the
prompt
    if not set -q __fish_prompt_hostname
        set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
    end

    if not set -q __fish_prompt_normal
        set -g __fish_prompt_normal (set_color normal)
    end

    set -l user_prompt '>'
    switch $USER
        # Set our root colors, if we're root :)
        case root
            set user_prompt '#'
            if not set -q __fish_prompt_cwd
                if set -q fish_color_cwd_root
                    set -g __fish_prompt_cwd (set_color
$fish_color_cwd_root)
                else
                    set -g __fish_prompt_cwd (set_color $fish_color_cwd)
                end
            end
        case '*'
            if not set -q __fish_prompt_cwd
                set -g __fish_prompt_cwd (set_color $fish_color_cwd)
            end
    end
    #printf '%s@%s %s%s%s# ' $USER $__fish_prompt_hostname
"$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
    #printf "LAST STATUS STRING: $last_status_string \n"
    printf '%s@%s %s%s%s%s%s ' $USER $__fish_prompt_hostname
"$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" $user_prompt

end

function fish_title
    echo $_ ' ' (prompt_pwd)
end


On Sun, Aug 26, 2012 at 5:06 PM, Guilhem Saurel <guil...@saurel.me> wrote:

> 2012/8/26 ridiculous_fish <corydo...@ridiculousfish.com>
>
>> Hello fellow fish fans,
>>
>> I'm working on a prompt editor, which will include a bunch of sample
>> prompts that the user can preview and then use (or edit). I'd like to
>> include real prompts contributed by real users, showing the range possible
>> prompts.
>>
>> If you're willing, please send me the following:
>>
>> - Your fish_prompt function, or file if it contains multiple functions
>> - A suggested short name for it, hopefully descriptive ("Minimalist",
>> "Git Savvy" ), or evocative ("Lotus Blossom"), or failing that, your name
>> is fine ("Richards")
>> - If you like, an attribution line ("John Doe's prompt -
>> http://www.mysite.com";)
>>
>> You can send it directly to me at corydo...@ridiculousfish.com, or post
>> it to the list if you want to strut your stuff.
>>
>> For the record, here's my prompt, which I'm calling "Minimalist" (but may
>> change it if we get a bunch of minimalist prompts):
>>
>> function fish_prompt
>>         set_color $fish_color_cwd
>>         echo -n (basename $PWD)
>>         set_color normal
>>         echo -n ' ) '
>> end
>>
>> Thanks for any and all contributions!
>>
>> _fish
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Fish-users mailing list
>> Fish-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/fish-users
>>
>
>
> Hello,
>
> Here is mine !
>
> Name: Nim
> Attribution line: Guilhem "Nim" Saurel −
> https://github.com/nim65s/dotfiles/
>
> It changes differents colors when the return of the last command is not 0,
> when you are root, and/or when you are in ssh.
> It also detects when you are in a tty and use ASCII instead of UTF-8,
> and shows some informations about battery and background jobs when useful.
>
> -----------------------------
> function fish_prompt
>     and set retc green; or set retc red
>     tty|grep -q tty; and set tty tty; or set tty pts
>
>     set_color $retc
>     if [ $tty = tty ]
>         echo -n .-
>     else
>         echo -n '┬─'
>     end
>     set_color -o green
>     echo -n [
>     if [ $USER = root ]
>         set_color -o red
>     else
>         set_color -o yellow
>     end
>     echo -n $USER
>     set_color -o white
>     echo -n @
>     if [ -z "$SSH_CLIENT" ]
>         set_color -o blue
>     else
>         set_color -o cyan
>     end
>     echo -n (hostname)
>     set_color -o white
>     #echo -n :(prompt_pwd)
>     echo -n :(pwd|sed "s=$HOME=~=")
>     set_color -o green
>     echo -n ']'
>     set_color normal
>     set_color $retc
>     if [ $tty = tty ]
>         echo -n '-'
>     else
>         echo -n '─'
>     end
>     set_color -o green
>     echo -n '['
>     set_color normal
>     set_color $retc
>     echo -n (date +%X)
>     set_color -o green
>     echo -n ]
>     if [ (acpi -a 2> /dev/null | grep off) ]
>         echo -n '─['
>         set_color -o red
>         echo -n (acpi -b|cut -d' ' -f 4-)
>         set_color -o green
>         echo -n ']'
>     end
>     echo
>     set_color normal
>     for job in (jobs)
>         set_color $retc
>         if [ $tty = tty ]
>             echo -n '; '
>         else
>             echo -n '│ '
>         end
>         set_color brown
>         echo $job
>     end
>     set_color normal
>     set_color $retc
>     if [ $tty = tty ]
>         echo -n "'->"
>     else
>         echo -n '╰─>'
>     end
>     set_color -o red
>     echo -n '$ '
>     set_color normal
> end
> -----------------------------
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to