Created
October 11, 2018 10:03
-
-
Save yutailang0119/0c9c57b894c478d7f679b2990c3a995d to your computer and use it in GitHub Desktop.
Fish shell function that open file by Android Studio
This file contains 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
~/.config/fish/functions/studio.fish | |
function studio -d "Open file by Android Studio" | |
set -l file $argv[1] | |
set -l a_option $argv[2] | |
set -l application $argv[3] | |
if test -z $a_option | |
set a_option -a | |
set application 'Android Studio' | |
else if test $a_option != -a | |
echo "Error: Option supports only '-a'" | |
return 1 | |
else if test -z $application | |
echo "Error: Need to specify Android Studio when using -a option" | |
return 1 | |
end | |
set -l match_pattern (string match -nr 'Android Studio' $application) | |
if test \( -z $match_pattern \) -o \( $match_pattern != '1 14' \) | |
echo "Error: Only application with 'Android Studio' prefix are supported" | |
return 1 | |
end | |
open $file $a_option $application | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment