Search code examples
shellsublimetext3zshzsh-alias

Zsh function sublime open folder and directory


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


Solution

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

    if [[ -n $@ ]]; then