-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changes from 5 commits
b7fec1c
627f5d6
554b798
1adf462
78f660f
025ef18
1ae8e8c
3cf7873
cc5ac3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
end | ||
|
||
complete -c figlet -s f -d "Select font" -x -a "(__fish_print_figlet_fonts)" | ||
complete -c figlet -s d -d "Change font directory" | ||
complete -c figlet -s c -d "Center output horizontally" | ||
complete -c figlet -s l -d "Make output flush-left" | ||
complete -c figlet -s r -d "Make output flush-right" | ||
complete -c figlet -s x -d "Set justification according to text direction" | ||
complete -c figlet -s t -d "Set output to terminal width" | ||
complete -c figlet -s w -d "Set output width" | ||
complete -c figlet -s p -d "Put FIGlet into `paragraph mode`" | ||
complete -c figlet -s n -d "Put FIGlet back to normal" | ||
complete -c figlet -s D -d "Switch to German (ISO 646-DE) character set" | ||
complete -c figlet -s E -d "Turns off German character set processing" | ||
complete -c figlet -s C -d "Add given control file" -a "(__fish_complete_suffix .flc)" -x | ||
complete -c figlet -s N -d "Clear control file list" | ||
complete -c figlet -s s -d "Cause `smushing`" | ||
complete -c figlet -s S -d "Cause `smushing`" | ||
complete -c figlet -s k -d "Cause `kerning`" | ||
complete -c figlet -s W -d "Makes FIGlet all FIGcharacters at full width" | ||
complete -c figlet -s o -d "Cause `overlapped`" | ||
complete -c figlet -s m -d "Specify layout mode between 1 and 63" | ||
complete -c figlet -s v -d "Print version and copyright" | ||
complete -c figlet -s I -d "Print information given infocode" -x -a "0\tVersion\ and\ copyright 1\tVersion\ \(integer\) 2\tDefault\ font\ directory 3\tFont 4\tOutput\ width 5\tSupported\ font\ format" | ||
complete -c figlet -s L -d "Print left-to-right" | ||
complete -c figlet -s R -d "Print right-to-left" | ||
complete -c figlet -s X -d "Print with default text direction" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set -l cmds build help init serve test watch | ||
|
||
complete -c mdbook -f | ||
complete -c mdbook -s l -l help -d "Prints help" | ||
complete -c mdbook -s V -l version -d "Prints version" | ||
|
||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a build -d "Build book from markdown files" | ||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a help -d "Prints help" | ||
|
||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a init -d "Create boilerplate structure and files in directory" | ||
complete -c mdbook -n "__fish_seen_subcommand_from init" -l force -d "Skip confirmation prompts" | ||
complete -c mdbook -n "__fish_seen_subcommand_from init" -l theme -d "Copy default theme into source folder" | ||
|
||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a serve -d "Serve book at http://localhost:3000" | ||
complete -c mdbook -n "__fish_seen_subcommand_from serve" -l port -s p -x -d "Use another port (default 3000)" | ||
complete -c mdbook -n "__fish_seen_subcommand_from serve" -l websocket-port -s w -x -d "Use another port for websocket (default 3001)" | ||
|
||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a test -d "Test that code samples compile" | ||
complete -c mdbook -n "not __fish_seen_subcommand_from $cmds" -a watch -d "Watch file changes" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function __fish_print_pygmentize --argument-names type description | ||
for line in (pygmentize -L $type | sed -e "s%^\* \(.*\):%\1%;tx;d;:x" | string split ", ") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any example output here? We might be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What it does is that it selects all lines that match the regex (lines beginning with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It returns what I want and the entire line. I don't know how to get rid of it (without doing something horrible). :-/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that's easy - In this case, we can probably save that to a variable and use the following line as description. Try this: set -l lines (pygmentize -L $type | string match -r '^(?:\* | ).*(?:)$' | string replace -r '\* (.*):$' '$1' | string trim)
while set -q lines[2]
printf '%s\t%s\n' $lines[1] $lines[2]
set -e lines[1]
set -e lines[1]
end |
||
printf "%s\t%s\n" $line $description | ||
end | ||
end | ||
|
||
complete -c pygmentize -s o -d "Set output file" | ||
complete -c pygmentize -s s -d "Read one line at a time" | ||
complete -c pygmentize -s l -d "Set lexer" -x -a "(__fish_print_pygmentize lexers Lexer)" | ||
complete -c pygmentize -s g -d "Guess lexer" | ||
complete -c pygmentize -s f -d "Set formater" -x -a "(__fish_print_pygmentize formaters Formater)" | ||
complete -c pygmentize -s O -d "Set coma-seperated options" -x | ||
complete -c pygmentize -s P -d "Set one option" -x | ||
complete -c pygmentize -s F -d "Set filter" -x -a "(__fish_print_pygmentize filters Filter)" | ||
complete -c pygmentize -s S -d "Print style definition for given style" -x -a "(__fish_print_pygmentize styles Style)" | ||
complete -c pygmentize -s L -d "List lexers, formaters, styles or filters" -x -a "lexers formaters styles filters" | ||
complete -c pygmentize -s N -d "Guess and print lexer name based on given file" | ||
complete -c pygmentize -s H -d "Print detailed help" -x -a "lexer formatter filter" | ||
complete -c pygmentize -s v -d "Print detailed traceback on unhandled exceptions" | ||
complete -c pygmentize -s h -d "Print help" | ||
complete -c pygmentize -s V -d "Print package version" | ||
|
||
function __test_args | ||
echo ... >> /tmp/args | ||
__fish_print_cmd_args >> /tmp/args | ||
return 1 | ||
end | ||
|
||
complete -n "__test_args" -d Hello | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Indeed... |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
complete -c ranger -s d -l debug -d "Activate debug mode" | ||
complete -c ranger -s c -l clean -d "Activate clean mode" | ||
complete -c ranger -s r -l confdir -d "Change configuration directory" | ||
complete -c ranger -l copy-config -x -d "Create copies of the default configuration" -a "all commands commands_full rc rifle scope" | ||
complete -c ranger -l chosefile -r -d "Pick file with ranger" | ||
complete -c ranger -l chosefiles -r -d "Pick multiple files with ranger" | ||
complete -c ranger -l chosedir -r -d "Pick directory" | ||
complete -c ranger -l selectfile -r -d "Open ranger with given file selected" | ||
complete -c ranger -l list-unused-keys -d "List common keys which are not bound" | ||
complete -c ranger -l list-tagged-files -f -d "List all tagged files with given tag (default *)" | ||
complete -c ranger -l profile -d "Print statistics of CPU usage on exit" | ||
complete -c ranger -l cmd -r -d "Execute command after configuration file read" | ||
complete -c ranger -l version -d "Print version" | ||
complete -c ranger -l help -s h -d "Print help" |
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.
We only want the name of the fonts (files with the extension .flf or .tlf). Here, that would be:
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:
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
?
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.