aboutsummaryrefslogtreecommitdiff
path: root/fish/functions/_fzf_extract_var_info.fish
diff options
context:
space:
mode:
authorIndrajith K L2024-06-27 17:51:18 +0530
committerIndrajith K L2024-06-27 17:51:18 +0530
commit57eb70137b5bbcdabdc0f02eea5477b3e5f845a1 (patch)
treee78187146c506d5a640545dee99cc3e9860e25dc /fish/functions/_fzf_extract_var_info.fish
downloaddots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.tar.gz
dots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.tar.bz2
dots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.zip
Adds Arch Linux dotfiles
Diffstat (limited to 'fish/functions/_fzf_extract_var_info.fish')
-rw-r--r--fish/functions/_fzf_extract_var_info.fish15
1 files changed, 15 insertions, 0 deletions
diff --git a/fish/functions/_fzf_extract_var_info.fish b/fish/functions/_fzf_extract_var_info.fish
new file mode 100644
index 000000000..dd4e9523a
--- /dev/null
+++ b/fish/functions/_fzf_extract_var_info.fish
@@ -0,0 +1,15 @@
+# helper function for _fzf_search_variables
+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."
+ # Extract only the lines about the variable, all of which begin with either
+ # $variable_name: ...or... $variable_name[
+ string match --regex "^\\\$$variable_name(?::|\[).*" <$set_show_output |
+
+ # Strip the variable name prefix, including ": " for scope info lines
+ string replace --regex "^\\\$$variable_name(?:: )?" '' |
+
+ # Distill the lines of values, replacing...
+ # [1]: |value|
+ # ...with...
+ # [1] value
+ string replace --regex ": \|(.*)\|" ' $1'
+end