New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New completions: figlet, mdbook, ranger, pygmentize + xz fix #3378
Conversation
The previous completion gave every files. Here, we only show files with the .xz, .txz, .lzma or .tlz extension.
return 1 | ||
end | ||
|
||
complete -n "__test_args" -d Hello |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you didn't want to include this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed...
Nope - something installed it into /usr/bin other than Apple, or
|
I really like this tool. I have defined an alias function |
|
That's why I use pygmentize. I can throw everything at it without having to think much and the highlights are pretty good. It doesn't even need the extension to guess some languages. |
@@ -0,0 +1,29 @@ | |||
function __fish_print_figlet_fonts | |||
find (figlet -I2) -type f ^ /dev/null | sed -e 's$/.*/\([^/.]*\)\.[ft]lf$\1\tFont$;tx;d;:x' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does figlet -I2
output?
This might be nicer with string, though it's something we can also do later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> figlet -I2
/usr/share/figlet/fonts
> find (figlet -I2) -type -f ^ /dev/null
/usr/share/figlet/fonts/slant.flf
/usr/share/figlet/fonts/ilhebrew.flc
/usr/share/figlet/fonts/banner.flf
/usr/share/figlet/fonts/646-jp.flc
/usr/share/figlet/fonts/646-irv.flc
/usr/share/figlet/fonts/646-es.flc
/usr/share/figlet/fonts/8859-4.flc
/usr/share/figlet/fonts/646-cn.flc
/usr/share/figlet/fonts/646-fr.flc
/usr/share/figlet/fonts/standard.flf
/usr/share/figlet/fonts/646-pt.flc
/usr/share/figlet/fonts/ivrit.flf
/usr/share/figlet/fonts/hz.flc
... and some more ...
We only want the name of the fonts (files with the extension .flf or .tlf). Here, that would be:
slant
banner
standard
... and some more ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does the same thing:
function __fish_print_figlet_fonts
set -l lines (find (figlet -I 2) -type f | string match -r '/.*/(.*)\.[ft]lc')
while set -q lines[2]
printf '%s\tFont\n' $lines[2]
set -e lines[1]
set -e lines[1]
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
set -l dir (figlet -I 2)
set -l files $dir/*.flf $dir/*.tlf
printf '%s\tFont\n' (string replace -r '.*/([^/]+)\.[ft]lf' '$1' -- $files)
?
You might want to test the performance here. To do that, define the function, execute it and echo $CMD_DURATION
right after. That'll give you the time in milliseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your solution is much faster (yours: 4ms; sed: 12ms; find + match: 25ms). I'll commit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my intuition was correct. The trick, and this applies to all shells, is to use builtins unless you're dealing with large datasets, when specialized tools (GNU's grep is blindlingly fast) might make sense. There's a constant cost to forking off an external command.
I have to say that I really like to contribute here. I am always learning something new. |
These commits have been lost somehow from master. |
Fixed with 92e3a3c - sorry for the noise. |
Add
figlet
,mdbook
,ranger
andpygmentize
and fixxz
completions.