view fish/config.fish @ 422:61f343a2aaff

Don't set the `$SHELL` variable, it's alread set by fish.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 17 Feb 2018 19:24:26 -0800
parents c6da0c9f40ae
children 350f7a55ff33
line wrap: on
line source


# Environment variables {{{

set -g -x fish_greeting 'Hello.'

# Homebrew.
#set -g -x PATH /usr/local/sbin $PATH
#set -g -x PATH /usr/local/bin $PATH
 
# My own stuff.
if test -d $HOME/.local/bin
    set -g -x PATH $HOME/.local/bin $PATH
end
if test -d $HOME/bin
    set -g -x PATH $HOME/bin $PATH
end
set -g -x OS MacOSX
set -g -x EDITOR vim
set -g -x TERM screen-256color-bce

# Python.
set -g -x VIRTUAL_ENV_DISABLE_PROMPT 1

# Go.
set -g -x GOPATH /usr/local/Cellar/go/1.4/gocode

if type -q git 
    set -g -x __local_has_git
end
if type -q hg
    set -g -x __local_has_hg
end
if test -e $HOME/.local/bin/fast-hg-bookmark
    set -g -x __local_has_fast_hg_bookmark
end

# }}}

# Aliases {{{

# Run Tmux in UTF8 and 256 colours always.
alias tm 'tmux -u2'

# }}}

# Prompt {{{

set normal (set_color normal)
set magenta (set_color magenta)
set yellow (set_color yellow)
set green (set_color green)
set gray (set_color -o black)

function virtualenv_prompt
    if set -q VIRTUAL_ENV
        set_color -b blue white
        printf '(venv:%s)' (basename "$VIRTUAL_ENV")
        set_color normal
        printf ' '
    end
end

function prompt_char
    if set -q __local_has_git
        if git branch >/dev/null 2>/dev/null 
            printf '±' ; return
        end
        if hg root >/dev/null 2>/dev/null
            printf '☿' ; return
        end
        echo '○'
    end
end

function hg_prompt
    if set -q __local_has_hg 
        and set -q __local_has_fast_hg_bookmark
        set_color magenta
        printf '%s' (fast-hg-bookmark 2>/dev/null)
        set_color normal
    end
end

function git_prompt
    if set -q __local_has_git
        if git root >/dev/null 2>&1
            set_color normal
            printf ' on '
            set_color magenta
            printf '%s' (git currentbranch ^/dev/null)
            set_color green
            git_prompt_status
            set_color normal
        end
    end
end

function fish_prompt
    set last_status $status

    echo

    # 'username@hostname: '
    set_color magenta
    printf '%s' (whoami)
    set_color normal
    printf '@'
    set_color yellow
    printf '%s' (hostname|cut -d . -f 1)
    set_color normal
    printf ': '

    set_color $fish_color_cwd
    printf '%s' (prompt_pwd)
    set_color normal

    printf ' '
    prompt_char
    printf ' '

    hg_prompt

    echo

    virtualenv_prompt

    if test $last_status -eq 0
        set_color white -o
        printf '> '
    else
        set_color red -o
        printf '[%d] > ' $last_status
    end

    set_color normal
end

# }}}

# Directories {{{

alias ..    'cd ..'
alias ...   'cd ../..'
alias ....  'cd ../../..'
alias ..... 'cd ../../../..'

alias md 'mkdir -p'

# }}}

# Local Settings {{{

if test -s $HOME/.config/fish/local.fish
    . $HOME/.config/fish/local.fish
end
#eval (/usr/local/bin/python -m virtualfish)

# }}}