cbc1a0806e910f7b4eed07b992d3d88ff7cb1162

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4342 from robobenklein/patch-1

Fix Atom Plugin for Linux Users

Diff

 1diff --git a/plugins/atom/README.md b/plugins/atom/README.md
 2index 75d77a0ac1c3732be4dbab1b4062e4f8e1d315fc..6350c647b029ef0ca2416c6dcfe976a63e1d1534 100644
 3--- a/plugins/atom/README.md
 4+++ b/plugins/atom/README.md
 5@@ -1,6 +1,8 @@
 6 ## atom
 7 
 8-Plugin for Atom, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
 9+This plugin makes "at" a useful function for invoking the Atom Editor.
10+
11+Originally by Github user [aforty](https://github.com/aforty) for OSX, modified to alias 'at' to 'atom' for Linux, since atom already works on the terminal for Linux, and calling 'at' in a non-OSX environment should still work.
12 
13 ### Requirements
14 
15@@ -10,8 +12,12 @@ Plugin for Atom, a cross platform text and code editor, available for Linux, Mac
16 
17  * If `at` command is called without an argument, launch Atom
18 
19- * If `at` is passed a directory, `cd` to it and open it in Atom
20+ * If `at` is passed a directory, open it in Atom
21 
22  * If `at` is passed a file, open it in Atom
23 
24- * if `att` command is called, it is equivalent to `at .`, opening the current folder in Atom
25+### Examples
26+
27+ * Open the current dir in atom: `at .`
28+ * Open another dir in atom: `at path/to/folder`
29+ * Open a file: `at filename.extension`
30diff --git a/plugins/atom/atom.plugin.zsh b/plugins/atom/atom.plugin.zsh
31index 9adb9031a0e9c61c113a0e210531f5f3fdc5f4e2..ec1a114edeb67221e0f203646fb0daf30fabbe07 100644
32--- a/plugins/atom/atom.plugin.zsh
33+++ b/plugins/atom/atom.plugin.zsh
34@@ -1,14 +1,22 @@
35-local _atom_paths > /dev/null 2>&1
36-_atom_paths=(
37-    "$HOME/Applications/Atom.app"
38-    "/Applications/Atom.app"
39-)
40+# Gets OS Type
41+unamestr=$(uname -s)
42 
43-for _atom_path in $_atom_paths; do
44-    if [[ -a $_atom_path ]]; then
45-        alias at="open -a '$_atom_path'"
46-        break
47-    fi
48-done
49+# If OSX
50+if [[ "$unamestr" == 'Darwin' ]]; then
51+    local _atom_paths > /dev/null 2>&1
52+    _atom_paths=(
53+        "$HOME/Applications/Atom.app"
54+        "/Applications/Atom.app"
55+    )
56 
57-alias att='at .'
58+    for _atom_path in $_atom_paths; do
59+        if [[ -a $_atom_path ]]; then
60+            alias at="open -a '$_atom_path'"
61+            break
62+        fi
63+    done
64+# If Linux
65+elif [[ "$unamestr" == 'Linux' ]]; then
66+    # Alerts the user if 'atom' is not a found command.
67+    type atom >/dev/null 2>&1 && alias at="atom" || { echo >&2 "You have enabled the atom oh-my-zsh plugin on Linux, but atom is not a recognized command. Please make sure you have it installed before using this plugin."; }
68+fi