diff options
author | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-05 11:57:45 -0400 |
---|---|---|
committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-05 11:57:45 -0400 |
commit | b88d77fb2d0d5028a6f5670695dee6bec129501f (patch) | |
tree | 2536b0461d297e647cf07157641c9b1223339adf /home-config/fish/functions/_fzf_extract_var_info.fish | |
parent | 776a7ca55d2d2c3f396de91db1c6c3c5065012cd (diff) |
ahhh sloppy fish, still needs fixing, esp with the vars
Diffstat (limited to 'home-config/fish/functions/_fzf_extract_var_info.fish')
-rw-r--r-- | home-config/fish/functions/_fzf_extract_var_info.fish | 15 |
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 | ||
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 | ||