Created
January 13, 2026 08:48
-
-
Save allefeld/df65a9d74f48259cc09bc6c78ab2bafa to your computer and use it in GitHub Desktop.
Better Quarto Preview for VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "key": "ctrl+shift+k", | |
| "command": "runCommands", | |
| "args": { | |
| "commands": [ | |
| { | |
| "command": "workbench.action.tasks.runTask", | |
| "args": "Better Quarto Preview" | |
| }, | |
| "simpleBrowser.show" | |
| ] | |
| }, | |
| "when": "editorTextFocus && editorLangId == 'quarto'" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "label": "Better Quarto Preview", | |
| "type": "shell", | |
| "command": "quarto-preview '${file}'", | |
| "isBackground": true, | |
| "presentation": { | |
| "reveal": "always", | |
| "panel": "dedicated", | |
| "clear": true | |
| }, | |
| "runOptions": { | |
| "instanceLimit": 1, | |
| "instancePolicy": "terminateOldest" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # `quarto preview` wrapper to encode URLs | |
| # for VS Code task | |
| copied=false | |
| quarto preview "$1" --no-browser --port 4242 2>&1 | \ | |
| while IFS= read -r line | |
| do | |
| echo "$line" | |
| # remove escape sequences | |
| line=$(echo "$line" | sed -r 's/\x1b\[[0-9;]*[mK]//g') | |
| if ! $copied && [[ $line =~ http:(.*) ]] | |
| then | |
| # if there is an http URL, encode spaces and copy to clipboard | |
| url="${BASH_REMATCH[1]}" | |
| url="${url// /%20}" # replace spaces with %20 | |
| echo "http:$url" | xclip -selection clipboard | |
| copied=true | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment