Skip to content

Commit

Permalink
Refactor installation (#102)
Browse files Browse the repository at this point in the history
* refactor: set default WORKSPACE_REPOSITORY_URL

* refactor: make if statement short

* refactor: create zprofile by ansible

* refactor: make git task short
  • Loading branch information
rikuson authored May 26, 2024
1 parent 5cceed6 commit 0d8cb66
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ssh-keygen -t ed25519
Run install script.

```bash
curl -fsSL https://raw.githubusercontent.com/rikuson/workspace/HEAD/install.sh | [email protected]:rikuson/workspace.git && zsh -
curl -fsSL https://raw.githubusercontent.com/rikuson/workspace/HEAD/install.sh | zsh -
```

Restart terminal and run `make`.
Expand Down
26 changes: 11 additions & 15 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,29 @@

set -u

WORKSPACE_REPOSITORY_URL=${WORKSPACE_REPOSITORY_URL:-git@github.com:rikuson/workspace.git}

abort() {
printf "%s\n" "$@" >&2
exit 1
}
if [[ -e $HOME/workspace ]]; then
abort '`workspace` directory already exists.'
fi
if [[ -z "$WORKSPACE_REPOSITORY_URL" ]]; then
abort '`WORKSPACE_REPOSITORY_URL` is undefined.'
fi

[[ -e $HOME/workspace ]] && abort '`workspace` directory already exists.'

# Install homebrew
/bin/bash -c `curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh`
if [[ -d /opt/homebrew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi

# Install oh-my-zsh
sh -c `curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh`

source "$(pwd)/roles/cui/templates/.zshrc"

brew update
brew upgrade

# Create bare repository
# Clone repository
git clone $WORKSPACE_REPOSITORY_URL

# Install oh-my-zsh
sh -c `curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh`

# Initialize
brew install ansible
gem install bundler ansible_spec

touch $HOME/.zprofile
67 changes: 22 additions & 45 deletions roles/cui/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Create .zprofile
file:
path: $HOME/.zprofile
state: touch
- name: Create .zshrc
template:
src: roles/cui/templates/.zshrc
Expand All @@ -20,48 +24,21 @@
- import_tasks: ohmyzsh.yml
- import_tasks: neovim.yml

# git
- name: Set git editor
git_config:
name: core.editor
scope: global
value: nvim
- name: Create .gitignore
template:
src: roles/cui/templates/.gitignore
dest: $HOME
- name: Set up global .gitignore
git_config:
name: core.excludesfile
value: ~/.gitignore
scope: global
- name: Show Japanese properly
git_config:
name: core.quotepath
value: false
scope: global
- name: Set pull rule
git_config:
name: pull.rebase
value: true
scope: global
- name: Disable pager for branch
git_config:
name: pager.branch
value: false
scope: global
- name: Disable pager for stash
git_config:
name: pager.stash
value: false
scope: global
- name: Set git email
git_config:
name: user.email
value: '[email protected]'
scope: global
- name: Set git user name
git_config:
name: user.name
value: 'Riku Takeuchi'
scope: global
- name: Set git global configurations
block:
- git_config:
name: "{{ item.name }}"
value: "{{ item.value }}"
scope: global
with_items:
- { name: "core.editor", value: "nvim" }
- { name: "core.excludesfile", value: "~/.gitignore" }
- { name: "core.quotepath", value: "false" }
- { name: "pull.rebase", value: "true" }
- { name: "pager.branch", value: "false" }
- { name: "pager.stash", value: "false" }
- { name: "user.email", value: "[email protected]" }
- { name: "user.name", value: "Riku Takeuchi" }
- template:
src: roles/cui/templates/.gitignore
dest: $HOME

0 comments on commit 0d8cb66

Please sign in to comment.