Last active
December 19, 2015 10:19
-
-
Save aslpavel/5939845 to your computer and use it in GitHub Desktop.
Simple config.fish with nice prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple config.fish with nice prompt (requires patched powerline font) | |
# link: https://gist.github.com/aslpavel/5939845 | |
# install: wget --no-check-certificate -q -O - https://gist.github.com/aslpavel/5939845/download | tar -xzO -f- --strip-components=1 > "$HOME/.config/fish/config.fish" | |
### PROMPT | |
switch "$TERM" | |
case "linux" "rxvt" | |
set _prompt_sep "" | |
set _prompt_col_user 3 | |
set _prompt_col_host 3 | |
set _prompt_col_base 0 | |
set _prompt_col_tags 1 5 2 | |
function _prompt_col | |
test -z $argv[1]; or printf "\x1b[3$argv[1]m" | |
test -z $argv[2]; or printf "\x1b[4$argv[2]m" | |
printf "$argv[3]" | |
set_color normal | |
end | |
case "*" | |
if test (tput colors 2>/dev/null; or echo 8) -ne 256 | |
set -gx TERM xterm-256color | |
end | |
set _prompt_sep \ue0b0 | |
set _prompt_col_user 178 | |
set _prompt_col_host 136 | |
set _prompt_col_base 235 | |
set _prompt_col_tags 131 61 29 | |
function _prompt_col | |
test -z $argv[1]; or printf "\x1b[38;5;$argv[1]m" | |
test -z $argv[2]; or printf "\x1b[48;5;$argv[2]m" | |
printf "$argv[3]" | |
set_color normal | |
end | |
end | |
if [ (id -u $USER) -eq 0 ] | |
set _prompt_col_tag $_prompt_col_tags[1] | |
else | |
switch (uname) | |
case "Darwin" "FreeBSD" | |
set _prompt_col_tag $_prompt_col_tags[2] | |
case "Linux" "CIGWIN*" | |
set _prompt_col_tag $_prompt_col_tags[3] | |
end | |
end | |
function _prompt_seg_sep | |
_prompt_col $argv[1] $argv[2] $_prompt_sep | |
end | |
function _prompt_seg_user | |
_prompt_col $_prompt_col_user $_prompt_col_base " "(whoami) | |
_prompt_col $_prompt_col_host $_prompt_col_base @(hostname|cut -d . -f 1)" " | |
end | |
function _prompt_seg_path | |
_prompt_col $_prompt_col_base $_prompt_col_tag " "(prompt_pwd)" " | |
end | |
function fish_prompt | |
_prompt_seg_user | |
_prompt_seg_sep $_prompt_col_base $_prompt_col_tag | |
_prompt_seg_path | |
_prompt_seg_sep $_prompt_col_tag "" | |
printf " " | |
end | |
### PATH | |
for path in "$HOME/.bin" \ | |
"$HOME/.local/bin" \ | |
"$HOME/.gem/ruby/2.0.0/bin" \ | |
"$HOME/.cabal/bin" | |
if test -d "$path"; and not contains "$path" $PATH | |
set PATH "$path" $PATH | |
end | |
end | |
### LS_COLORS | |
if test -f "$HOME/.config/dircolors" | |
eval (dircolors -c "$HOME/.config/dircolors") | |
end | |
### KEY BINDINGS | |
function fish_user_key_bindings | |
bind \e. "history-token-search-backward" | |
end | |
## FUNCTIONS | |
function fish_conf_update -d "update fish config file" | |
set repo https://gist.github.com/aslpavel/5939845/download | |
set conf "$HOME/.config/fish/config.fish" | |
set conf_tmp (mktemp) | |
wget --no-check-certificate -q -O - "$repo" |\ | |
tar -xzO -f- --strip-components=1 > "$conf_tmp" | |
if test -s "$conf_tmp" | |
cat "$conf_tmp" > "$conf" | |
. "$conf" | |
end | |
end | |
function pretzel_shell -d "start pretzel shell" | |
switch (count $argv) | |
case 0 | |
set python python | |
set module pretzel | |
set -x PYTHONPATH /mnt/data/Maggot/Python | |
case 1 | |
set python $argv[1] | |
set module pretzel | |
set -x PYTHONPATH /mnt/data/Maggot/Python | |
case 2 | |
set python $argv[1] | |
set module $argv[2] | |
end | |
rlwrap -D2 -pgreen $python -m$module.apps.shell | |
end | |
function p | |
pretzel_shell python $argv | |
end | |
function p2 | |
pretzel_shell python2 $argv | |
end | |
function pp | |
pretzel_shell pypy $argv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment