From 3f2a8fcb402c4aabbc5a7304cbb7875ee5936b0a Mon Sep 17 00:00:00 2001 From: Bruno Carlin Date: Fri, 12 Jun 2020 11:02:41 +0200 Subject: [PATCH] reorganize fish config in separate files --- fish/.config/fish/conf.d/abbr.fish | 5 +++ fish/.config/fish/conf.d/prompt.fish | 12 ++++++ fish/.config/fish/conf.d/virtualenv.fish | 25 ++++++++++++ fish/.config/fish/config.fish | 51 ------------------------ 4 files changed, 42 insertions(+), 51 deletions(-) create mode 100644 fish/.config/fish/conf.d/abbr.fish create mode 100644 fish/.config/fish/conf.d/prompt.fish create mode 100644 fish/.config/fish/conf.d/virtualenv.fish diff --git a/fish/.config/fish/conf.d/abbr.fish b/fish/.config/fish/conf.d/abbr.fish new file mode 100644 index 0000000..456da90 --- /dev/null +++ b/fish/.config/fish/conf.d/abbr.fish @@ -0,0 +1,5 @@ +if status --is-interactive + abbr --add --global lg 'lazygit' + abbr --add --global jsonpp "python -mjson.tool" +end + diff --git a/fish/.config/fish/conf.d/prompt.fish b/fish/.config/fish/conf.d/prompt.fish new file mode 100644 index 0000000..8824c4c --- /dev/null +++ b/fish/.config/fish/conf.d/prompt.fish @@ -0,0 +1,12 @@ +# set command timing in prompt +set fish_command_timer_time_format '' +source ~/.config/fish/command_timer.sh + +# Removes greeting message +set fish_greeting + +set -g __fish_git_prompt_show_informative_status 1 +set -g __fish_git_prompt_shorten_branch_len 20 +set -g __fish_git_prompt_showcolorhints 1 + + diff --git a/fish/.config/fish/conf.d/virtualenv.fish b/fish/.config/fish/conf.d/virtualenv.fish new file mode 100644 index 0000000..e68369d --- /dev/null +++ b/fish/.config/fish/conf.d/virtualenv.fish @@ -0,0 +1,25 @@ +set -x VIRTUAL_ENV_DISABLE_PROMPT true + +# Autosource python virtualenv +function __autovenv_python --on-variable PWD + set -l base $PWD + set -l has_venv false + + while test $base != '/' + if test -f $base/.venv/bin/activate.fish + set has_venv $base/.venv + break + end + set base (dirname $base) + end + + if test -n "$VIRTUAL_ENV" -a $has_venv = 'false' + deactivate + else if test $has_venv != 'false' + if test -z "$VIRTUAL_ENV" -o "$VIRTUAL_ENV" != "$has_env" + source "$has_venv/bin/activate.fish" + end + end +end + + diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish index 812e652..d1774ee 100644 --- a/fish/.config/fish/config.fish +++ b/fish/.config/fish/config.fish @@ -1,7 +1,6 @@ ## PATH set -x PATH $PATH ~/.local/bin ~/.go/bin ~/.npm/bin -set -x VIRTUAL_ENV_DISABLE_PROMPT true set -x EDITOR nvim ## SSH init @@ -16,53 +15,3 @@ end ## Go utils set -x GOPATH ~/.go -## aliases -alias jsonpp "python -mjson.tool" - -# Emulates !! -function bind_bang - switch (commandline -t)[-1] - case "!" - commandline -t $history[1]; commandline -f repaint - case "*" - commandline -i ! - end -end - -function fish_user_key_bindings - bind ! bind_bang -end - -# Autosource python virtualenv -function __autovenv_python --on-variable PWD - set -l base $PWD - set -l has_venv false - - while test $base != '/' - if test -f $base/.venv/bin/activate.fish - set has_venv $base/.venv - break - end - set base (dirname $base) - end - - if test -n "$VIRTUAL_ENV" -a $has_venv = 'false' - deactivate - else if test $has_venv != 'false' - if test -z "$VIRTUAL_ENV" -o "$VIRTUAL_ENV" != "$has_env" - source "$has_venv/bin/activate.fish" - end - end -end - -# set command timing in prompt -set fish_command_timer_time_format '' -source ~/.config/fish/command_timer.sh - -# Removes greeting message -set fish_greeting - -set -g __fish_git_prompt_show_informative_status 1 -set -g __fish_git_prompt_shorten_branch_len 20 -set -g __fish_git_prompt_showcolorhints 1 -