From 9d9ab376b97b87c4228164555fd525224eafed65 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Tue, 31 Aug 2021 12:46:45 +0300 Subject: [PATCH] Added fish configs --- fish/config.fish | 4 +++ fish/fish_variables | 31 ++++++++++++++++++++ fish/functions/fish_prompt.fish | 51 +++++++++++++++++++++++++++++++++ install.sh | 3 +- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 fish/config.fish create mode 100644 fish/fish_variables create mode 100644 fish/functions/fish_prompt.fish diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..85ffc19 --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,4 @@ +if status is-interactive + # Commands to run in interactive sessions can go here + +end diff --git a/fish/fish_variables b/fish/fish_variables new file mode 100644 index 0000000..236682a --- /dev/null +++ b/fish/fish_variables @@ -0,0 +1,31 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3100 +SETUVAR fish_color_autosuggestion:BD93F9 +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:F8F8F2 +SETUVAR fish_color_comment:6272A4 +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:50FA7B +SETUVAR fish_color_error:FFB86C +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_param:FF79C6 +SETUVAR fish_color_quote:F1FA8C +SETUVAR fish_color_redirection:8BE9FD +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:B3A06D\x1eyellow +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..4f28b2c --- /dev/null +++ b/fish/functions/fish_prompt.fish @@ -0,0 +1,51 @@ +function fish_prompt --description 'Write out the prompt' + set -l laststatus $status + + set -l git_info + if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '') + set git_branch (set_color -o blue)"$git_branch" + set -l git_status + if not command git diff-index --quiet HEAD -- + if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null) + echo $count | read -l ahead behind + if test "$ahead" -gt 0 + set git_status "$git_status"(set_color red)⬆ + end + if test "$behind" -gt 0 + set git_status "$git_status"(set_color red)⬇ + end + end + for i in (git status --porcelain | string sub -l 2 | sort | uniq) + switch $i + case "." + set git_status "$git_status"(set_color green)✚ + case " D" + set git_status "$git_status"(set_color red)✖ + case "*M*" + set git_status "$git_status"(set_color green)✱ + case "*R*" + set git_status "$git_status"(set_color purple)➜ + case "*U*" + set git_status "$git_status"(set_color brown)═ + case "??" + set git_status "$git_status"(set_color red)≠ + end + end + else + set git_status (set_color green): + end + set git_info "(git$git_status$git_branch"(set_color white)")" + end + + # Disable PWD shortening by default. + set -q fish_prompt_pwd_dir_length + or set -lx fish_prompt_pwd_dir_length 0 + + set_color -b black + printf '%s%s%s%s%s%s%s%s%s%s%s%s%s' (set_color -o white) '❰' (set_color green) $USER (set_color white) '❙' (set_color yellow) (prompt_pwd) (set_color white) $git_info (set_color white) '❱' (set_color white) + if test $laststatus -eq 0 + printf "%s✔%s≻%s " (set_color -o green) (set_color white) (set_color normal) + else + printf "%s✘%s≻%s " (set_color -o red) (set_color white) (set_color normal) + end +end diff --git a/install.sh b/install.sh index b37e886..a95b4f5 100755 --- a/install.sh +++ b/install.sh @@ -3,5 +3,4 @@ ln -s $(pwd)/nvim ${HOME}/.config/nvim ln -s $(pwd)/git/config ${HOME}/.gitconfig ln -s $(pwd)/git/ignore ${HOME}/.gitignore -ln -s $(pwd)/zsh/zsh ${HOME}/.oh-my-zsh -ln -s $(pwd)/zsh/zshrc ${HOME}/.zshrc +ln -s $(pwd)/fish ${HOME}/.config/fish