j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
539 stars 32 forks source link

feat: allow variables in custom editor command arguments #168

Closed j178 closed 1 year ago

j178 commented 1 year ago

Some usage examples:

  1. open all files using Goland
editor:
  command: open
  args: [ '-a', 'Goland.app', '{{.AllFiles}}' ]
  1. open files using custom script
editor:
  command: /usr/local/bin/opener.sh
  args: ['{{.AllFiles}}' ]

/usr/local/bin/opener.sh:

#!/bin/bash

if [ $# -gt 0 ]; then
    for filepath in "$@"
    do
        file_extension="${filepath##*.}"
        case "$file_extension" in
            md)
                code "$filepath" &
                ;;
            *)
                vim -n "$filepath" &
                ;;
        esac
    done
else
    echo "No file paths provided"
    exit 1
fi