I'm trying to write a zsh function for open files or folders from terminal.
function osub () {
if [[ -z $@ ]]; then
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl $@
else
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl .
fi
}
I try with $1 also. I want to open current folder in sublime if run only osub command and create new file and open it on sublime if run osub filename
You want to check that $@
is non-zero instead of zero which -z
does. So
if [[ -n $@ ]]; then