From c3362aefa2e762211409923cfff065541bebf9e7 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 22 May 2022 00:37:40 +0530 Subject: ble.sh & z4h addition --- .local/src/blesh/contrib/airline/atomic.bash | 42 ++++ .local/src/blesh/contrib/airline/dark.bash | 30 +++ .local/src/blesh/contrib/airline/dark_minimal.bash | 13 ++ .local/src/blesh/contrib/airline/google_dark.bash | 28 +++ .local/src/blesh/contrib/airline/google_light.bash | 28 +++ .local/src/blesh/contrib/airline/landscape.bash | 34 +++ .local/src/blesh/contrib/airline/light.bash | 29 +++ .local/src/blesh/contrib/airline/minimalist.bash | 31 +++ .local/src/blesh/contrib/airline/monochrome.bash | 22 ++ .local/src/blesh/contrib/airline/solarized.bash | 33 +++ .../src/blesh/contrib/airline/solarized_flood.bash | 49 ++++ .local/src/blesh/contrib/airline/term.bash | 38 ++++ .local/src/blesh/contrib/airline/term_light.bash | 38 ++++ .local/src/blesh/contrib/airline/transparent.bash | 33 +++ .local/src/blesh/contrib/airline/xtermlight.bash | 29 +++ .local/src/blesh/contrib/bash-preexec.bash | 154 +++++++++++++ .local/src/blesh/contrib/config/execmark.bash | 111 +++++++++ .local/src/blesh/contrib/fzf-completion.bash | 49 ++++ .local/src/blesh/contrib/fzf-git.bash | 110 +++++++++ .local/src/blesh/contrib/fzf-initialize.bash | 52 +++++ .local/src/blesh/contrib/fzf-key-bindings.bash | 54 +++++ .local/src/blesh/contrib/prompt-defer.bash | 150 +++++++++++++ .local/src/blesh/contrib/prompt-elapsed.bash | 91 ++++++++ .local/src/blesh/contrib/prompt-git.bash | 250 +++++++++++++++++++++ .local/src/blesh/contrib/prompt-vim-mode.bash | 20 ++ 25 files changed, 1518 insertions(+) create mode 100644 .local/src/blesh/contrib/airline/atomic.bash create mode 100644 .local/src/blesh/contrib/airline/dark.bash create mode 100644 .local/src/blesh/contrib/airline/dark_minimal.bash create mode 100644 .local/src/blesh/contrib/airline/google_dark.bash create mode 100644 .local/src/blesh/contrib/airline/google_light.bash create mode 100644 .local/src/blesh/contrib/airline/landscape.bash create mode 100644 .local/src/blesh/contrib/airline/light.bash create mode 100644 .local/src/blesh/contrib/airline/minimalist.bash create mode 100644 .local/src/blesh/contrib/airline/monochrome.bash create mode 100644 .local/src/blesh/contrib/airline/solarized.bash create mode 100644 .local/src/blesh/contrib/airline/solarized_flood.bash create mode 100644 .local/src/blesh/contrib/airline/term.bash create mode 100644 .local/src/blesh/contrib/airline/term_light.bash create mode 100644 .local/src/blesh/contrib/airline/transparent.bash create mode 100644 .local/src/blesh/contrib/airline/xtermlight.bash create mode 100644 .local/src/blesh/contrib/bash-preexec.bash create mode 100644 .local/src/blesh/contrib/config/execmark.bash create mode 100644 .local/src/blesh/contrib/fzf-completion.bash create mode 100644 .local/src/blesh/contrib/fzf-git.bash create mode 100644 .local/src/blesh/contrib/fzf-initialize.bash create mode 100644 .local/src/blesh/contrib/fzf-key-bindings.bash create mode 100644 .local/src/blesh/contrib/prompt-defer.bash create mode 100644 .local/src/blesh/contrib/prompt-elapsed.bash create mode 100644 .local/src/blesh/contrib/prompt-git.bash create mode 100644 .local/src/blesh/contrib/prompt-vim-mode.bash (limited to '.local/src/blesh/contrib') diff --git a/.local/src/blesh/contrib/airline/atomic.bash b/.local/src/blesh/contrib/airline/atomic.bash new file mode 100644 index 0000000..2a05808 --- /dev/null +++ b/.local/src/blesh/contrib/airline/atomic.bash @@ -0,0 +1,42 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/atomic.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +#---------------------------------------------------------------- +# ___ __ _ +# / | / /_____ ____ ___ (_)____ +# / /| |/ __/ __ \/ __ `__ \/ / ___/ +# / ___ / /_/ /_/ / / / / / / / /__ +# /_/ |_\__/\____/_/ /_/ /_/_/\___/ +# +#---------------------------------------------------------------- +# Theme : Atomic +# Version : 2.1.0 +# License : MIT +# Author : Gerard Bajona +# URL : https://github.com/gerardbm/atomic +# ---------------------------------------------------------------- +# Colors will be adapted to the current colorscheme. For better +# contrast use the atomic colorscheme: it has ten color palettes +# with sixteen colors selected procedurally (algorithms). +# +# Atomic colorscheme: https://github.com/gerardbm/vim-atomic +# ---------------------------------------------------------------- + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:atomic/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_a_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_a_insert fg=-1,bg=29 # fg=-1,bg=#2e8b57 + ble-face -s vim_airline_a_replace fg=-1,bg=231 # fg=-1,bg=#ffffff + ble-face -s vim_airline_a_visual fg=-1,bg=196 # fg=-1,bg=#ff0000 + ble-face -s vim_airline_b fg=-1,bg=124 # fg=-1,bg=#a52a2a + ble-face -s vim_airline_b_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c_inactive fg=124,bg=-1 # fg=#a52a2a,bg=-1 + ble-face -s vim_airline_c_insert fg=29,bg=-1 # fg=#2e8b57,bg=-1 + ble-face -s vim_airline_c_replace fg=231,bg=-1 # fg=#ffffff,bg=-1 + ble-face -s vim_airline_c_visual fg=196,bg=-1 # fg=#ff0000,bg=-1 +} diff --git a/.local/src/blesh/contrib/airline/dark.bash b/.local/src/blesh/contrib/airline/dark.bash new file mode 100644 index 0000000..47bf5a6 --- /dev/null +++ b/.local/src/blesh/contrib/airline/dark.bash @@ -0,0 +1,30 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=190 # fg=#00005f,bg=#dfff00 + ble-face -s vim_airline_a_commandline fg=17,bg=40 # fg=#00005f,bg=#00d700 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=17,bg=45 # fg=#00005f,bg=#00dfff + ble-face -s vim_airline_a_replace fg=231,bg=124 # fg=#ffffff,bg=#af0000 + ble-face -s vim_airline_a_visual fg=16,bg=214 # fg=#000000,bg=#ffaf00 + ble-face -s vim_airline_b fg=231,bg=238 # fg=#ffffff,bg=#444444 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_b_insert fg=231,bg=27 # fg=#ffffff,bg=#005fff + ble-face -s vim_airline_b_visual fg=16,bg=202 # fg=#000000,bg=#ff5f00 + ble-face -s vim_airline_c fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert fg=231,bg=18 # fg=#ffffff,bg=#000080 + ble-face -s vim_airline_c_insert_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_normal_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_replace_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_c_visual fg=231,bg=52 # fg=#ffffff,bg=#5f0000 + ble-face -s vim_airline_c_visual_modified fg=231,bg=53 # fg=#ffffff,bg=#5f005f + ble-face -s vim_airline_z_replace fg=17,bg=45 # fg=#00005f,bg=#00dfff +} diff --git a/.local/src/blesh/contrib/airline/dark_minimal.bash b/.local/src/blesh/contrib/airline/dark_minimal.bash new file mode 100644 index 0000000..2285147 --- /dev/null +++ b/.local/src/blesh/contrib/airline/dark_minimal.bash @@ -0,0 +1,13 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/dark_minimal.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:dark_minimal/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=190 # fg=#00005f,bg=#dfff00 + ble-face -s vim_airline_b fg=231,bg=238 # fg=#ffffff,bg=#444444 + ble-face -s vim_airline_c fg=158,bg=234 # fg=#9cffd3,bg=#202020 +} diff --git a/.local/src/blesh/contrib/airline/google_dark.bash b/.local/src/blesh/contrib/airline/google_dark.bash new file mode 100644 index 0000000..6a6c47f --- /dev/null +++ b/.local/src/blesh/contrib/airline/google_dark.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/google_dark.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by danrneal (http://github.com/danrneal) +# Google Scheme by Lisie Michel (https://github.com/google/vim-colorscheme-primary/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:google_dark/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=16,bg=71 # fg=#202124,bg=#34a853 + ble-face -s vim_airline_a_inactive fg=16,bg=59 # fg=#202124,bg=#5f6368 + ble-face -s vim_airline_a_insert fg=16,bg=69 # fg=#202124,bg=#4285f4 + ble-face -s vim_airline_a_replace fg=16,bg=167 # fg=#202124,bg=#ea4335 + ble-face -s vim_airline_a_visual fg=16,bg=214 # fg=#202124,bg=#fbbc04 + ble-face -s vim_airline_b fg=189,bg=59 # fg=#e8eaed,bg=#5f6368 + ble-face -s vim_airline_c fg=71,bg=16 # fg=#34a853,bg=#202124 + ble-face -s vim_airline_c_inactive fg=59,bg=16 # fg=#5f6368,bg=#202124 + ble-face -s vim_airline_c_inactive_modified fg=231,bg=16 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_insert fg=69,bg=16 # fg=#4285f4,bg=#202124 + ble-face -s vim_airline_c_insert_modified fg=231,bg=16 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_normal_modified fg=231,bg=16 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_replace fg=167,bg=16 # fg=#ea4335,bg=#202124 + ble-face -s vim_airline_c_replace_modified fg=231,bg=16 # fg=#ffffff,bg=#202124 + ble-face -s vim_airline_c_visual fg=214,bg=16 # fg=#fbbc04,bg=#202124 + ble-face -s vim_airline_c_visual_modified fg=231,bg=16 # fg=#ffffff,bg=#202124 +} diff --git a/.local/src/blesh/contrib/airline/google_light.bash b/.local/src/blesh/contrib/airline/google_light.bash new file mode 100644 index 0000000..1bef3d9 --- /dev/null +++ b/.local/src/blesh/contrib/airline/google_light.bash @@ -0,0 +1,28 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/google_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# vim-airline template by danrneal (http://github.com/danrneal) +# Google Scheme by Lisie Michel (https://github.com/google/vim-colorscheme-primary/) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:google_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=71 # fg=#ffffff,bg=#34a853 + ble-face -s vim_airline_a_inactive fg=231,bg=189 # fg=#ffffff,bg=#e8eaed + ble-face -s vim_airline_a_insert fg=231,bg=69 # fg=#ffffff,bg=#4285f4 + ble-face -s vim_airline_a_replace fg=231,bg=167 # fg=#ffffff,bg=#ea4335 + ble-face -s vim_airline_a_visual fg=231,bg=214 # fg=#ffffff,bg=#fbbc04 + ble-face -s vim_airline_b fg=59,bg=189 # fg=#5f6368,bg=#e8eaed + ble-face -s vim_airline_c fg=71,bg=231 # fg=#34a853,bg=#ffffff + ble-face -s vim_airline_c_inactive fg=189,bg=231 # fg=#e8eaed,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=16,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_insert fg=69,bg=231 # fg=#4285f4,bg=#ffffff + ble-face -s vim_airline_c_insert_modified fg=16,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_normal_modified fg=16,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_replace fg=167,bg=231 # fg=#ea4335,bg=#ffffff + ble-face -s vim_airline_c_replace_modified fg=16,bg=231 # fg=#202124,bg=#ffffff + ble-face -s vim_airline_c_visual fg=214,bg=231 # fg=#fbbc04,bg=#ffffff + ble-face -s vim_airline_c_visual_modified fg=16,bg=231 # fg=#202124,bg=#ffffff +} diff --git a/.local/src/blesh/contrib/airline/landscape.bash b/.local/src/blesh/contrib/airline/landscape.bash new file mode 100644 index 0000000..d3154ac --- /dev/null +++ b/.local/src/blesh/contrib/airline/landscape.bash @@ -0,0 +1,34 @@ +# From github:itchyny/landscape.vim/autoload/airline/themes/landscape.vim +# The MIT License (MIT) +# Copyright (c) 2012-2015 itchyny. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:landscape/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=21,bg=231 # fg=#0000ff,bg=#ffffff + ble-face -s vim_airline_a_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_a_insert fg=22,bg=231 # fg=#005f00,bg=#ffffff + ble-face -s vim_airline_a_replace fg=124,bg=231 # fg=#af0000,bg=#ffffff + ble-face -s vim_airline_a_visual fg=57,bg=231 # fg=#5f00ff,bg=#ffffff + ble-face -s vim_airline_b fg=231,bg=21 # fg=#ffffff,bg=#0000ff + ble-face -s vim_airline_b_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_b_insert fg=231,bg=22 # fg=#ffffff,bg=#005f00 + ble-face -s vim_airline_b_replace fg=231,bg=124 # fg=#ffffff,bg=#af0000 + ble-face -s vim_airline_b_visual fg=231,bg=57 # fg=#ffffff,bg=#5f00ff + ble-face -s vim_airline_c fg=231,bg=236 # fg=#ffffff,bg=#303030 + ble-face -s vim_airline_c_inactive fg=236,bg=233 # fg=#303030,bg=#121212 + ble-face -s vim_airline_x_insert fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_normal fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_replace fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_x_visual fg=250,bg=240 # fg=#bcbcbc,bg=#585858 + ble-face -s vim_airline_y_insert fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_normal fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_replace fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_y_visual fg=236,bg=245 # fg=#303030,bg=#8a8a8a + ble-face -s vim_airline_z_insert fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_normal fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_replace fg=236,bg=252 # fg=#303030,bg=#d0d0d0 + ble-face -s vim_airline_z_visual fg=236,bg=252 # fg=#303030,bg=#d0d0d0 +} diff --git a/.local/src/blesh/contrib/airline/light.bash b/.local/src/blesh/contrib/airline/light.bash new file mode 100644 index 0000000..26362f4 --- /dev/null +++ b/.local/src/blesh/contrib/airline/light.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=231,bg=27 # fg=#ffffff,bg=#005fff + ble-face -s vim_airline_a_inactive fg=241,bg=249 # fg=#666666,bg=#b2b2b2 + ble-face -s vim_airline_a_insert fg=231,bg=29 # fg=#ffffff,bg=#00875f + ble-face -s vim_airline_a_replace fg=22,bg=196 # fg=#005f00,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=231,bg=202 # fg=#ffffff,bg=#ff5f00 + ble-face -s vim_airline_b fg=18,bg=45 # fg=#000087,bg=#00dfff + ble-face -s vim_airline_b_inactive fg=245,bg=252 # fg=#8a8a8a,bg=#d0d0d0 + ble-face -s vim_airline_b_insert fg=22,bg=42 # fg=#005f00,bg=#00df87 + ble-face -s vim_airline_b_visual fg=52,bg=214 # fg=#5f0000,bg=#ffaf00 + ble-face -s vim_airline_c fg=27,bg=159 # fg=#005fff,bg=#afffff + ble-face -s vim_airline_c_inactive fg=248,bg=231 # fg=#a8a8a8,bg=#ffffff + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#df0000,bg=0 + ble-face -s vim_airline_c_insert fg=23,bg=156 # fg=#005f5f,bg=#afff87 + ble-face -s vim_airline_c_insert_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_normal_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_replace_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_c_visual fg=166,bg=228 # fg=#df5f00,bg=#ffff87 + ble-face -s vim_airline_c_visual_modified fg=160,bg=224 # fg=#df0000,bg=#ffdfdf + ble-face -s vim_airline_z_replace fg=231,bg=29 # fg=#ffffff,bg=#00875f +} diff --git a/.local/src/blesh/contrib/airline/minimalist.bash b/.local/src/blesh/contrib/airline/minimalist.bash new file mode 100644 index 0000000..ecefcd3 --- /dev/null +++ b/.local/src/blesh/contrib/airline/minimalist.bash @@ -0,0 +1,31 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/minimalist.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Minimalist Airline - A Material Color Scheme +# +# Author: Diki Ananta +# Repository: https://github.com/dikiaap/minimalist +# Version: 2.0 +# License: MIT + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:minimalist/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=239,bg=249 # fg=#4d4d4d,bg=#b3b3b3 + ble-face -s vim_airline_a_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_b fg=236,bg=247 # fg=#333333,bg=#999999 + ble-face -s vim_airline_b_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_c fg=236,bg=252 # fg=#333333,bg=#cccccc + ble-face -s vim_airline_c_inactive fg=235,bg=252 # fg=#262626,bg=#cccccc + ble-face -s vim_airline_error fg=234,bg=167 # fg=#1c1c1c,bg=#d75f5f + ble-face -s vim_airline_error_default fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=234,bg=249 # fg=#1c1c1c,bg=#b3b3b3 + ble-face -s vim_airline_term_default fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_warning fg=234,bg=215 # fg=#1c1c1c,bg=#ffaf5f + ble-face -s vim_airline_warning_default fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/src/blesh/contrib/airline/monochrome.bash b/.local/src/blesh/contrib/airline/monochrome.bash new file mode 100644 index 0000000..95daf85 --- /dev/null +++ b/.local/src/blesh/contrib/airline/monochrome.bash @@ -0,0 +1,22 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/monochrome.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:monochrome/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_b fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_c fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_error fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_error_default fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_term fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_term_default fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_term_inactive fg=158,bg=234 # fg=#9cffd3,bg=#202020 + ble-face -s vim_airline_warning fg=-1,bg=-1 # fg=-1,bg=-1 + ble-face -s vim_airline_warning_default fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/src/blesh/contrib/airline/solarized.bash b/.local/src/blesh/contrib/airline/solarized.bash new file mode 100644 index 0000000..8cb0dab --- /dev/null +++ b/.local/src/blesh/contrib/airline/solarized.bash @@ -0,0 +1,33 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/solarized.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:solarized/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=224,bg=66 # fg=#eee8d5,bg=#657b83 + ble-face -s vim_airline_a_inactive fg=224,bg=102 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_a_insert fg=224,bg=136 # fg=#eee8d5,bg=#b58900 + ble-face -s vim_airline_a_replace fg=224,bg=166 # fg=#eee8d5,bg=#dc322f + ble-face -s vim_airline_a_visual fg=224,bg=168 # fg=#eee8d5,bg=#d33682 + ble-face -s vim_airline_b fg=224,bg=109 # fg=#eee8d5,bg=#93a1a1 + ble-face -s vim_airline_b_inactive fg=224,bg=102 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_c fg=109,bg=224 # fg=#93a1a1,bg=#eee8d5 + ble-face -s vim_airline_c_inactive fg=224,bg=102 # fg=#eee8d5,bg=#839496 + ble-face -s vim_airline_c_inactive_modified fg=23,bg=0 # fg=#073642,bg=0 + ble-face -s vim_airline_c_insert_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_normal_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_replace_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_c_visual_modified fg=60,bg=224 # fg=#586e75,bg=#eee8d5 + ble-face -s vim_airline_error fg=230,bg=166 # fg=#fdf6e3,bg=#cb4b16 + ble-face -s vim_airline_error_default fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_insert fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_normal_modified fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_visual fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=230,bg=166 # fg=#fdf6e3,bg=#cb4b16 + ble-face -s vim_airline_warning_default fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 +} diff --git a/.local/src/blesh/contrib/airline/solarized_flood.bash b/.local/src/blesh/contrib/airline/solarized_flood.bash new file mode 100644 index 0000000..2726fe9 --- /dev/null +++ b/.local/src/blesh/contrib/airline/solarized_flood.bash @@ -0,0 +1,49 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/solarized_flood.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +# Name: Solarized Flood +# Changed: June 3 2018 +# Maintainer: https://github.com/Neur1n +# Description: +# A vim-airline theme made based on and tested with the Solarized colorscheme +# (https://github.com/frankier/neovim-colors-solarized-truecolor-only) in +# Windows 10 OS and GVim 8.1. +# +# This script is based on the 'dark' theme. The 'inactive' and 'ctrlp' parts +# were not changed. +# +# It is call 'flood' since the statusline and the tabline will be highlighted +# with the 'base03' color in Solarized (dark). If you use the dark Solarized +# colorscheme for Vim and, in Windows, set 'Personalization-Colors-Choose +# your color - Custom color' to be '#002B36' (*), then most parts of the GVim +# window will be 'flooded' with the color. +# NOTE: This will make some components of the airline less distinguishable +# from the others. If anyone has better ideas, I will be happy to take +# a conversation with you. :) + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:solarized_flood/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=17,bg=100 # fg=#002b36,bg=#859900 + ble-face -s vim_airline_a_inactive fg=239,bg=234 # fg=#4e4e4e,bg=#1c1c1c + ble-face -s vim_airline_a_insert fg=17,bg=36 # fg=#002b36,bg=#2aa198 + ble-face -s vim_airline_a_replace fg=17,bg=166 # fg=#002b36,bg=#dc322f + ble-face -s vim_airline_a_visual fg=17,bg=136 # fg=#002b36,bg=#b58900 + ble-face -s vim_airline_b fg=109,bg=17 # fg=#93a1a1,bg=#002b36 + ble-face -s vim_airline_b_inactive fg=239,bg=235 # fg=#4e4e4e,bg=#262626 + ble-face -s vim_airline_c fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_c_inactive fg=239,bg=236 # fg=#4e4e4e,bg=#303030 + ble-face -s vim_airline_c_inactive_modified fg=97,bg=0 # fg=#875faf,bg=0 + ble-face -s vim_airline_c_insert fg=32,bg=17 # fg=#268bd2,bg=#002b36 + ble-face -s vim_airline_c_insert_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_normal_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_replace_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_c_visual fg=166,bg=17 # fg=#dc322f,bg=#002b36 + ble-face -s vim_airline_c_visual_modified fg=168,bg=17 # fg=#d33682,bg=#002b36 + ble-face -s vim_airline_z_insert fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_z_normal fg=100,bg=17 # fg=#859900,bg=#002b36 + ble-face -s vim_airline_z_replace fg=36,bg=17 # fg=#2aa198,bg=#002b36 + ble-face -s vim_airline_z_visual fg=136,bg=17 # fg=#b58900,bg=#002b36 +} diff --git a/.local/src/blesh/contrib/airline/term.bash b/.local/src/blesh/contrib/airline/term.bash new file mode 100644 index 0000000..eebdec5 --- /dev/null +++ b/.local/src/blesh/contrib/airline/term.bash @@ -0,0 +1,38 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/term.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:term/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=16,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_a_insert fg=16,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_insert_modified fg=16,bg=221 # fg=#141413,bg=#fade3e + ble-face -s vim_airline_a_normal_modified fg=16,bg=114 # fg=#141413,bg=#86cd74 + ble-face -s vim_airline_a_replace fg=16,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_replace_modified fg=16,bg=167 # fg=#141413,bg=#e55345 + ble-face -s vim_airline_a_visual fg=16,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_a_visual_modified fg=16,bg=110 # fg=#141413,bg=#7cb0e6 + ble-face -s vim_airline_b fg=186,bg=58 # fg=#cae682,bg=#32322f + ble-face -s vim_airline_b_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_b_insert fg=221,bg=58 # fg=#fde76e,bg=#32322f + ble-face -s vim_airline_b_insert_modified fg=221,bg=59 # fg=#fade3e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=114,bg=59 # fg=#86cd74,bg=#40403c + ble-face -s vim_airline_b_replace fg=173,bg=58 # fg=#e5786d,bg=#32322f + ble-face -s vim_airline_b_replace_modified fg=167,bg=59 # fg=#e55345,bg=#40403c + ble-face -s vim_airline_b_visual fg=153,bg=58 # fg=#b5d3f3,bg=#32322f + ble-face -s vim_airline_b_visual_modified fg=110,bg=59 # fg=#7cb0e6,bg=#40403c + ble-face -s vim_airline_c fg=186,bg=235 # fg=#cae682,bg=#242424 + ble-face -s vim_airline_c_inactive fg=243,bg=235 # fg=#767676,bg=#242424 + ble-face -s vim_airline_c_inactive_modified fg=114,bg=0 # fg=#86cd74,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=235 # fg=#fde76e,bg=#242424 + ble-face -s vim_airline_c_insert_modified fg=221,bg=235 # fg=#fade3e,bg=#242424 + ble-face -s vim_airline_c_normal_modified fg=114,bg=235 # fg=#86cd74,bg=#242424 + ble-face -s vim_airline_c_replace fg=173,bg=235 # fg=#e5786d,bg=#242424 + ble-face -s vim_airline_c_replace_modified fg=167,bg=235 # fg=#e55345,bg=#242424 + ble-face -s vim_airline_c_visual fg=153,bg=235 # fg=#b5d3f3,bg=#242424 + ble-face -s vim_airline_c_visual_modified fg=110,bg=235 # fg=#7cb0e6,bg=#242424 +} diff --git a/.local/src/blesh/contrib/airline/term_light.bash b/.local/src/blesh/contrib/airline/term_light.bash new file mode 100644 index 0000000..e0ffd22 --- /dev/null +++ b/.local/src/blesh/contrib/airline/term_light.bash @@ -0,0 +1,38 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/term_light.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:term_light/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=114 # fg=#f0f0f0,bg=#86cd74 + ble-face -s vim_airline_a_inactive fg=243,bg=102 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_a_insert fg=255,bg=221 # fg=#f0f0f0,bg=#fade3e + ble-face -s vim_airline_a_insert_modified fg=16,bg=221 # fg=#141413,bg=#fde76e + ble-face -s vim_airline_a_normal_modified fg=16,bg=186 # fg=#141413,bg=#cae682 + ble-face -s vim_airline_a_replace fg=255,bg=167 # fg=#f0f0f0,bg=#e55345 + ble-face -s vim_airline_a_replace_modified fg=16,bg=173 # fg=#141413,bg=#e5786d + ble-face -s vim_airline_a_visual fg=255,bg=110 # fg=#f0f0f0,bg=#7cb0e6 + ble-face -s vim_airline_a_visual_modified fg=16,bg=153 # fg=#141413,bg=#b5d3f3 + ble-face -s vim_airline_b fg=114,bg=188 # fg=#86cd74,bg=#deded9 + ble-face -s vim_airline_b_inactive fg=243,bg=102 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_b_insert fg=221,bg=188 # fg=#fade3e,bg=#deded9 + ble-face -s vim_airline_b_insert_modified fg=221,bg=59 # fg=#fde76e,bg=#40403c + ble-face -s vim_airline_b_normal_modified fg=186,bg=59 # fg=#cae682,bg=#40403c + ble-face -s vim_airline_b_replace fg=167,bg=188 # fg=#e55345,bg=#deded9 + ble-face -s vim_airline_b_replace_modified fg=173,bg=59 # fg=#e5786d,bg=#40403c + ble-face -s vim_airline_b_visual fg=110,bg=188 # fg=#7cb0e6,bg=#deded9 + ble-face -s vim_airline_b_visual_modified fg=153,bg=59 # fg=#b5d3f3,bg=#40403c + ble-face -s vim_airline_c fg=114,bg=102 # fg=#86cd74,bg=#888a85 + ble-face -s vim_airline_c_inactive fg=243,bg=102 # fg=#767676,bg=#888a85 + ble-face -s vim_airline_c_inactive_modified fg=186,bg=0 # fg=#cae682,bg=0 + ble-face -s vim_airline_c_insert fg=221,bg=102 # fg=#fade3e,bg=#888a85 + ble-face -s vim_airline_c_insert_modified fg=221,bg=102 # fg=#fde76e,bg=#888a85 + ble-face -s vim_airline_c_normal_modified fg=186,bg=102 # fg=#cae682,bg=#888a85 + ble-face -s vim_airline_c_replace fg=167,bg=102 # fg=#e55345,bg=#888a85 + ble-face -s vim_airline_c_replace_modified fg=173,bg=102 # fg=#e5786d,bg=#888a85 + ble-face -s vim_airline_c_visual fg=110,bg=102 # fg=#7cb0e6,bg=#888a85 + ble-face -s vim_airline_c_visual_modified fg=153,bg=102 # fg=#b5d3f3,bg=#888a85 +} diff --git a/.local/src/blesh/contrib/airline/transparent.bash b/.local/src/blesh/contrib/airline/transparent.bash new file mode 100644 index 0000000..30d94b6 --- /dev/null +++ b/.local/src/blesh/contrib/airline/transparent.bash @@ -0,0 +1,33 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/transparent.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# +#FROM https://github.com/khatiba + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:transparent/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=103,bg=-1 # fg=#8d96a1,bg=-1 + ble-face -s vim_airline_a_inactive fg=16,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_a_insert fg=16,bg=150 # fg=#1d1f21,bg=#bbe67e + ble-face -s vim_airline_a_normal_modified fg=16,bg=215 # fg=#1d1f21,bg=#ffae57 + ble-face -s vim_airline_a_replace fg=16,bg=183 # fg=#1d1f21,bg=#d4bfff + ble-face -s vim_airline_a_visual fg=16,bg=204 # fg=#1d1f21,bg=#f07178 + ble-face -s vim_airline_b fg=59,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_b_inactive fg=16,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_c fg=59,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_c_inactive_modified fg=215,bg=-1 # fg=#ffae57,bg=-1 + ble-face -s vim_airline_error fg=16,bg=204 # fg=#1d1f21,bg=#f07178 + ble-face -s vim_airline_error_default fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_error_inactive fg=16,bg=88 # fg=#000000,bg=#990000 + ble-face -s vim_airline_warning fg=16,bg=215 # fg=#1d1f21,bg=#ffae57 + ble-face -s vim_airline_warning_default fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_warning_inactive fg=16,bg=166 # fg=#000000,bg=#df5f00 + ble-face -s vim_airline_x_inactive fg=16,bg=-1 # fg=#1d1f21,bg=-1 + ble-face -s vim_airline_z_insert fg=150,bg=-1 # fg=#bbe67e,bg=-1 + ble-face -s vim_airline_z_normal fg=59,bg=-1 # fg=#3f4b59,bg=-1 + ble-face -s vim_airline_z_normal_modified fg=215,bg=-1 # fg=#ffae57,bg=-1 + ble-face -s vim_airline_z_replace fg=183,bg=-1 # fg=#d4bfff,bg=-1 + ble-face -s vim_airline_z_visual fg=204,bg=-1 # fg=#f07178,bg=-1 +} diff --git a/.local/src/blesh/contrib/airline/xtermlight.bash b/.local/src/blesh/contrib/airline/xtermlight.bash new file mode 100644 index 0000000..f8d23c1 --- /dev/null +++ b/.local/src/blesh/contrib/airline/xtermlight.bash @@ -0,0 +1,29 @@ +# From github:vim-airline/vim-airline-themes/autoload/airline/themes/xtermlight.vim +# The MIT License (MIT) +# Copyright (C) 2013-2021 Bailey Ling & Contributors. +# + +ble-import lib/vim-airline + +function ble/lib/vim-airline/theme:xtermlight/initialize { + ble-face -r vim_airline_@ + ble-face -s vim_airline_a fg=255,bg=27 # fg=#eeeeee,bg=#005fff + ble-face -s vim_airline_a_inactive fg=242,bg=249 # fg=#6c6c6c,bg=#b2b2b2 + ble-face -s vim_airline_a_insert fg=255,bg=29 # fg=#eeeeee,bg=#00875f + ble-face -s vim_airline_a_replace fg=22,bg=196 # fg=#005f00,bg=#ff0000 + ble-face -s vim_airline_a_visual fg=255,bg=202 # fg=#eeeeee,bg=#ff5f00 + ble-face -s vim_airline_b fg=18,bg=45 # fg=#000087,bg=#00d7ff + ble-face -s vim_airline_b_inactive fg=245,bg=252 # fg=#8a8a8a,bg=#d0d0d0 + ble-face -s vim_airline_b_insert fg=22,bg=42 # fg=#005f00,bg=#00d787 + ble-face -s vim_airline_b_visual fg=52,bg=214 # fg=#5f0000,bg=#ffaf00 + ble-face -s vim_airline_c fg=27,bg=159 # fg=#005fff,bg=#afffff + ble-face -s vim_airline_c_inactive fg=248,bg=255 # fg=#a8a8a8,bg=#eeeeee + ble-face -s vim_airline_c_inactive_modified fg=160,bg=0 # fg=#d70000,bg=0 + ble-face -s vim_airline_c_insert fg=23,bg=156 # fg=#005f5f,bg=#afff87 + ble-face -s vim_airline_c_insert_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_normal_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_replace_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_c_visual fg=166,bg=228 # fg=#d75f00,bg=#ffff87 + ble-face -s vim_airline_c_visual_modified fg=160,bg=224 # fg=#d70000,bg=#ffdfdf + ble-face -s vim_airline_z_replace fg=255,bg=29 # fg=#eeeeee,bg=#00875f +} diff --git a/.local/src/blesh/contrib/bash-preexec.bash b/.local/src/blesh/contrib/bash-preexec.bash new file mode 100644 index 0000000..668aabe --- /dev/null +++ b/.local/src/blesh/contrib/bash-preexec.bash @@ -0,0 +1,154 @@ +# ble/contrib/bash-preexec.bash (C) 2022, akinomyoga + +## @arr[in] precmd_functions +## @arr[in] preexec_functions +## The functions registered to these arrays are executed on PRECMD and +## PREEXEC hooks, respectively. +## +## @fn[in] precmd +## @fn[in] preexec +## If these functions are defined, they are executed on PRECMD and PREEXEC +## hooks, respectively, through "precmd_functions" and "preexec_functions". +## +## +## * Integration with bash-preexec.sh (https://github.com/rcaloras/bash-preexec) +## +## Although this script works without bash-preexec, it provides a better +## integration with bash-preexec when bash-preexec is loaded. The +## integration relies on the following public API of bash-preexec. +## +## @fn __bp_precmd_invoke_functions lastexit lastarg +## @fn __bp_preexec_invoke_functions lastexit lastarg this_command +## @fn __bp_uninstall +## @var __bp_trapdebug_string +## @var __bp_install_string + +function ble/contrib/bash-preexec/add-convenience-functions { + ble/array#remove precmd_functions precmd + ble/array#remove preexec_functions preexec + ble/array#unshift precmd_functions precmd + ble/array#unshift preexec_functions preexec +} + +function ble/contrib/bash-preexec/precmd.hook { + local __lastexit=$? __lastarg=$_ + + # Emulate bash-preexec variables + __bp_last_ret_value=$__lastexit + BP_PIPESTATUS=("${BLE_PIPESTATUS[@]}") + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_precmd_invoke_functions; then + __bp_precmd_invoke_functions "$__lastexit" "$__lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local __hook + for __hook in "${precmd_functions[@]}"; do + if builtin type -t "$__hook" &>/dev/null; then + ble/util/setexit "$__lastexit" "$__lastarg" + "$__hook" + fi + done + fi +} + +function ble/contrib/bash-preexec/preexec.hook { + local __lastexit=$? __lastarg=$_ __this_command=$1 + __bp_last_argument_prev_command=$__lastarg + + # local __bp_blesh_invoking_through_blesh=1 # XXX + if ble/is-function __bp_preexec_invoke_functions; then + __bp_preexec_invoke_functions "$__lastexit" "$__lastarg" + else + # For older bash-preexec.sh / without bash-preexec.sh + local __hook + for __hook in "${preexec_functions[@]}"; do + if builtin type -t "$__hook" &>/dev/null; then + ble/util/setexit "$__lastexit" "$__lastarg" + "$__hook" "$__this_command" + fi + done + fi +} + +## @fn ble/contrib/bash-preexec/attach.hook +## Remove bash-preexec hooks +function ble/contrib/bash-preexec/attach.hook { + local BP_TRAPDEBUG_STRING=${__bp_trapdebug_string:-'__bp_preexec_invoke_exec "$_"'} + + # Remove bash-preexec preexec hook in builtin DEBUG trap. + local trap_string q="'" Q="'\''" + ble/util/assign trap_string 'builtin trap -p DEBUG' + if [[ $trap_string == "trap -- '${BP_TRAPDEBUG_STRING//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + builtin eval -- "builtin $__bp_trap_string" + else + builtin trap - DEBUG + fi + fi + + if ble/is-function __bp_uninstall; then + __bp_uninstall + else + # For older bash-preexec.sh + + local BP_INSTALL_STRING=${__bp_install_string:-$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install'} + local BP_PROMPT_COMMAND_PREFIX=__bp_precmd_invoke_cmd + local BP_PROMPT_COMMAND_SUFFIX=__bp_interactive_mode + + # Remove __bp_install hook from PROMPT_COMMAND + if [[ ${PROMPT_COMMAND-} == *"$__bp_install_string"* ]]; then + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING[;$'\n']}" # Edge case of appending to PROMPT_COMMAND + PROMPT_COMMAND="${PROMPT_COMMAND//$BP_INSTALL_STRING}" + fi + + # Remove precmd hook from PROMPT_COMMAND + PROMPT_COMMAND=${PROMPT_COMMAND/#$BP_PROMPT_COMMAND_PREFIX$'\n'/$'\n'} + PROMPT_COMMAND=${PROMPT_COMMAND%$'\n'$BP_PROMPT_COMMAND_SUFFIX} + PROMPT_COMMAND=${PROMPT_COMMAND#$'\n'} + + # Remove preexec hook in the DEBUG trap + local q="'" Q="'\''" trap_string + ble/util/assign trap_string 'trap -p DEBUG' + if [[ $trap_string == "trap -- '${__bp_trapdebug_string//$q/$Q}' DEBUG" ]]; then + if [[ ${__bp_trap_string-} ]]; then + eval -- "$__bp_trap_string" + else + trap - DEBUG + fi + fi + fi +} + +## @fn ble/contrib/bash-preexec/detach.hook +function ble/contrib/bash-preexec/detach.hook { + # Reinstall bash-preexec hooks + local BP_INSTALL_STRING=${__bp_install_string-} + [[ ! $BP_INSTALL_STRING ]] && ble/is-function __bp_install && + BP_INSTALL_STRING=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' + + builtin eval -- "$__bp_install_string" + + # Note: 重複して登録される (古い bash-preexec.sh) かもしれないし、全 + # く登録されない (bash-preexec.sh をロードしていない時) かもしれない + # ので、ble.sh 側で末尾で一回呼び出す形に修正する。 + ble/contrib/bash-preexec/add-convenience-functions +} + +ble/contrib/bash-preexec/add-convenience-functions +blehook PRECMD-+=ble/contrib/bash-preexec/precmd.hook +blehook PREEXEC-+=ble/contrib/bash-preexec/preexec.hook +blehook ATTACH-+=ble/contrib/bash-preexec/attach.hook +blehook DETACH-+=ble/contrib/bash-preexec/detach.hook +if [[ ${bp_imported-${__bp_imported-}} ]]; then + ble/contrib/bash-preexec/attach.hook +fi + +# XXX: 以下は uninstall で削除しきれなかった時の為の保険。今の所不要に思われる。 +# __bp_blesh_check() { +# if [[ $BLE_ATTACHED && ! ${__bp_blesh_invoking_through_blesh-} ]]; then +# ble/contrib/bash-preexec/attach.hook +# fi +# } +# precmd_function+=(__bp_blesh_check) +# preexec_function+=(__bp_blesh_check) diff --git a/.local/src/blesh/contrib/config/execmark.bash b/.local/src/blesh/contrib/config/execmark.bash new file mode 100644 index 0000000..d8da0ce --- /dev/null +++ b/.local/src/blesh/contrib/config/execmark.bash @@ -0,0 +1,111 @@ +# blesh/contrib/config/execmark.bash (C) 2022, Koichi Murase +# +# Example setup +# +# ```bash +# # blerc +# ble-import -d contrib/config/execmark +# bleopt exec_elapsed_enabled='_ble_exec_time_tot>=1000' +# ``` +# + +function ble/contrib/config:execmark/.getsec { + local msec=$1 sec + if ((msec==0)); then + ret=0 + elif ((msec<1000)); then + ret=${msec}ms + else + ((sec=msec/1000,msec%=1000)) + msec=000$msec msec=${msec:${#msec}-3} + ret=$sec.$msec + fi +} + +function ble/contrib/config:execmark/postexec.hook { + local command=$_ble_edit_exec_BASH_COMMAND + + if ((_ble_edit_exec_lastexit)) || ble/exec/time#mark-enabled; then + local ret + local sgr=$'\e[;94m' sgrC=$'\e[38:5:244m' sgr0=$'\e[m' + ((_ble_edit_exec_lastexit)) && sgr=$'\e[;91m' + ble/color/face2sgr-ansi syntax_varname; local sgrV=$ret + ble/color/face2sgr-ansi command_function; local sgrS=$ret + ble/color/face2sgr-ansi varname_number; local sgrN=$ret + + # exit + local exit=$_ble_edit_exec_lastexit name= + if ((exit>=128)) && [[ ${name:=${_ble_builtin_trap_signames[exit&127]}} ]]; then + exit=$'\e[1m'"$name"$'\e[22m'" ($sgrN$exit$sgr)" + else + exit="exit $sgrN$exit$sgr" + fi + + # ata + local ata=$_ble_exec_time_ata + local d=${#ata} sec min hour + if ((d<=3)); then + ata=${ata}us + elif ((d<=5)); then + ata=${ata::d-3}.${ata:d-3:6-d}ms + elif ((d<=6)); then + ata=${ata::3}ms + elif ((d<=9)); then + ata=${ata::${#ata}-6}.${ata:${#ata}-6:3}s + elif ((sec=ata/(1000*1000),min=sec/60,sec%=60,min<100)); then + ata="${min}m${sec}s" + elif ((hour=min/60,min%=60,hour<100)); then + ata="${hour}h${min}m${ata}s" + else + ata="$((hour/24))d$((hour%24))h${min}m" + fi + ata="${sgrV}elapsed$sgr $sgrN$ata$sgr" + + # cpu + local cpu='--.-%' + if ((_ble_exec_time_tot)); then + cpu=$(((_ble_exec_time_usr+_ble_exec_time_sys)*1000/_ble_exec_time_tot)) + cpu=$((cpu/10)).$((cpu%10))% + fi + cpu="${sgrV}CPU$sgr $sgrN$cpu$sgr" + if [[ $_ble_exec_time_usr_self && $_ble_exec_time_sys_self ]]; then + local usr0=$_ble_exec_time_usr_self + local sys0=$_ble_exec_time_sys_self + local usr1=$((_ble_exec_time_usr-_ble_exec_time_usr_self)) + local sys1=$((_ble_exec_time_sys-_ble_exec_time_sys_self)) + + local ret max=0 + ble/contrib/config:execmark/.getsec "$usr0"; local usr0s=$ret + ble/contrib/config:execmark/.getsec "$sys0"; local sys0s=$ret + ((usr0>max)) && max=$usr0 + ((sys0>max)) && max=$sys0 + if ((usr1||sys1)); then + ble/contrib/config:execmark/.getsec "$usr1"; local usr1s=$ret + ble/contrib/config:execmark/.getsec "$sys1"; local sys1s=$ret + ((usr1>max)) && max=$usr1 + ((sys1>max)) && max=$sys1 + fi + + ((usr0==max)) && usr0s=$'\e[1m'$usr0s$'\e[22m' + ((sys0==max)) && sys0s=$'\e[1m'$sys0s$'\e[22m' + cpu="$cpu $sgrS(self)${sgrV}usr$sgrN$usr0s$sgr/${sgrV}sys$sgrN$sys0s$sgr" + if ((usr1||sys1)); then + ((usr1==max)) && usr1s=$'\e[1m'$usr1s$'\e[22m' + ((sys1==max)) && sys1s=$'\e[1m'$sys1s$'\e[22m' + cpu="$cpu+$sgrS(child)${sgrV}usr$sgrN${usr1s}$sgr/${sgrV}sys$sgrN${sys1s}$sgr" + fi + else + local ret + ble/contrib/config:execmark/.getsec "$_ble_exec_time_usr"; local usr=$ret + ble/contrib/config:execmark/.getsec "$_ble_exec_time_sys"; local sys=$ret + cpu="$cpu ${usr}usr/${sys}sys" + fi + + local msg=$sgr'[ble: '$exit', '$ata', '$cpu']'$sgr0 + local ret; ble/string#ltrim "$command"; msg="$msg${ret:+ $sgrC$ret$sgr0}" + x=0 y=0 g=0 LINES=1 ble/canvas/trace "$msg" confine:truncate + ble/util/buffer.print "$ret" + fi +} +bleopt exec_@_mark= +blehook POSTEXEC-+=ble/contrib/config:execmark/postexec.hook diff --git a/.local/src/blesh/contrib/fzf-completion.bash b/.local/src/blesh/contrib/fzf-completion.bash new file mode 100644 index 0000000..f6a4876 --- /dev/null +++ b/.local/src/blesh/contrib/fzf-completion.bash @@ -0,0 +1,49 @@ +# ble/contrib/fzf-completion.bash (C) 2020-2021, akinomyoga + +ble-import contrib/fzf-initialize + +[[ $- == *i* ]] || return 0 + +# fzf/shell/completion.bash を未ロードの時のみロードする +if ! ble/is-function _fzf_complete; then + if [[ -f $_ble_contrib_fzf_base/completion.bash ]]; then + source "$_ble_contrib_fzf_base/completion.bash" + elif [[ -f $_ble_contrib_fzf_base/shell/completion.bash ]]; then + source "$_ble_contrib_fzf_base/shell/completion.bash" + elif [[ $_ble_contrib_fzf_base == */share/fzf && -f /etc/bash_completion.d/fzf ]]; then + source /etc/bash_completion.d/fzf + fi +fi + +# clear blesh completer for cd +blehook/eval-after-load complete 'unset -f ble/cmdinfo/complete:cd' + +# patch fzf functions +ble/function#advice around __fzf_generic_path_completion _fzf_complete.advice +ble/function#advice around _fzf_complete _fzf_complete.advice +ble/function#advice around _fzf_complete_kill _fzf_complete.advice +function _fzf_complete.advice { + if [[ ! $_ble_attached ]]; then + ble/function#advice/do + return + fi + + [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return + compopt -o noquote -o ble/syntax-raw + COMP_WORDS=("${comp_words[@]}") COMP_CWORD=$comp_cword + COMP_LINE=$comp_line COMP_POINT=$comp_point + ble/function#push printf '[[ $1 == "\e[5n" ]] || builtin printf "$@"' + ble/term/leave-for-widget + ble/function#advice/do <> /dev/tty >&0 2>&0 + ble/term/enter-for-widget + ble/function#pop printf + ble/textarea#invalidate + + # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる + if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then + ble/complete/candidates/clear + [[ $old_cand_count ]] && + ! ble/variable#is-global old_cand_count && + old_cand_count=0 + fi +} diff --git a/.local/src/blesh/contrib/fzf-git.bash b/.local/src/blesh/contrib/fzf-git.bash new file mode 100644 index 0000000..156fa70 --- /dev/null +++ b/.local/src/blesh/contrib/fzf-git.bash @@ -0,0 +1,110 @@ +# ble/contrib/fzf-git.bash (C) 2020, akinomyoga +# Ported from https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236 + +ble-import contrib/fzf-initialize + +[[ $- == *i* ]] || return 0 + +# GIT heart FZF +# ------------- + +is_in_git_repo() { + git rev-parse HEAD > /dev/null 2>&1 +} + +fzf-down() { + fzf --height 50% "$@" --border +} + +gf() { + is_in_git_repo || return + git -c color.status=always status --short | + fzf-down -m --ansi --nth 2..,.. \ + --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500' | + cut -c4- | sed 's/.* -> //' +} + +gb() { + is_in_git_repo || return + git branch -a --color=always | grep -v '/HEAD\s' | sort | + fzf-down --ansi --multi --tac --preview-window right:70% \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | + sed 's/^..//' | cut -d' ' -f1 | + sed 's#^remotes/##' +} + +gt() { + is_in_git_repo || return + git tag --sort -version:refname | + fzf-down --multi --preview-window right:70% \ + --preview 'git show --color=always {} | head -'$LINES +} + +gh() { + is_in_git_repo || return + git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | + fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \ + --header 'Press CTRL-S to toggle sort' \ + --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always | head -'$LINES | + grep -o "[a-f0-9]\{7,\}" +} + +gr() { + is_in_git_repo || return + git remote -v | awk '{print $1 "\t" $2}' | uniq | + fzf-down --tac \ + --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" {1} | head -200' | + cut -d$'\t' -f1 +} + +# export FZF_DEFAULT_OPTS=--no-unicode + +: "${_ble_contrib_fzf_git_config=key-binding}" + +if [[ :$_ble_contrib_fzf_git_config: == *:original:* ]]; then + bind '"\er": redraw-current-line' + bind '"\C-g\C-f": "$(gf)\e\C-e\er"' + bind '"\C-g\C-b": "$(gb)\e\C-e\er"' + bind '"\C-g\C-t": "$(gt)\e\C-e\er"' + bind '"\C-g\C-h": "$(gh)\e\C-e\er"' + bind '"\C-g\C-r": "$(gr)\e\C-e\er"' + + # bind '"\C-g\C-f": "$(gf)\M-\C-e\M-\C-l"' + # bind '"\C-g\C-b": "$(gb)\M-\C-e\M-\C-l"' + # bind '"\C-g\C-t": "$(gt)\M-\C-e\M-\C-l"' + # bind '"\C-g\C-h": "$(gh)\M-\C-e\M-\C-l"' + # bind '"\C-g\C-r": "$(gr)\M-\C-e\M-\C-l"' +fi + +if [[ :$_ble_contrib_fzf_git_config: == *:key-binding:* ]]; then + function ble/widget/fzf-git { + ble/widget/insert-string "$($1)" + ble/textarea#invalidate + } + ble-bind -f 'C-g C-f' 'fzf-git gf' + ble-bind -f 'C-g C-b' 'fzf-git gb' + ble-bind -f 'C-g C-t' 'fzf-git gt' + ble-bind -f 'C-g C-h' 'fzf-git gh' + ble-bind -f 'C-g C-r' 'fzf-git gr' +fi + +if [[ :$_ble_contrib_fzf_git_config: == *:sabbrev:* ]]; then + function fzf-git.sabbrev { + COMPREPLY=$($1) + ble/textarea#invalidate + } + ble-sabbrev -m gf='fzf-git.sabbrev gf' + ble-sabbrev -m gb='fzf-git.sabbrev gb' + ble-sabbrev -m gt='fzf-git.sabbrev gt' + ble-sabbrev -m gh='fzf-git.sabbrev gh' + ble-sabbrev -m gr='fzf-git.sabbrev gr' +fi + +if [[ :$_ble_contrib_fzf_git_config: == *:arpeggio:* ]]; then + ble-import 'lib/vim-arpeggio.sh' + ble/lib/vim-arpeggio.sh/bind -f 'gf' 'fzf-git gf' + ble/lib/vim-arpeggio.sh/bind -f 'gb' 'fzf-git gb' + ble/lib/vim-arpeggio.sh/bind -f 'gt' 'fzf-git gt' + ble/lib/vim-arpeggio.sh/bind -f 'gh' 'fzf-git gh' + ble/lib/vim-arpeggio.sh/bind -f 'gr' 'fzf-git gr' +fi diff --git a/.local/src/blesh/contrib/fzf-initialize.bash b/.local/src/blesh/contrib/fzf-initialize.bash new file mode 100644 index 0000000..327c3fe --- /dev/null +++ b/.local/src/blesh/contrib/fzf-initialize.bash @@ -0,0 +1,52 @@ +# ble/contrib/fzf-initialize.bash (C) 2020-2021, akinomyoga + +# Usage: Please write the following lines in blerc +# +# ```bash +# _ble_contrib_fzf_base=/path/to/fzf-base-directory +# ble-import -d contrib/fzf-initialize +# ``` + +function ble/contrib/fzf-completion/initialize { + if [[ $_ble_contrib_fzf_base ]]; then + if [[ :$PATH: != *:"$_ble_contrib_fzf_base/bin":* ]]; then + export PATH="${PATH:+${PATH}:}$_ble_contrib_fzf_base/bin" + fi + if ! type fzf &>/dev/null; then + echo 'ble/contrib/fzf-initialize: "fzf" not found.' >&2 + return 1 + fi + else + local ret + if ! ble/util/assign ret 'type -p fzf 2>/dev/null'; then + echo 'ble/contrib/fzf: "fzf" not found.' >&2 + return 1 + fi + ble/util/readlink "$ret" + ret=${ret%/*} # fzf, fzf-linux_amd64, etc. + ret=${ret%/bin} # repo/bin/ + ret=${ret%/target} # repo/target (compile directory) + if [[ -s $ret/shell/key-bindings.bash ]]; then + _ble_contrib_fzf_base=$ret + elif [[ -d $ret/share/fzf/shell ]]; then + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/fzf/key-bindings.bash ]]; then + # NixOS package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/fzf + elif [[ -s $ret/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=$ret/share/doc/fzf/examples + elif [[ -d /usr/share/fzf/shell ]]; then + _ble_contrib_fzf_base=/usr/share/fzf + elif [[ -d /usr/share/doc/fzf/examples/key-bindings.bash ]]; then + # Ubuntu fzf package (https://github.com/akinomyoga/blesh-contrib/pull/5#issuecomment-1019394821) + _ble_contrib_fzf_base=/usr/share/doc/fzf/examples + else + echo 'ble/contrib/fzf: failed to find "fzf" base directory' >&2 + return 1 + fi + fi + return 0 +} + +ble/contrib/fzf-completion/initialize || return 1 diff --git a/.local/src/blesh/contrib/fzf-key-bindings.bash b/.local/src/blesh/contrib/fzf-key-bindings.bash new file mode 100644 index 0000000..9ef2774 --- /dev/null +++ b/.local/src/blesh/contrib/fzf-key-bindings.bash @@ -0,0 +1,54 @@ +# ble/contrib/fzf-key-bindings.bash (C) 2020, akinomyoga + +ble-import contrib/fzf-initialize + +[[ $- == *i* ]] || return 0 + +ble/function#push bind : +if [[ -f $_ble_contrib_fzf_base/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/key-bindings.bash" +elif [[ -f $_ble_contrib_fzf_base/shell/key-bindings.bash ]]; then + source "$_ble_contrib_fzf_base/shell/key-bindings.bash" +fi +ble/function#pop bind + +function ble/contrib/fzf-key-bindings/is-fzf-above-7c447bbd { + local def; ble/function#getdef __fzf_history__ + [[ $def == *READLINE_LINE=* ]] +} + +# CTRL-T - Paste the selected file path into the command line +ble-bind -m emacs -x C-t fzf-file-widget +ble-bind -m vi_imap -x C-t fzf-file-widget +ble-bind -m vi_nmap -s C-t 'i\C-t' + +# CTRL-R - Paste the selected command from history into the command line +ble-bind -m emacs -x C-r fzf-history-widget +ble-bind -m vi_imap -x C-r fzf-history-widget +ble-bind -m vi_nmap -s C-r 'i\C-r' +function fzf-history-widget { + READLINE_LINE=$(history -p "$(__fzf_history__)") + READLINE_POINT=${#READLINE_LINE} +} +((_ble_bash>=40000)) && + ble/contrib/fzf-key-bindings/is-fzf-above-7c447bbd && + function fzf-history-widget { __fzf_history__; } + +# ALT-C - cd into the selected directory +ble-bind -m emacs -c M-c 'eval "$(__fzf_cd__)"' +ble-bind -m vi_imap -c M-c 'eval "$(__fzf_cd__)"' +ble-bind -m vi_nmap -c M-c 'eval "$(__fzf_cd__)"' + +# patch fzf functions +ble/function#advice around fzf-file-widget ble/contrib/fzf-key-bindings.advice +ble/function#advice around __fzf_history__ ble/contrib/fzf-key-bindings.advice +ble/function#advice around __fzf_cd__ ble/contrib/fzf-key-bindings.advice +function ble/contrib/fzf-key-bindings.advice { + if [[ ! $_ble_attached ]]; then + ble/function#advice/do + return + fi + ble/term/leave-for-widget + ble/function#advice/do + ble/term/enter-for-widget +} diff --git a/.local/src/blesh/contrib/prompt-defer.bash b/.local/src/blesh/contrib/prompt-defer.bash new file mode 100644 index 0000000..ea289ff --- /dev/null +++ b/.local/src/blesh/contrib/prompt-defer.bash @@ -0,0 +1,150 @@ +# blesh/contrib/prompt-defer.bash (C) 2021, akinomyoga + +function ble/contrib/prompt-defer/.worker { + local prefix=$1 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + ble/contrib/prompt-defer:"$prefix"/worker + ble/util/put "$?" >| "$tmpfile" +} + +function ble/contrib/prompt-defer/.finalize { + local prefix=$1 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + ble/util/set "${prefix}_DEFER_bgpid" '' + + local ext + ble/util/readfile ext "$tmpfile" + ble/util/setexit "$ext" + ble/contrib/prompt-defer:"$prefix"/callback + + local ret; ble/util/clock + ble/util/set "${prefix}_DEFER_clock" "$ret" +} + +function ble/contrib/prompt-defer/clear { + local prefix=$1 script=' + [[ $PREFIX_DEFER_bgpid ]] && + builtin kill -9 "$PREFIX_DEFER_bgpid" &>/dev/null + PREFIX_DEFER_index= + PREFIX_DEFER_hash1= + PREFIX_DEFER_hash2= + PREFIX_DEFER_clock= + PREFIX_DEFER_bgpid=' + builtin eval -- "${script//PREFIX/$prefix}" +} + +## @fn ble/contrib/prompt-defer/submit prefix [hash1] [hash2] [opts] +## @param[in] prefix +## 関連変数の接頭辞を指定します。 +## +## @fn ble/comtrib/prompt-defer:$prefix/clear +## これまでに取得した情報を初期化します。後述の hash1 が前回の呼 +## び出しと異なる際に親シェルで呼び出されます。 +## +## @fn ble/comtrib/prompt-defer:$prefix/worker +## バックグラウンドの別プロセスで実行する処理を記述します。bash +## 4.0 以降ではサブシェルで呼び出されます。bash 4.0 未満では非同 +## 期に処理できない為、親シェルで実行されます。 +## +## @fn ble/comtrib/prompt-defer:$prefix/callback +## バックグラウンドの処理が完了した時に親シェルで呼び出される関 +## 数です。$? に worker の終了ステータスが設定された状態で呼び出 +## されます。 +## +## @var[internal] ${prefix}_DEFER_index +## @var[internal] ${prefix}_DEFER_hash1 +## @var[internal] ${prefix}_DEFER_hash2 +## @var[internal] ${prefix}_DEFER_clock +## @var[internal] ${prefix}_DEFER_bgpid +## 内部で使用する変数です。 +## +## @param[in] hash1 +## この値が前回の呼び出しと異なる時に強制的に情報の更新を行います。 +## +## @param[in] hash2 +## この値が前回の呼び出しと異なりかつ前回の呼び出しから十分時間が +## 経っている時に情報の更新を行います。 +## +## @param[in,opt] opts +## コロン区切りのオプションです。 +## +## cooling=NUM +## ミリ秒(整数)で情報のタイムアウトを指定します。プロンプト番号 +## または hash2 が前回と異なりかつ此処で指定した時間経過している +## 場合に再度情報更新を行います。 +## +## cooling-lines=NUM +## プロンプト更新回数を指定します。プロンプト番号が此処で指定し +## た回数以上変化している場合に再度情報更新を行います。 +## +## expires[=NUM] +## ミリ秒(整数)で情報のタイムアウトを指定します。プロンプト更新 +## の際に指定した時間経過している場合、強制的に情報更新を行いま +## す。既定値は 60000 (1分) です。 +## +## sync=NUM +## ミリ秒(整数)で同期的な情報取得のタイムアウトを指定します。 +## +function ble/contrib/prompt-defer/submit { + local prefix=$1 opts=$4 + local tmpfile=$_ble_base_run/$$.prompt.defer.$prefix + local rbgpid=${prefix}_DEFER_bgpid + + local opt_cooling=1000 opt_expires=none opt_nprompt=10 opt_sync=5 ret + ble/opts#extract-last-optarg "$opts" cooling && opt_cooling=$ret + ble/opts#extract-last-optarg "$opts" cooling-lines && opt_nprompt=$ret + ble/opts#extract-last-optarg "$opts" expires 60000 && opt_expires=$ret + ble/opts#extract-last-optarg "$opts" sync 60000 && opt_sync=$ret + + local oindex=${prefix}_DEFER_index; oindex=${!oindex-} + local ohash1=${prefix}_DEFER_hash1; ohash1=${!ohash1-} + local ohash2=${prefix}_DEFER_hash2; ohash2=${!ohash2-} + local oclock=${prefix}_DEFER_clock; oclock=${!oclock-} + + local nindex=$_ble_prompt_version + local nhash1=${2-done} # 強制 update を誘起する hashref + local nhash2=${3-done} # + + local update= + if [[ $nhash1 != "$ohash1" ]]; then + update=1 + ble/contrib/prompt-defer:"$prefix"/clear + elif [[ ! ${!rbgpid} ]]; then + if [[ $nindex:$nhash2 != "$oindex:$ohash2" ]]; then + if ((nindex<=oindex-opt_nprompt||oindex+opt_nprompt<=nindex)) || { local ret; ble/util/clock; ((ret>=oclock+opt_cooling)); }; then + update=1 + fi + elif [[ $opt_expires && $opt_expires != none ]]; then + if local ret; ble/util/clock; ((ret>=oclock+opt_expires)); then + update=1 + fi + fi + fi + + if [[ $update ]]; then + ble/util/set "${prefix}_DEFER_index" "$nindex" + ble/util/set "${prefix}_DEFER_hash1" "$nhash1" + ble/util/set "${prefix}_DEFER_hash2" "$nhash2" + + if ble/is-function ble/util/idle.push; then + if [[ ${!rbgpid} ]]; then + builtin kill -9 "${!rbgpid}" &>/dev/null + ble/util/idle.cancel "ble/contrib/prompt-defer/.finalize $prefix" + ble/util/set "$rbgpid" '' + fi + + : >| "$tmpfile" + ble/util/set "$rbgpid" "$(shopt -u huponexit; ble/contrib/prompt-defer/.worker $prefix < /dev/null &> /dev/null & ble/util/print $!)" + ((opt_sync>0)) && ble/util/msleep "$opt_sync" + if [[ -s $tmpfile ]]; then + ble/contrib/prompt-defer/.finalize "$prefix" + else + ble/util/idle.push -F "$tmpfile" "ble/contrib/prompt-defer/.finalize $prefix" + fi + + else + ble/contrib/prompt-defer:"$prefix"/worker + ble/contrib/prompt-defer:"$prefix"/callback + fi + fi +} diff --git a/.local/src/blesh/contrib/prompt-elapsed.bash b/.local/src/blesh/contrib/prompt-elapsed.bash new file mode 100644 index 0000000..b6b79ee --- /dev/null +++ b/.local/src/blesh/contrib/prompt-elapsed.bash @@ -0,0 +1,91 @@ +# blesh/contrib/prompt-elapsed.bash (C) 2022, Koichi Murase + +function ble/contrib/prompt-elapsed/output-sec.ps { + local sec=$1 min + ((min=sec/60,sec%=60)) + if ((min<100)); then + ble/prompt/print "${min}m${sec}s" + return 0 + fi + + local hour; ((hour=min/60,min%=60)) + if ((hour<100)); then + ble/prompt/print "${hour}h${min}m${sec}s" + return 0 + fi + + local day; ((day=hour/24,hour%=24)) + if ((day<365)); then + ble/prompt/print "${day}d${hour}h${min}m" + return 0 + fi + + local year; ((year=day/365,day%=365)) + ble/prompt/print "${year}y${day}d${hour}h" + return 0 +} + +function ble/contrib/prompt-elapsed/output-time-format.ps { + local msec=$1 + local d=${#msec} + if ((d<=3)); then + ble/prompt/print "${msec}msec" + return 0 + elif ((d<=5)); then + ble/prompt/print "${msec::d-3}.${msec:d-36-d}sec" + return 0 + fi + + local sec=$((msec/1000)) min + ((msec%=1000,min=sec/60,sec%=60)) + msec=000${msec}; msec=${msec:${#msec}-3} + if ((min<100)); then + ble/prompt/print "${min}m${sec}.${msec}s" + return 0 + fi + + ble/contrib/prompt-elapsed/output-sec.ps $((min*60+sec)) +} + +function ble/prompt/backslash:contrib/elapsed { + [[ $_ble_exec_time_ata ]] || return 1 + + local ata=$_ble_exec_time_ata + local d=${#ata} + if ((d<=3)); then + ble/prompt/print "${ata}usec" + return 0 + elif ((d<=6)); then + if ((d<=5)); then + ble/prompt/print "${ata::d-3}.${ata:d-3:6-d}msec" + else + ble/prompt/print "${ata::3}msec" + fi + return 0 + elif ((d<=8)); then + ble/prompt/print "${ata::d-6}.${ata:d-6:3}sec" + return 0 + fi + + ble/contrib/prompt-elapsed/output-sec.ps $((ata/1000000)) +} + +function ble/prompt/backslash:contrib/elapsed-real { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_tot" +} +function ble/prompt/backslash:contrib/elapsed-user { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_usr" +} +function ble/prompt/backslash:contrib/elapsed-sys { + [[ $_ble_exec_time_ata ]] || return 1 + ble/contrib/prompt-elapsed/output-time-format.ps "$_ble_exec_time_sys" +} +function ble/prompt/backslash:contrib/elapsed-cpu { + ((_ble_exec_time_tot)) || return 1 + + local pk=$(((_ble_exec_time_usr+_ble_exec_time_sys)*1000/_ble_exec_time_tot)) + ble/prompt/print "$((pk/10)).$((pk%10))%" + return 0 +} diff --git a/.local/src/blesh/contrib/prompt-git.bash b/.local/src/blesh/contrib/prompt-git.bash new file mode 100644 index 0000000..941905a --- /dev/null +++ b/.local/src/blesh/contrib/prompt-git.bash @@ -0,0 +1,250 @@ +# blesh/contrib/prompt-git.bash (C) 2020-2021, akinomyoga + +# bleopt prompt_rps1='\q{contrib/git-info}' +# bleopt prompt_rps1='\q{contrib/git-name}' +# bleopt prompt_rps1='\q{contrib/git-hash}' +# bleopt prompt_rps1='\q{contrib/git-branch}' +# bleopt prompt_rps1='\q{contrib/git-path}' + +ble-import contrib/prompt-defer + +#------------------------------------------------------------------------------ + +_ble_contrib_prompt_git_data=() +_ble_contrib_prompt_git_base= +_ble_contrib_prompt_git_base_dir= +_ble_contrib_prompt_git_vars=(git_base git_base_dir) + +## @fn ble/contrib/prompt-git/.check-gitdir path +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/.check-gitdir { + local path=$1 + [[ -f $path/.git/HEAD ]] || return 1 + ble/prompt/unit/assign _ble_contrib_prompt_git_base "$path" + ble/prompt/unit/assign _ble_contrib_prompt_git_base_dir "$path/.git" + return 0 +} +## @fn ble/contrib/prompt-git/.check-submodule path +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/.check-submodule { + local path=$1 content + [[ -f $path/.git ]] || return 1 + ble/util/mapfile content < "$path/.git" + [[ $content == 'gitdir:'* ]] || return 1 + local git_base=$path + local git_base_dir=${content#'gitdir:'} + git_base_dir=${git_base_dir#' '} + [[ $git_base_dir == /* ]] || + git_base_dir=$path/$git_base_dir + [[ -f $git_base_dir/HEAD ]] + ble/prompt/unit/assign _ble_contrib_prompt_git_base "$git_base" + ble/prompt/unit/assign _ble_contrib_prompt_git_base_dir "$git_base_dir" + return 0 +} +function ble/prompt/unit:_ble_contrib_prompt_git/update { + ble/prompt/unit/add-hash '$PWD' + + type git &>/dev/null || return 1 + # [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) ]] + local path=$PWD found= + while + if ble/contrib/prompt-git/.check-gitdir "$path"; then + [[ $prompt_unit_changed ]] + return $? + elif ble/contrib/prompt-git/.check-submodule "$path"; then + [[ $prompt_unit_changed ]] + return $? + fi + [[ $path == */* ]] + do path=${path%/*}; done + + ble/prompt/unit/assign _ble_contrib_prompt_git_base '' + [[ $prompt_unit_changed ]] +} + +## @fn ble/contrib/prompt-git/initialize +## @var[out] git_base git_base_dir +function ble/contrib/prompt-git/initialize { + ble/prompt/unit#update _ble_contrib_prompt_git + ble/util/restore-vars _ble_contrib_prompt_ "${_ble_contrib_prompt_git_vars[@]}" + [[ $git_base ]] +} + +## @fn ble/contrib/prompt-git/check-dirty +## 現在の working tree に編輯があるかどうかを非同期で取得します。 +## @var[in] git_base +_ble_contrib_prompt_git_dirty=0 +ble/contrib/prompt-defer/clear _ble_contrib_prompt_git_dirty +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/clear { _ble_contrib_prompt_git_dirty=0; } +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/worker { + #git diff --quiet + git status --porcelain | ble/bin/awk ' + /^[^ ?]./ { staged = 1;} + /^.[^ ?]/ { unstaged = 1;} + /^\?\?/ { untracked = 1; } + END { + if (unstaged) exit 1; + if (staged) exit 2; + if (untracked) exit 3; + exit 0 + } + ' +} +function ble/contrib/prompt-defer:_ble_contrib_prompt_git_dirty/callback { _ble_contrib_prompt_git_dirty=$?; } +function ble/contrib/prompt-git/check-dirty { + [[ $_ble_contrib_prompt_git_base ]] || return 0 + ble/contrib/prompt-defer/submit _ble_contrib_prompt_git_dirty "$_ble_contrib_prompt_git_base" '' + ble/prompt/unit/add-hash '$_ble_contrib_prompt_git_dirty' + return "$_ble_contrib_prompt_git_dirty" +} +function ble/contrib/prompt-git/is-dirty { ble/contrib/prompt-git/check-dirty; (($?!=0&&$?!=3)); } + +## @fn ble/contrib/prompt-git/get-head-information +## @var[out] hash branch +function ble/contrib/prompt-git/get-head-information { + branch= hash= + + local head_file=$git_base_dir/HEAD + [[ -s $head_file ]] || return + local content; ble/util/mapfile content < "$head_file" + + if [[ $content == *'ref: refs/heads/'* ]]; then + branch=${content#*refs/heads/} + + local branch_file=$git_base_dir/refs/heads/$branch + [[ -s $branch_file ]] || return + local content; ble/util/mapfile content < "$branch_file" + fi + + [[ ! ${content//[0-9a-fA-F]} ]] && hash=$content + return 0 +} +## @fn ble/contrib/prompt-git/get-tag-name hash +## @var[out] tag +function ble/contrib/prompt-git/get-tag-name { + # ble/util/assign-array tag 'git describe --tags --exact-match 2>/dev/null' + tag= + local hash=$1; [[ $hash ]] || return 1 + + local file tagsdir=$git_base_dir/refs/tags hash1 + local files ret; ble/util/eval-pathname-expansion '"$tagsdir"/*'; files=("${ret[@]}") + for file in "${files[@]}"; do + local tag1=${file#$tagsdir/} + [[ -s $file ]] || continue + ble/util/mapfile hash1 < "$file" + if [[ $hash1 == "$hash" ]]; then + tag=$tag1 + return + fi + done +} + +function ble/contrib/prompt-git/describe-head { + local opts=:$1: + ret= + + local dirty_mark= + [[ $opts == *:check-dirty:* ]] && + { ble/contrib/prompt-git/check-dirty; + case $? in + (1) dirty_mark=$'\e[1;38:5:202m*\e[m' ;; + (2) dirty_mark=$'\e[1;32m*\e[m' ;; + (3) dirty_mark=$'\e[1;94m+\e[m' ;; + esac } + + local hash branch + ble/contrib/prompt-git/get-head-information + if [[ $branch ]]; then + local sgr=$'\e[1;34m' sgr0=$'\e[m' + ret=$sgr$branch$sgr0 + if [[ $opts == *:add-hash:* && $hash ]]; then + ret="$ret (${hash::7}$dirty_mark)" + else + ret=$ret$dirty_mark + fi + return + fi + + local DETACHED=$'\e[91mDETACHED\e[m' + + local tag + ble/contrib/prompt-git/get-tag-name "$hash" + if [[ $tag ]]; then + local sgr=$'\e[1;32m' sgr0=$'\e[m' + ret=$sgr$tag$sgr0 + [[ $opts == *:add-hash:* && $hash ]] && + ret="$ret ${hash::7}" + ret=$ret$dirty_mark + [[ $opts == *:check-detached:* ]] && + ret="$DETACHED ($ret)" + return + fi + + # "master~23" 等の分かりにくい説明なのでこれは使わない + # ble/util/assign-array ret 'git describe --contains --all 2>/dev/null' + # if [[ $ret ]]; then + # local sgr=$'\e[32m' sgr0=$'\e[m' + # ret="($DETACHED at $sgr$ret$sgr0)" + # return + # fi + + if [[ $hash ]]; then + ret=${hash::7}$dirty_mark + [[ $opts == *:check-detached:* ]] && + ret="$DETACHED ($ret)" + return + fi + + ret=$'\e[91mUNKNOWN\e[m' +} + +#------------------------------------------------------------------------------ + +function ble/prompt/backslash:contrib/git-info { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local sgr=$'\e[1m' sgr0=$'\e[m' + local name=$sgr${git_base##*?/}$sgr0 + local ret; ble/contrib/prompt-git/describe-head add-hash:check-dirty:check-detached; local branch=$ret + ble/prompt/print "$name $branch" + [[ $PWD == "$git_base"/?* ]] && + ble/prompt/print " /${PWD#$git_base/}" + return 0 + else + return 1 + fi +} +function ble/prompt/backslash:contrib/git-name { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local name=${git_base%.git} + name=${name%/} + name=${name##*?/} + ble/prompt/print "${git_base##*?/}" + fi +} +function ble/prompt/backslash:contrib/git-hash { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local hash branch + ble/contrib/prompt-git/get-head-information + ble/prompt/print "${hash::${1:-7}}" + fi +} +function ble/prompt/backslash:contrib/git-branch { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + local ret; ble/contrib/prompt-git/describe-head check-dirty + ble/prompt/print "$ret" + fi +} +function ble/prompt/backslash:contrib/git-path { + local "${_ble_contrib_prompt_git_vars[@]/%/=}" # WA #D1570 checked + if ble/contrib/prompt-git/initialize; then + if [[ $PWD == "$git_base"/?* ]]; then + ble/prompt/print "/${PWD#$git_base/}" + elif [[ $PWD == "$git_base" ]]; then + ble/prompt/print / + fi + fi +} diff --git a/.local/src/blesh/contrib/prompt-vim-mode.bash b/.local/src/blesh/contrib/prompt-vim-mode.bash new file mode 100644 index 0000000..f1574f3 --- /dev/null +++ b/.local/src/blesh/contrib/prompt-vim-mode.bash @@ -0,0 +1,20 @@ +# ble/contrib/prompt-vim-mode.bash (C) 2020-2021, akinomyoga + +# \q{contrib/vim-mode} (Prompt escape sequence) +# +# Example: +# +# ble-import contrib/prompt-vim-mode +# PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' +# bleopt keymap_vi_mode_show:= +# + +function ble/prompt/backslash:contrib/vim-mode { + local mode; ble/keymap:vi/script/get-mode + case $mode in + ([iR]*) ble/prompt/print '(ins)' ;; + (*n) ble/prompt/print '(cmd)' ;; + (*x) ble/prompt/print '(vis)' ;; + (*s) ble/prompt/print '(sel)' ;; + esac +} -- cgit v1.2.3