Last active
July 13, 2018 21:50
-
-
Save deconstructionalism/df7ca33b4e93333b4efcf859a1c455f2 to your computer and use it in GitHub Desktop.
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
| #!/bin/sh | |
| # shell command to install Atom packages | |
| install_packages="apm install linter linter-rubocop" | |
| if grep -q Microsoft /proc/version 1>/dev/null 2>/dev/null; then | |
| # -------------------- # | |
| # W I N D O W S 1 0 # | |
| # -------------------- # | |
| # install Atom packages | |
| cmd.exe /c "$install_packages" | |
| # set default line endings to LF | |
| echo "atom.config.set(\"line-ending-selector.defaultLineEnding\", \"LF\")" >> ~/winhome/.atom/init.coffee | |
| # -------------------------------------------- # | |
| # BATCH SCRIPTS TO BIND WSL BINARIES TO VSCODE # | |
| # -------------------------------------------- # | |
| # VSCode will use binaries installed in WSL to run linting and other | |
| # functionality. In order for VSCode, a Windows 10 program to use WSL | |
| # binaries, we need simple batch scripts to allow calling WSL binaries | |
| # from VSCode. | |
| # WSL git batch file | |
| # WSL rubocop batch file | |
| cat <<EOF > ~/winhome/.vscode/rubocop.bat | |
| @echo off | |
| bash.exe -c "$(rbenv which rubocop) %*" | |
| EOF | |
| # add command to set correct rubocop path to Atom init screen | |
| echo "atom.config.set(\"linter-rubocop.command\", \"%USERPROFILE%/.atom/rubocop.bat\")" >> ~/winhome/.atom/init.coffee | |
| else | |
| # ---------------------------- # | |
| # M A C O S / L I N U X # | |
| # ---------------------------- # | |
| # install Atom packages | |
| eval $install_packages | |
| # add command to set correct rubocop path to Atom init screen | |
| echo "atom.config.set(\"linter-rubocop.command\", \"`rbenv which rubocop`\")" >> ~/.atom/init.coffee | |
| fi |
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
| #!/bin/sh | |
| # install npm packages | |
| npm install --global eslint | |
| # install gem packages | |
| gem install rubocop solargraph | |
| if grep -q Microsoft /proc/version 1>/dev/null 2>/dev/null; then | |
| # -------------------- # | |
| # W I N D O W S 1 0 # | |
| # -------------------- # | |
| # -------------------------------------------- # | |
| # BATCH SCRIPTS TO BIND WSL BINARIES TO VSCODE # | |
| # -------------------------------------------- # | |
| # VSCode will use binaries installed in WSL to run linting and other | |
| # functionality. In order for VSCode, a Windows 10 program to use WSL | |
| # binaries, we need simple batch scripts to allow calling WSL binaries | |
| # from VSCode. | |
| # WSL git batch file | |
| cat <<EOF > ~/winhome/.vscode/git.bat | |
| @echo off | |
| bash -c 'git %*' | |
| EOF | |
| # WSL rubocop batch file | |
| cat <<EOF > ~/winhome/.vscode/rubocop.bat | |
| @echo off | |
| bash.exe -c "$(rbenv which rubocop) %*" | |
| EOF | |
| # WSL solargraph batch file | |
| cat <<EOF > ~/winhome/.vscode/solargraph.bat | |
| @echo off | |
| bash.exe -c "$(rbenv which solargraph) %*" | |
| EOF | |
| # WSL eslint batch file | |
| cat <<EOF > ~/winhome/.vscode/eslint.bat | |
| @echo off | |
| bash.exe -c "eslint %*" | |
| EOF | |
| # ----------------------------------- # | |
| # SETTINGS TO ADD TO VSCODE (WINDOWS) # | |
| # ----------------------------------- # | |
| cat <<EOF > settings.json | |
| { | |
| "git.path": "%USERPROFILE%\\\.vscode\\\git.bat", | |
| "eslint.nodePath": "%USERPROFILE%\\\.vscode\\\eslint.bat", | |
| "solargraph.commandPath": "%USERPROFILE%\\\.vscode\\\solargraph.bat", | |
| "ruby.rubocop.executePath": "%USERPROFILE%\\\.vscode\\\rubocop.bat", | |
| "terminal.integrated.shell.windows": "C:\\\Windows\\\Sysnative\\\bash.exe", | |
| "files.eol": "\n", | |
| "files.associations": { | |
| "*.pgsql": "sql", | |
| "*.psql": "sql" | |
| } | |
| } | |
| EOF | |
| # WINDOWS settings.json path | |
| settings_json="~/winhome/AppData/Roaming/Code/User/settings.json" | |
| # install jq to allow JSON file merge | |
| sudo apt-get install jq | |
| else | |
| # ---------------------------- # | |
| # M A C O S / L I N U X # | |
| # ---------------------------- # | |
| # ------------------------------------- # | |
| # SETTINGS TO ADD TO VSCODE (MAC/LINUX) # | |
| # ------------------------------------- # | |
| cat <<EOF > settings.json | |
| { | |
| "ruby.rubocop.executePath": "$(rbenv which rubocop)", | |
| "files.associations": { | |
| "*.pgsql": "sql", | |
| "*.psql": "sql" | |
| } | |
| } | |
| EOF | |
| if [[ $(uname -s) = 'Darwin' ]]; then | |
| # MAC settings.json path | |
| settings_json="$HOME/Library/Application Support/Code/User/settings.json" | |
| else | |
| # LINUX settings.json path | |
| settings_json="$HOME/.config/Code/User/settings.json" | |
| fi | |
| fi | |
| # merge settings.json into VSCode settings | |
| jq -s '.[0] * .[1]' "$settings_json" settings.json > temp.json | |
| cat temp.json > "$settings_json" | |
| rm temp.json | |
| rm settings.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment