Răsfoiți Sursa

Update Code: better living through symlinks

Tom McKenzie 6 ani în urmă
părinte
comite
74c6be0667
4 a modificat fișierele cu 29 adăugiri și 13 ștergeri
  1. 4 0
      Code/install-extensions.sh
  2. 20 3
      Code/setup.sh
  3. 5 0
      Code/update-extensions.sh
  4. 0 10
      Code/update.sh

+ 4 - 0
Code/install-extensions.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+set -e
+
+cat list-extensions.txt | while read line; do code --install-extension "$line"; done

+ 20 - 3
Code/setup.sh

@@ -1,7 +1,24 @@
 #!/bin/bash
-
 set -e
 
-cp ./User/* "${HOME}/Library/Application Support/Code/User/"
+TARGET="$HOME/Library/Application Support/Code/User"
+SOURCE="$HOME/dotfiles/Code/User"
+BAK="$HOME/dotfiles/bak/Code_User"
+
+setup_symlink () {
+  if [ -d "$TARGET" ]; then
+    true
+  else
+    echo "$TARGET does not exist"
+    exit 1
+  fi
+
+  if [ -f "$TARGET/$1" ]; then
+    mv "$TARGET/$1" "$BAK/$1"
+  fi
+
+  ln -s "$SOURCE/$1" "$TARGET/$1"
+}
 
-cat list-extensions.txt | while read -r line; do code --install-extension "$line"; done
+setup_symlink "settings.json"
+setup_symlink "keybindings.json"

+ 5 - 0
Code/update-extensions.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+set -e
+
+cp /Users/tom/Library/Application\ Support/Code/User/keybindings.json ./User/
+code --list-extensions > ./list-extensions.txt

+ 0 - 10
Code/update.sh

@@ -1,10 +0,0 @@
-#!/bin/bash
-
-set -e
-
-grep -v 'oauth' /Users/tom/Library/Application\ Support/Code/User/settings.json > ./User/settings.json
-cp /Users/tom/Library/Application\ Support/Code/User/keybindings.json ./User/
-code --list-extensions > ./list-extensions.txt
-
-# install extensions using:
-# cat list-extensions.txt | while read line; do code --install-extension "$line"; done