I like that sudo bind, going to steal that on!

On Fri, Sep 2, 2016 at 1:19 PM, Robert Carpenter <rob...@robacarp.com>
wrote:

> I've put together a nice clean prompt that still carries a lot of
> information when it's needed:
>
> From left to right on the first prompt line:
>
> Git dirty state (red exclamation when dirty)
> Git branch name (light blue)
> RAILS_ENV var (pink, when present)
> git commit sha (hidden)
> date, time (hidden)
> long running command timer (hidden). I use this all the time.
>
> A blank previous command reveals all hidden data to quickly check
> time/date. Otherwise it can be selected to reveal.
>
> Second line is basically the stock fish prompt.
>
>
> Config is here: https://github.com/robacarp/config_files/blob/
> master/.config/fish/config.fish#L93-L152
>
> Essential to the git integration while retaining a fast prompt render is a
> gitstatus function / awk script:
>
>
> function gitstatus
>   git status --porcelain -b ^ /dev/null | awk '
>     BEGIN {
>       status["untracked"] = 0
>       status["modifications"] = 0
>       status["unmerged"] = 0
>     }
>     $1 ~ /##/ {
>       split($2, branch_names, ".")
>     }
>     $1 ~ /\?\?/       { status["untracked"] ++     }
>     $1 ~ /M/          { status["modifications"] ++ }
>     $1 ~ /[DAU][DAU]/ { status["unmerged"] ++ }
>     END {
>       print branch_names[1]
>       print status["untracked"]
>       print status["modifications"]
>       print status["unmerged"]
>     }
>    '
> end
>
> While we're showing off...a few things I've really enjoyed with fish that
> I would not have had the patience to write with bash.
>
> Faster "up navigation" allows me to just type a period to navigate another
> directory higher after "..":
>
> function fish_user_key_bindings
>   bind . 'expand-dot-to-parent-directory-path'
> end
>
> function expand-dot-to-parent-directory-path -d 'expand ... to ../.. etc'
>     # Get commandline up to cursor
>     set -l cmd (commandline --cut-at-cursor)
>
>     # Match last line
>     switch $cmd[-1]
>         case '*..'
>             commandline --insert '/..'
>         case '*'
>             commandline --insert '.'
>     end
> end
>
> These configs prepend "sudo " to a command on ctrl-s:
>
> # in config.fish
>
> function fish_user_key_bindings
>   bind \cs 'sudo-my-prompt-yo'
> end
>
> # in functions/sudo-my-prompt-yo.fish
>
> function sudo-my-prompt-yo
>   set -l cmd (commandline)
>   commandline --replace "sudo $cmd"
> end
>
>
> Like I said, these are tweaks that might have been possible under Bash but
> I certainly never would have had the patience for it.
>
> Robert
>
> On Sep 2, 2016, at 10:15, David Frascone <d...@frascone.com> wrote:
>
> Sure . . . let me try to un-wind it from the rest of my crap and toss it
> up on github.
>
> On Fri, Sep 2, 2016 at 8:59 AM, charlie <charlie.f...@gmail.com> wrote:
> Can you share it please :P ?
>
> On Fri, Sep 2, 2016 at 9:50 AM, David Frascone <d...@frascone.com> wrote:
> I'm pretty happy with mine, with mercurial/git branch integration, and
> error return values, plus a pretty fish!
>
> <image.png>
>
> On Fri, Sep 2, 2016 at 8:42 AM, charlie <charlie.f...@gmail.com> wrote:
> I saw a friends z-shell theme the other day and thought it was really
> slick, https://cloud.githubusercontent.com/assets/
> 2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png .  Anyway to
> accomplish the same thing in Fish ?  Or where would I start looking ?
>
> Thanks!
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
>
>
>
> --
> Thanks!
> Charlie
>
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
> ------------------------------------------------------------
> ------------------
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
>


-- 
Thanks!
Charlie
------------------------------------------------------------------------------
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to