1

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

Harald Nordgren
  • 11,693
  • 6
  • 41
  • 65

1 Answers1

1

You want to check that $@ is non-zero instead of zero which -z does. So

if [[ -n $@ ]]; then
Harald Nordgren
  • 11,693
  • 6
  • 41
  • 65