From bb360c818922cb6d68611bd537ec4b29b9952456 Mon Sep 17 00:00:00 2001 From: JY8752 Date: Thu, 13 Jul 2023 21:23:07 +0900 Subject: [PATCH] install programing languages by asdf --- .zshenv | 1 - .zshrc | 33 +++++++++++----- Makefile | 6 ++- README.md | 96 +++++++++++++++++++++++++++++++++++++++++------ scripts/.Brewfile | 5 ++- scripts/asdf.sh | 25 ++++++++++++ scripts/link.sh | 18 ++++----- scripts/util.sh | 4 +- 8 files changed, 151 insertions(+), 37 deletions(-) create mode 100644 scripts/asdf.sh diff --git a/.zshenv b/.zshenv index c2f3182..e69de29 100644 --- a/.zshenv +++ b/.zshenv @@ -1 +0,0 @@ -. "$HOME/.cargo/env" diff --git a/.zshrc b/.zshrc index 3e531f4..8ba5ec4 100644 --- a/.zshrc +++ b/.zshrc @@ -13,18 +13,18 @@ zstyle ':vcs_info:*' actionformats '[%b|%a]' precmd(){ vcs_info } #nodenv -eval "$(nodenv init - --no-rehash)" +# eval "$(nodenv init - --no-rehash)" #java #export PATH="/opt/homebrew/opt/openjdk/bin:$PATH" #go -export GOPATH=/Users/yamanakajunichi # GOPATHにすると決めた場所 -export PATH=$GOPATH/bin:$PATH +# export GOPATH=/Users/yamanakajunichi # GOPATHにすると決めた場所 +# export PATH=$GOPATH/bin:$PATH #jenv -export PATH="$HOME/.jenv/bin:$PATH" -eval "$(jenv init -)" +# export PATH="$HOME/.jenv/bin:$PATH" +# eval "$(jenv init -)" # vim alias alias vi="nvim" @@ -81,14 +81,14 @@ export EDITOR=vim eval "$(direnv hook zsh)" # graal -export PATH=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.2.0/Contents/Home/bin:"$PATH" -export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.2.0/Contents/Home +# export PATH=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.2.0/Contents/Home/bin:"$PATH" +# export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.2.0/Contents/Home -export JAVA_HOME=$GRAALVM_HOME +# export JAVA_HOME=$GRAALVM_HOME #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! -export SDKMAN_DIR="$HOME/.sdkman" -[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" +# export SDKMAN_DIR="$HOME/.sdkman" +# [[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" # キーボードアシスト alias chkey="open /System/Library/CoreServices/KeyboardSetupAssistant.app" @@ -112,3 +112,16 @@ PS1='$(kube_ps1)'$PS1 # helm 補完 source <(helm completion zsh) +# asdf + +# asdfの補完 +# . /opt/homebrew/opt/asdf/libexec/asdf.sh +# fpath=($(brew --prefix asdf)/completions $fpath) +# autoload -Uz compinit && compinit + +# asdfのJAVA_HOMEを設定 +. ~/.asdf/plugins/java/set-java-home.zsh + +# asdfのGOROOTを設定 +. ~/.asdf/plugins/golang/set-env.zsh + diff --git a/Makefile b/Makefile index 36e36f2..2a8ea1b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Do everything. -all: init link defaults brew +all: init link defaults brew code asdf # Set initial preference. init: @@ -28,3 +28,7 @@ code: # google chrome extentions list up chromeex: @ls -l $${HOME}/Library/Application\ Support/Google/Chrome/Default/Extensions | awk '{print $$9}' | sed 's/^/https:\/\/chrome.google.com\/webstore\/detail\//g' | sed -e '1,2d' > chrome/extensions + +# Install Languages +asdf: + @scripts/asdf.sh \ No newline at end of file diff --git a/README.md b/README.md index 68346c2..465585b 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # dotfiles -このリポジトリはdotfilesを管理するためのリポジトリです。このリポジトリでは以下の項目について管理しています。なお、このdotfilesは**MacOSを対象**としており、新しいMac端末に開発環境を構築することを目的として作成しています。 +This repository is for managing dotfiles. It covers the following items. Note that these dotfiles **target MacOS** and are designed to set up a development environment on a new Mac machine. -- Macの初期設定。 -- brewで管理しているモジュールのインストール。 -- dotfilesのリンクの作成。 -- 使用頻度の高いプログラミング言語の管理。 -- (vscode, google chromeの拡張機能の管理。)変更検知はせずリストアップのみ。つまり、手動設定をしています。 -- (グローバルインストールしたgo, nodeライブラリの管理。)変更検知はせずリストアップのみ。つまり、手動設定をしています。 +- Initial setup of Mac. +- Installation of modules managed with brew. +- Creation of symbolic links for dotfiles. +- Management of frequently used programming languages. +- Listing and installation of VSCode extensions. +- Listing of Google Chrome extensions. +- Import file for Raycast. -拡張機能や各プログラミング言語ライブラリは追加、削除、バージョン追従が難しいので手動管理としています。 +We manually manage globally installed libraries for Node and Go as version management can be challenging in this repository. -## 開発環境 +## Development Environment - aws -- gcp - GitHub - hammerspoon - vscode @@ -23,15 +23,87 @@ - neovim - kitty - Homebrew +- asdf - Go - TypeScript - Java - Kotlin -## インストール +## Installation -## 使い方 +``` +git clone git@github.com:JY8752/dotfiles.git +``` + +## Usage + +### initialize all setting + +By running the make command, the following settings and installations will be made. + +- Initial settings for MacOS (installation of xcode command line tools and homebrew). +- Creation of symbolic links for various dotfiles in the home directory. +- Changing the default terminal settings of MacOS itself. +- Installation of packages listed in Homebrew's ```.Brewfile```. +- Installation of VSCode extensions and creation of a symbolic link for ```setting.json``` (extensions to be installed are listed in ```vscode/extensions```). +- Installation of various programming languages via asdf. + +``` +make +``` + +### Mac OS initial setting(xcode command line tool and homebrew install) + +``` +make init +``` + +### create symbolic link to home dir + +``` +make link +``` + +### change Mac OS default setting + +``` +make defaults +``` + +### install brew package + +``` +make berw +``` + +### list up vscode + +Overwrite the ```vscode/extensions``` with extensions installed in the running OS's VSCode. + +``` +make codeex +``` + +### install vscode extensions + +``` +make code +``` + +### list up google chrome extensions + +Write out a list of installation URLs for Google Chrome extensions installed on the running terminal to ```chrome/extensions``` (these extensions are only written out and manually managed). + +``` +make chromeex +``` + +### install languages + +``` +make asdf +``` ## 参考 diff --git a/scripts/.Brewfile b/scripts/.Brewfile index e6ae1a6..a79decc 100755 --- a/scripts/.Brewfile +++ b/scripts/.Brewfile @@ -11,6 +11,7 @@ brew "age" brew "awscli" # brew "binaryen" brew "clang-format" +brew "coreutils" # cmake brew "deno" brew "direnv" @@ -57,7 +58,7 @@ cask "hammerspoon" cask "intellij-idea-ce" # cask "intellij-idea" cask "obsidian" -cask "deel" +cask "deepl" cask "visualvm" cask "mysqlworkbench" @@ -65,6 +66,6 @@ cask "mysqlworkbench" # cask "line" # cask "kindle" -# 手動 +# manual install # gifski https://gif.ski/ # Flux https://justgetflux.com/ \ No newline at end of file diff --git a/scripts/asdf.sh b/scripts/asdf.sh new file mode 100644 index 0000000..37bf103 --- /dev/null +++ b/scripts/asdf.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# install node +command asdf -v >/dev/null 2>&1 \ + && asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git \ + && asdf install nodejs latest \ + && asdf global nodejs latest + +# install java +command asdf -v >/dev/null 2>&1 \ + && asdf plugin add java https://github.com/halcyon/asdf-java.git \ + && asdf install java latest:adoptopenjdk \ + && asdf global java latest:adoptopenjdk + +# install golang +command asdf -v >/dev/null 2>&1 \ + && asdf plugin add golang https://github.com/kennyp/asdf-golang.git \ + && asdf install golang latest \ + && asdf global golang latest + +# install rust +command asdf -v >/dev/null 2>&1 \ + && asdf plugin add rust https://github.com/code-lever/asdf-rust.git \ + && asdf install rust latest \ + && asdf global rust latest diff --git a/scripts/link.sh b/scripts/link.sh index 44eb34c..27c6de7 100755 --- a/scripts/link.sh +++ b/scripts/link.sh @@ -3,7 +3,7 @@ source $(dirname "${BASH_SOURCE[0]:-$0}")/util.sh function link_to_homedir() { - # backupディレクトリを作成  + # make backup directory print_notice "backup old dotfiles..." local tmp_date @@ -19,7 +19,7 @@ function link_to_homedir() { local dotfiles_dir dotfiles_dir="$(builtin cd "$current_dir" && git rev-parse --show-toplevel)" - # 除外ファイルの読み込み + # Load excluded files linkignore=() if [[ -e "$dotfiles_dir/.linkignore" ]]; then while IFS= read -r line; do @@ -27,21 +27,21 @@ function link_to_homedir() { done <"$dotfiles_dir/.linkignore" fi - # シンボリックリンクの作成 + # make symbolic links for f in "$dotfiles_dir"/.??*; do local f_filename f_filename=$(basename "$f") - # 除外ファイルの場合はスキップ + # if excluded file, skip [[ ${linkignore[*]} =~ $f_filename ]] && continue - # .awsは配下のconfigをシンボリックリンクにする + # .aws make the subordinate config a symbolic link if [ "$f_filename" = ".aws" ]; then for config in "$f"/*; do local config_filename config_filename=$(basename "$config") - # 除外ファイルの場合はスキップ + # if excluded file, skip [[ ${linkignore[*]} =~ $config_filename ]] && continue backup_and_link "$config" "$HOME/.aws" "$backupdir" @@ -49,13 +49,13 @@ function link_to_homedir() { continue fi - # .configは配下のディレクトリをシンボリックリンクにする + # .config makes the directory under it a symbolic link if [ "$f_filename" = ".config" ]; then for config in "$f"/*; do local config_filename config_filename=$(basename "$config") - # 除外ファイルの場合はスキップ + # if excluded file, skip [[ ${linkignore[*]} =~ $config_filename ]] && continue backup_and_link "$config" "$HOME/.config" "$backupdir" @@ -63,7 +63,7 @@ function link_to_homedir() { continue fi - # それ以外はそのままホームディレクトリにシンボリックリンクを作成 + # Create a symbolic link to the home directory as is otherwise backup_and_link "$f" "$HOME" "$backupdir" done } diff --git a/scripts/util.sh b/scripts/util.sh index ba6c658..6b674ee 100755 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -46,12 +46,12 @@ function backup_and_link() { f_filename=$(basename "$link_src_file") local f_filepath="$link_dest_dir/$f_filename" - # 既にシンボリックリンクとして存在する場合は削除 + # Delete if already exists as a symbolic link if [[ -L "$f_filepath" ]]; then command rm -f "$f_filepath" fi - # シンボリックリンクでなく実ファイルであればバックアップ + # Backup if it is a real file, not a symbolic link if [[ -e "$f_filepath" && ! -L "$f_filepath" ]]; then command mv "$f_filepath" "$backupdir" fi