jamie (owner)

Revisions

gist: 70952 Download_button fork
public
Description:
My base fish config files
Public Clone URL: git://gist.github.com/70952.git
Embed All Files: show embed
~/.config/fish/config.fish #
1
2
3
4
5
6
7
8
9
10
11
12
13
set PATH ~/bin $PATH
if test -d /opt/local/lib/mysql5/bin/
  # include OSX mysql from macports
  set PATH $PATH /opt/local/lib/mysql5/bin/
end
 
# OSX tweaks
if set -q Apple_PubSub_Socket_Render
  # bind \cleft and \cright
  bind \e\[5D prevd-or-backward-word
  bind \e\[5C nextd-or-forward-word
end
 
~/.config/fish/functions/fish_prompt.fish #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function fish_prompt --description 'Write out the prompt'
  
  # 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
 
  # different path colors for root prompts
  switch $USER
    case root
    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
 
  # basic prompt
  printf '%s@%s %s%s%s' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
 
  # optionally describe current git status
  if git symbolic-ref HEAD >/dev/null ^/dev/null
    printf ' (git:%s' (git-current-branch)
    if not test -z (gitout) >/dev/null ^/dev/null
      printf '+%d' (gitout | wc -l | awk '{print $1}')
    end
    printf ')'
  end
  
  # end the prompt
  switch $USER
    case root
    printf '# '
 
    case '*'
    printf '> '
  end
 
end
 
~/.config/fish/functions/git-current-branch.fish #
1
2
3
4
5
function git-current-branch
  # display name of current active branch
  git symbolic-ref HEAD ^/dev/null | awk -F/ '{print $3;}'
end
 
~/.config/fish/functions/gitout.fish #
1
2
3
4
5
6
7
8
9
10
11
12
function gitout
  # count non-merge commits needing a push to origin
  if git cherry -v origin/(git-current-branch) >/dev/null ^/dev/null
    # vs outgoing branch if available
    git cherry -v origin/(git-current-branch) ^/dev/null
  else
    # otherwise compare to the master branch
    git cherry -v master ^/dev/null
  end
 
end