Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
takyshu98 committed Jan 21, 2024
1 parent 5ee16b1 commit 52c3bfd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 46 deletions.
22 changes: 11 additions & 11 deletions .config/zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 > ")"
Expand All @@ -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)"
14 changes: 7 additions & 7 deletions .zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -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"
37 changes: 18 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 7 additions & 9 deletions scripts/symlink.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}" \;
Expand All @@ -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
# mkdir -m 700 -p "${HOME}/.ssh"

0 comments on commit 52c3bfd

Please sign in to comment.