summaryrefslogtreecommitdiff
path: root/home-config/fish/functions/_fzf_extract_var_info.fish
diff options
context:
space:
mode:
Diffstat (limited to 'home-config/fish/functions/_fzf_extract_var_info.fish')
-rw-r--r--home-config/fish/functions/_fzf_extract_var_info.fish15
1 files changed, 15 insertions, 0 deletions
diff --git a/home-config/fish/functions/_fzf_extract_var_info.fish b/home-config/fish/functions/_fzf_extract_var_info.fish
new file mode 100644
index 0000000..dd4e952
--- /dev/null
+++ b/home-config/fish/functions/_fzf_extract_var_info.fish
@@ -0,0 +1,15 @@
1# helper function for _fzf_search_variables
2function _fzf_extract_var_info --argument-names variable_name set_show_output --description "Extract and reformat lines pertaining to \$variable_name from \$set_show_output."
3 # Extract only the lines about the variable, all of which begin with either
4 # $variable_name: ...or... $variable_name[
5 string match --regex "^\\\$$variable_name(?::|\[).*" <$set_show_output |
6
7 # Strip the variable name prefix, including ": " for scope info lines
8 string replace --regex "^\\\$$variable_name(?:: )?" '' |
9
10 # Distill the lines of values, replacing...
11 # [1]: |value|
12 # ...with...
13 # [1] value
14 string replace --regex ": \|(.*)\|" ' $1'
15end