diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 41ce865..5bf223a 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -4,27 +4,27 @@ # This file is read after .zshenv file is read. # -# activate plugins +# Activate plugins eval "$(sheldon source)" -# set completions +# Set completions zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # enable completion without distinguishing uppercase or lowercase. except for input uppercase -# set emacs key bindings +# Set emacs key bindings bindkey -e -# set alias +# Set alias alias ls='ls -FG' -# set history options +# Set history options export HISTFILE="${XDG_STATE_HOME}/.zsh_history" export HISTSIZE=3000 export SAVEHIST=3000 -setopt hist_expire_dups_first # delete the oldest duplicate event first when truncating the history -setopt hist_ignore_all_dups # delete old history if history is duplicated -setopt hist_ignore_dups # don't save to history if it overlaps with the previous event -setopt hist_save_no_dups # discard old commands that overlap with new commands +setopt hist_expire_dups_first # Delete the oldest duplicate event first when truncating the history +setopt hist_ignore_all_dups # Delete old history if history is duplicated +setopt hist_ignore_dups # Don't save to history if it overlaps with the previous event +setopt hist_save_no_dups # Discard old commands that overlap with new commands function select-history() { BUFFER="$(history -n -r 1 | fzf --exact --reverse --query="$LBUFFER" --prompt="History > ")" @@ -33,9 +33,9 @@ function select-history() { zle -N select-history bindkey '^r' select-history -# set tool options +# Set tool options export FZF_DEFAULT_OPTS='--height 40% --reverse --border' -# activate runtime +# Activate runtime export PIPENV_VENV_IN_PROJECT=true # create virtual enviroment in each project eval "$(mise activate zsh)" \ No newline at end of file diff --git a/.zshenv b/.zshenv index e0540c8..d75f5b1 100644 --- a/.zshenv +++ b/.zshenv @@ -3,24 +3,24 @@ # @brief initial setup file for both interactive and noninteractive zsh # -# set locale +# Set locale export LANG=ja_JP.UTF-8 -# set path +# Set path export PATH="/usr/local/bin:/usr/sbin:${HOME}/bin:${PATH}" -arch_type="$(arch)" -if [ "${arch_type}" = "i386" ]; then +readonly ARCH_TYPE="$(arch)" +if [ "${ARCH_TYPE}" = "i386" ]; then eval "$(/usr/local/bin/brew shellenv)" # for Intel -elif [ "${arch_type}" = "arm64" ]; then +elif [ "${ARCH_TYPE}" = "arm64" ]; then eval "$(/opt/homebrew/bin/brew shellenv)" # for Apple silicon fi -# set xdg +# Set xdg export XDG_CONFIG_HOME="${HOME}/.config" export XDG_CACHE_HOME="${HOME}/.cache" export XDG_DATA_HOME="${HOME}/.local/share" export XDG_STATE_HOME="${HOME}/.local/state" -# set zdotdir +# Set zdotdir export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" \ No newline at end of file diff --git a/install.sh b/install.sh index ef738b1..0e6ad12 100755 --- a/install.sh +++ b/install.sh @@ -2,31 +2,16 @@ set -eu -echo "Installation has started..." -echo - +readonly ARCH_TYPE="$(arch)" readonly DOTPATH="${HOME}/share/dotfiles" -# Clone repository -if [ ! -d "${DOTPATH}" ]; then - git clone https://github.com/takyshu98/dotfiles.git "${DOTPATH}" # Create $DOTPATH directory at the same time -else - echo "Already downloaded: ${DOTPATH}" - echo "Updating..." - git -C "${DOTPATH}" stash - git -C "${DOTPATH}" switch master - git -C "${DOTPATH}" pull origin master - echo -fi - -cd "${DOTPATH}" - -readonly ARCH_TYPE="$(arch)" -echo "My architecture: ${ARCH_TYPE}" +echo -e "Installation has started...\n" +echo -e "My architecture: ${ARCH_TYPE}\n" # Install Rosetta 2 for Apple silicon if [ "${ARCH_TYPE}" = "arm64" ]; then softwareupdate --install-rosetta --agree-to-license + echo fi # Install Homebrew @@ -42,6 +27,20 @@ elif [ "${ARCH_TYPE}" = "arm64" ]; then export PATH="/opt/homebrew/bin:${PATH}" # for Apple silicon fi +# Clone repository +if [ ! -d "${DOTPATH}" ]; then + git clone https://github.com/takyshu98/dotfiles.git "${DOTPATH}" +else + echo "Already downloaded: ${DOTPATH}" + echo "Updating..." + git -C "${DOTPATH}" stash + git -C "${DOTPATH}" switch master + git -C "${DOTPATH}" pull origin master + echo +fi + +cd "${DOTPATH}" + # Restore macOS settings scripts/defaults.sh echo diff --git a/scripts/symlink.sh b/scripts/symlink.sh index ef53c80..77004d1 100755 --- a/scripts/symlink.sh +++ b/scripts/symlink.sh @@ -1,14 +1,12 @@ #!/bin/bash -DOTPATH="${HOME}/share/dotfiles" +readonly DOTPATH="${HOME}/share/dotfiles" if [ ! -e "${DOTPATH}" ]; then echo "Error: Directory does not exist: ${DOTPATH}" exit 1 fi -cd "${DOTPATH}" || exit 1 - # Make symbolic links from ~/.* to ~/share/dotfiles/.* for file in .??*; do [[ "${file}" == ".DS_Store" ]] && continue @@ -19,7 +17,7 @@ for file in .??*; do ln -fvns "${DOTPATH}/${file}" "${HOME}/${file}" done -# Make symbolic links on the basis of XDG Base Directory +# Make symbolic links on the basis of XDG Base Directory specification [[ -z "${XDG_CONFIG_HOME}" ]] && XDG_CONFIG_HOME="${HOME}/.config" mkdir -p "${XDG_CONFIG_HOME}" find "${DOTPATH}/.config" -maxdepth 1 -exec ln -fvns {} "${XDG_CONFIG_HOME}" \; @@ -34,13 +32,13 @@ mkdir -p "${XDG_DATA_HOME}" mkdir -p "${XDG_STATE_HOME}" # Make directories with reference to Filesystem Hierarchy Standard -mkdir -p ~/bin # for original commands -find "${DOTPATH}/bin/" -type f -perm 0755 -exec ln -fvns {} ~/bin/ \; +mkdir -p "${HOME}/bin" # for original commands +find "${DOTPATH}/bin/" -type f -perm 0755 -exec ln -fvns {} "${HOME}/bin/" \; -mkdir -p ~/src # for code repositories +mkdir -p "${HOME}/src" # for code repositories -mkdir -p ~/tmp # for temporary workspace +mkdir -p "${HOME}/tmp" # for temporary workspace ## shellcheck disable=SC2174 ## https://github.com/koalaman/shellcheck/wiki/SC2174 -# mkdir -m 700 -p ~/.ssh \ No newline at end of file +# mkdir -m 700 -p "${HOME}/.ssh" \ No newline at end of file