From a31f5dd447548df8bfb023b434295559ceb3d580 Mon Sep 17 00:00:00 2001 From: Ricard Fredin Date: Thu, 11 Sep 2014 10:01:31 +0200 Subject: [PATCH] Added Sublime Text module which checks for installed application and adds aliases. --- modules/sublime/README.md | 31 ++++++++++++++++++++++++++ modules/sublime/init.zsh | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 modules/sublime/README.md create mode 100644 modules/sublime/init.zsh diff --git a/modules/sublime/README.md b/modules/sublime/README.md new file mode 100644 index 00000000..e6c2fa79 --- /dev/null +++ b/modules/sublime/README.md @@ -0,0 +1,31 @@ +Sublime Text +============ + +Checks for Sublime Text installations and adds aliases. +Port from https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sublime + +Aliases +------- + +## Sublime Text + +### Linux + + - `st_run` - runs Sublime Text + - `st` - runs Sublime Text + - `stt` - runs Sublime Text for current directory, the same as running `st .` + +### OS X + + - `subl` - runs Sublime Text + - `st` - runs Sublime Text + - `stt` - runs Sublime Text for current directory, the same as running `st .` + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][1].* + + - [Ricard Fredin](https://github.com/cordazar) + +[1]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/sublime/init.zsh b/modules/sublime/init.zsh new file mode 100644 index 00000000..61143c17 --- /dev/null +++ b/modules/sublime/init.zsh @@ -0,0 +1,46 @@ +# +# Checks for installed Sublime Text 3/2 and adds aliases +# Port from https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sublime +# +# Authors: Ricard Fredin +# + +if [[ $('uname') == 'Linux' ]]; then + local _sublime_linux_paths > /dev/null 2>&1 + _sublime_linux_paths=( + "$HOME/bin/sublime_text" + "/opt/sublime_text/sublime_text" + "/usr/bin/sublime_text" + "/usr/local/bin/sublime_text" + "/usr/bin/subl" + ) + for _sublime_path in $_sublime_linux_paths; do + if [[ -a $_sublime_path ]]; then + st_run() { $_sublime_path $@ >/dev/null 2>&1 &| } + alias st=st_run + break + fi + done + +elif [[ "$OSTYPE" = darwin* ]]; then + local _sublime_darwin_paths > /dev/null 2>&1 + _sublime_darwin_paths=( + "/usr/local/bin/subl" + "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" + "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" + "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" + "$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" + "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" + "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" + ) + + for _sublime_path in $_sublime_darwin_paths; do + if [[ -a $_sublime_path ]]; then + alias subl="'$_sublime_path'" + alias st=subl + break + fi + done +fi + +alias stt='st .' \ No newline at end of file