home-config/fish/functions/_fzf_extract_var_info.fish

b307172932ea5fc99dc9053ebd263cb9ae5a2b4c · 742 B · 15 lines raw

1 # helper function for _fzf_search_variables
2 function _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'
15 end