Logo
Explore Help
Sign In
h/fish-shell
1
Fork 0
You've already forked fish-shell
mirror of https://github.com/fish-shell/fish-shell.git synced 2026-05-17 08:01:14 -03:00
Code Issues Packages Projects Releases Wiki Activity
Files
7bf704fe87f72f8b9b0bc80c3fbfc50e3544ea4e
fish-shell/share/functions/__fish_nth_token.fish

10 lines
386 B
Fish
Raw Normal View History

Make __fish_is_nth_token and __fish_nth_token private again Their names are not perfect, so let's keep them as internal functions, until we figure out how/if we want to expose this. This reverts 0445126c2 (Undunder __fish_is_nth_token, 2021-06-29) (but I did it without "git revert"). Closes #8008
2022-02-09 09:46:07 +01:00
function __fish_nth_token --description 'Prints the Nth token (ignoring command and switches/flags)' --argument-names n
Add public function fish_nth_token to mirror fish_is_nth_token Completions may benefit from using these in tandem to dynamically generate completions predicated on the value of an earlier token in a cleaner fashion. (Currently, most of called completion helper functions introspect the command line to get the value of an earlier argument, making them less reusable for different expressions that need completions of the same type. This way, the completion can provide the function with the argument value explicitly.)
2022-02-07 13:16:02 -06:00
set -l tokens (commandline -po | string replace -r --filter '^([^-].*)' '$1')
# Increment $n by one to account for ignoring the command
if test (count $tokens) -ge (math "$n" + 1)
echo $tokens[(math $n + 1)]
else
return 1
end
end
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.3 Page: 514ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API