Skip to content

custom open command to open md files #1263

Answered by joelim-work
techeddie asked this question in Q&A
Discussion options

You must be logged in to vote

You can just add another case statement:

cmd open ${{
    test -L $f && f=$(readlink -f $f)
    case $f in
        *.md) glow -p $fx;;  # handle markdown files
        *)
            case $(file --mime-type $f -b) in
                text/*) nvim $fx;;
                *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
            esac
            ;;
    esac
}}

You can use this (and if statements) to adjust the logic to suit your needs - it's a lot like other programming languages.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@techeddie
Comment options

Answer selected by techeddie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants