Created
December 2, 2015 15:09
-
-
Save aeberlin/61998f5ef9c5eff76eb6 to your computer and use it in GitHub Desktop.
Atom Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
childProcess = require('child_process') | |
fs = require('fs') | |
path = require('path') | |
spawn = require('child_process').spawn | |
spawnPath = atom.project.getPaths()[0] | |
if not fs.statSync(spawnPath).isDirectory() | |
spawnPath = path.dirname(dir) | |
parseCharArray = (array) -> | |
array.reduce ((str, charIndex) -> | |
str += String.fromCharCode(charIndex) | |
), '' | |
buildShellCommand = (cmd) -> | |
initCommand = 'cd ' + spawnPath + ' && source ~/.zshrc' | |
commandArgs = '-c "' + initCommand + ' && ' + cmd + '"' | |
command = '/usr/local/bin/zsh ' + commandArgs | |
runShellCommand = (command) -> | |
full_command = buildShellCommand(command) | |
output = childProcess.execSync(full_command) | |
parseCharArray(output) | |
getEnvironmentVariable = (variable) -> | |
output = runShellCommand("env | grep '^" + variable + "'") | |
output.replace(variable + '=', '') | |
process.env.PATH = getEnvironmentVariable('PATH') | |
# Open developer tools | |
# editor = atom.workspace.getActiveTextEditor() | |
# editorElement = atom.views.getView(editor) | |
# atom.commands.dispatch(editorElement, 'window:toggle-dev-tools') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment