Skip to content

Commit

Permalink
make vscode setting script
Browse files Browse the repository at this point in the history
  • Loading branch information
JY8752 committed Jul 10, 2023
1 parent ff0e24c commit 89f18d5
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
!/.config/nvim

/chrome/*
!/chrome/extentions
!/chrome/extensions

/vscode/*
!/vscode/extentions
!/vscode/extensions
!/vscode/settings.json
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ defaults:

# Install macOS applications.
brew:
@scripts/brew.sh
@scripts/brew.sh

# update vscode extentions
codeex:
@code --list-extensions > vscode/extensions

# Set VSCode settings.
code:
@scripts/code.sh
36 changes: 36 additions & 0 deletions scripts/code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

source $(dirname "${BASH_SOURCE[0]:-$0}")/util.sh

function setting_vscode() {
print_notice "backup old setting.json..."

local tmp_date
tmp_date="$(date '+%y%m%d-%H%M%S')/vscode"

local backupdir="$HOME/.backup/$tmp_date"
mkdir_not_exist "$backupdir"
print_info "create backup directory: $backupdir"

print_info "Creating symlinks"
local current_dir
current_dir=$(dirname "${BASH_SOURCE[0]:-$0}")
local root_dir
root_dir="$(builtin cd "$current_dir" && git rev-parse --show-toplevel)"
local vscode_dir="${HOME}/Library/Application Support/Code/User"

# Link settings.json
backup_and_link "${root_dir}/vscode/settings.json" "${vscode_dir}" "${backupdir}"

# Install extensions using the code command
if [ "$(which code)" != "" ]; then
cat < "${root_dir}/vscode/extensions" | while read -r line
do
code --install-extension "$line"
done
else
print_error "Install the code command from the command palette to add your extensions."
fi
}

setting_vscode
23 changes: 0 additions & 23 deletions scripts/link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

source $(dirname "${BASH_SOURCE[0]:-$0}")/util.sh

function backup_and_link() {
local link_src_file=$1
local link_dest_dir=$2
local backupdir=$3
local f_filename

f_filename=$(basename "$link_src_file")
local f_filepath="$link_dest_dir/$f_filename"

# 既にシンボリックリンクとして存在する場合は削除
if [[ -L "$f_filepath" ]]; then
command rm -f "$f_filepath"
fi

# シンボリックリンクでなく実ファイルであればバックアップ
if [[ -e "$f_filepath" && ! -L "$f_filepath" ]]; then
command mv "$f_filepath" "$backupdir"
fi

echo "Creating symlink for $link_src_file -> $link_dest_dir"
command ln -snf "$link_src_file" "$link_dest_dir"
}

function link_to_homedir() {
# backupディレクトリを作成 
print_notice "backup old dotfiles..."
Expand Down
23 changes: 23 additions & 0 deletions scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,27 @@ function check_macos() {
print_error "Not macOS!"
exit 1
fi
}

function backup_and_link() {
local link_src_file=$1
local link_dest_dir=$2
local backupdir=$3
local f_filename

f_filename=$(basename "$link_src_file")
local f_filepath="$link_dest_dir/$f_filename"

# 既にシンボリックリンクとして存在する場合は削除
if [[ -L "$f_filepath" ]]; then
command rm -f "$f_filepath"
fi

# シンボリックリンクでなく実ファイルであればバックアップ
if [[ -e "$f_filepath" && ! -L "$f_filepath" ]]; then
command mv "$f_filepath" "$backupdir"
fi

echo "Creating symlink for $link_src_file -> $link_dest_dir"
command ln -snf "$link_src_file" "$link_dest_dir"
}
54 changes: 54 additions & 0 deletions vscode/extensions
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
aaron-bond.better-comments
astro-build.astro-vscode
asvetliakov.vscode-neovim
bierner.markdown-mermaid
bierner.markdown-preview-github-styles
bradlc.vscode-tailwindcss
bungcip.better-toml
csstools.postcss
dariofuzinato.vue-peek
DavidAnson.vscode-markdownlint
dbaeumer.vscode-eslint
denoland.vscode-deno
dracula-theme.theme-dracula
dsznajder.es7-react-js-snippets
ecmel.vscode-html-css
esbenp.prettier-vscode
formulahendry.auto-close-tag
formulahendry.auto-rename-tag
formulahendry.code-runner
foxundermoon.next-js
gencay.vscode-chatgpt
GitHub.copilot
github.vscode-github-actions
golang.go
hashicorp.terraform
hediet.vscode-drawio
hylwxqwq.yuyuko-vim-vsc
JuanBlanco.solidity
mads-hartmann.bash-ide-vscode
ms-azuretools.vscode-docker
MS-CEINTL.vscode-language-pack-ja
ms-kubernetes-tools.vscode-kubernetes-tools
ms-vscode.makefile-tools
ms-vsliveshare.vsliveshare
oderwat.indent-rainbow
onflow.cadence
Orta.vscode-jest
PKief.material-icon-theme
Prisma.prisma
redhat.vscode-yaml
ritwickdey.LiveServer
rust-lang.rust-analyzer
taichi.vscode-textlint
vadimcn.vscode-lldb
VisualStudioExptTeam.intellicode-api-usage-examples
VisualStudioExptTeam.vscodeintellicode
vmsynkov.colonize
vscodevim.vim
vsls-contrib.gistfs
Vue.volar
WakaTime.vscode-wakatime
xaver.clang-format
yoavbls.pretty-ts-errors
zxh404.vscode-proto3
Empty file removed vscode/extentions
Empty file.

0 comments on commit 89f18d5

Please sign in to comment.