view fish/config.fish @ 383:ff48d206d1f1

Miscellaneous tweaks.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 05 Aug 2017 22:11:13 -0700
parents 93a174c912ea
children b5d54b669b8c
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.
set -g -x PATH $HOME/.local/bin $PATH
set -g -x PATH $HOME/bin $PATH
set -g -x OS MacOSX
set -g -x EDITOR vim
set -g -x SHELL fish

# Python.
set -g -x VIRTUAL_ENV_DISABLE_PROMPT 1

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

# }}}

# Aliases {{{

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 git branch >/dev/null 2>/dev/null 
        printf '±' ; return
    end
    if hg root >/dev/null 2>/dev/null
        printf '☿' ; return
    end
    echo '○'
end

function hg_prompt
    set_color magenta
    printf '%s' (fast-hg-bookmark 2>/dev/null)
    set_color normal
end

function git_prompt
    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

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'

# }}}

# Virtualenv wrapper for Fish {{{

eval (/usr/local/bin/python2.7 -m virtualfish)

#set -g VIRTUALFISH_COMPAT_ALIASES # uncomment for virtualenvwrapper-style commands
#. $HOME/.config/fish/virtualfish/virtual.fish
# optional plugins
#. path/to/auto_activation.fish
#. path/to/global_requirements.fish
#. path/to/projects.fish

# }}}

# Local Settings {{{

if test -s $HOME/.config/fish/local.fish
    . $HOME/.config/fish/local.fish
end

# }}}