Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Brace expansion with range in fish shell

In bash, I can do the following

$ echo bunny{1..6} bunny1 bunny2 bunny3 bunny4 bunny5 bunny6 

Is there a way to achieve the same result in fish?

like image 444
workflow Avatar asked Dec 25 '13 08:12

workflow


People also ask

What is brace expansion?

Brace expansion is a mechanism by which arbitrary strings may be generated. This mechanism is similar to filename expansion (see Filename Expansion), but the filenames generated need not exist.

What is one major difference between brace expansion and?

What is one major difference between brace expansion and globs? Globs create a list; brace expansion matches pattern. Brace expansion requires files to exist; globs do not.

How do you set the path on a fish shell?

It does this by adding the components either to $fish_user_paths or directly to $PATH (if the --path switch is given). It is (by default) safe to use fish_add_path in config. fish, or it can be used once, interactively, and the paths will stay in future because of universal variables.

How do I customize my fish shell prompt?

fish is empty by default. To create a custom prompt create a file ~/. config/fish/functions/fish_prompt. fish and fill it with your prompt.


1 Answers

The short answer is echo bunny(seq 6)

Longer answer: In keeping with fish's philosophy of replacing magical syntax with concrete commands, we should hunt for a Unix command that substitutes for the syntactic construct {1..6}. seq fits the bill; it outputs numbers in some range, and in this case, integers from 1 to 6. fish (to its shame) omits a help page for seq, but it is a standard Unix/Linux command.

Once we have found such a command, we can leverage command substitutions. The command (foo)bar performs command substitution, expanding foo into an array, and may result in multiple arguments. Each argument has 'bar' appended.

like image 56
ridiculous_fish Avatar answered Oct 09 '22 02:10

ridiculous_fish