Skip to content

Commit

Permalink
Refactor setup script to handle CI environment and existing repositor…
Browse files Browse the repository at this point in the history
…ies (#4)

* Refactor setup script to handle CI environment and existing repositories

* Refactor setup script to handle CI environment and existing repositories

* Refactor setup script to include .bashrc in dotfile symlinks

* Refactor setup script to include .bashrc in dotfile symlinks and handle CI environment

* Refactor setup script to handle installation commands with sudo

* Refactor setup script to always use sudo for installation commands

* Refactor setup script to include .bashrc in dotfile symlinks and handle CI environment

* Refactor setup script to include .bashrc in dotfile symlinks and handle CI environment

* Refactor setup script to use Homebrew for package installation

* Refactor setup script to handle installation commands with sudo or Homebrew

* Refactor setup script to handle installation commands with sudo or Homebrew

* Refactor setup script to handle Rancher Desktop installation

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to handle package installations with Homebrew and anyenv initialization

* Refactor setup script to include .bash_profile in the list of dotfiles for symbolic link creation

* Refactor setup script to update Rancher Desktop installation check

* Refactor setup script to handle Hyper.js installation on Linux and macOS

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to install anyenv-install plugin

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to handle anyenv initialization and plugin installation

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to install anyenv and handle anyenv initialization

* Refactor setup script to install anyenv plugin and handle anyenv initialization

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to include anyenv version check

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to include completion message and exit code

* chmod +x ./setup.sh

* Refactor setup script to fix anyenv initialization issue

* Refactor setup script to fix anyenv initialization issue and include anyenv-install plugin installation

* Refactor setup script to fix anyenv initialization issue and include anyenv-install plugin installation

* Refactor setup script to include anyenv installation and initialization

* Refactor setup script to fix anyenv initialization issue and include anyenv-install plugin installation

* Refactor setup script to fix anyenv initialization issue and include anyenv-install plugin installation

* Refactor setup script to include anyenv installation and initialization

* Refactor setup script to fix anyenv initialization issue and include anyenv-install plugin installation

* Refactor setup script to remove unnecessary code and include anyenv initialization

* Refactor setup script to include anyenv installation and initialization

* Refactor setup script to include anyenv-install plugin installation and fix anyenv initialization issue

* Refactor setup script to include anyenv-install plugin installation and list available installations

* Refactor setup script to include anyenv initialization

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv path and initialization

* Refactor setup script to include anyenv initialization and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to include anyenv installation and update anyenv path

* Refactor setup script to exclude sourcing of .bashrc file

* Refactor setup script to exclude sourcing of .bashrc file and update anyenv installation

* Refactor setup script to exclude sourcing of .bashrc file and update anyenv installation

* Refactor setup script to include displaying version of installed environment

* Refactor setup script to include initializing anyenv and displaying version of installed environment

* Refactor setup script to exclude sourcing of .bashrc file and update anyenv installation

* Refactor setup script to exclude sourcing of .bashrc file and update anyenv installation

* Refactor setup script to include initializing anyenv and displaying version of installed environment

* Refactor setup script to include Hyper.js and direnv installation

* Refactor setup script to include installation of libnotify4 package for Hyper.js on Linux

* Refactor setup script to include installation of libnotify4 package for Hyper.js on Linux and direnv installation

* Refactor setup script to include installation of AWS CLI, aws-vault, jq, and GitHub CLI

* Refactor setup script to include installation and version checks for AWS CLI, aws-vault, jq, and GitHub CLI

* Refactor setup script to simplify installation of aws-vault

* Refactor setup script to include installation of direnv and starship

* Refactor setup script to include installation of direnv and starship

* Refactor setup script to include installation of direnv and starship

* Refactor setup script to include installation of Visual Studio Code

* Refactor setup script to include installation of 1Password, Visual Studio Code, and Hyper.js

* Refactor setup script to include installation of 1Password, Visual Studio Code, and Hyper.js

* Refactor setup script to include installation of 1Password, Visual Studio Code, and Hyper.js

* Refactor setup script to include installation of 1Password, Visual Studio Code, Hyper.js, direnv, starship, and update version checks

* Refactor setup script to include installation of Rancher Desktop if it is not already installed on Linux

* Refactor setup script to include installation of zsh and display zsh version

* Refactor setup script to fix typo in comment

* Refactor setup script to remove unnecessary code related to anyenv installation

* Refactor setup script to include installation of Brave browser on Linux and macOS

* Refactor setup script to include installation of default shell configuration file based on the user's default shell

* Refactor setup script to include installation of default shell configuration file based on user's default shell

* Refactor setup script to include conditional restart suggestion

* Refactor setup script to include installation of zsh and change default shell to zsh

* Refactor setup script to include installation of HackGenNerd Font

* Refactor setup script to fix font installation issue

* Refactor setup script to include installation of HackGenNerd Font and check for successful installation

* Refactor setup script to fix font installation issue

* Refactor setup script to include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to fix font installation issue and include installation of HackGenNerd Font

* Refactor setup script to fix font installation issue and include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to fix font installation issue and include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to fix font installation issue and include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to fix font installation issue and include installation of HackGenNerd Font on Linux and macOS

* Refactor setup script to include pbcopy/pbpaste setup on Linux

* Refactor setup script to include pbcopy/pbpaste setup on Linux and macOS

* Refactor setup script to include installation of deskpad on macOS

* Refactor test-setup.yml to include macOS as a target platform

* Refactor test-setup.yml to include macOS as a target platform

* Refactor setup script to include installation of deskpad on macOS

* Refactor setup script to include installation of deskpad on macOS and pbcopy/pbpaste setup on Linux and macOS

* Refactor setup script to include installation of DeskPad on macOS and improve installation check

* Refactor test-setup.yml to remove matrix strategy and specify runs-on as ubuntu-latest

* Refactor test-setup.yml to include macOS as a target platform

* Refactor setup script to use "brew install deskpad" for macOS installation

* Refactor setup script to include installation of eza on macOS and improve installation check

* Refactor setup script to include installation of .gitconfig on macOS and improve installation check

* Refactor setup script to include installation of .gitconfig on macOS and improve installation check

* Refactor setup script to remove unnecessary echo statements and improve installation process

* Refactor .editorconfig to use UTF-8 encoding and Unix-style newlines

* Refactor setup script to include installation of fzf and z on macOS and improve installation check

* Refactor setup script to include installation of fzf and z on macOS and improve installation check

* Refactor setup script to include installation of AWS CLI on macOS and improve installation check

* Refactor setup script to include installation of bat, fd, and z on macOS and improve installation check

* Refactor fzf setup in .bashrc and .zshrc

* Refactor setup script to remove installation of z package

* Refactor git and bat aliases in .bashrc and .zshrc

* Refactor exa and eza aliases in .bashrc and .zshrc

* Refactor git alias in .bashrc

* Refactor .zshrc to remove pyenv initialization and update comments

* Refactor openjdk configuration in .bashrc and .zshrc

* Refactor mysql-client configuration in .bashrc and .zshrc

* Refactor terraform aliases in .bashrc and .zshrc

* Refactor git aliases in .bashrc and .zshrc

* Refactor shortcut aliases in .bashrc and .zshrc

* Refactor setup script action and workflow

* Refactor setup script action and workflow

* Refactor setup script to remove unnecessary code and add exit statement

* Refactor setup script to improve installation messages

* Refactor setup script error messages to include failure indicators

* Refactor setup script to include git installation check and improve installation messages

* Refactor setup.sh to check for xsel command instead of pbcopy for Linux systems

* Refactor setup script to improve Google Chrome installation messages

* Refactor setup script to check for xsel command instead of pbcopy for Linux systems

* Refactor setup script to fix font installation on macOS

* Refactor setup script to fix font installation check on macOS

* Refactor setup script to remove unnecessary font installation check on macOS

* Refactor setup script to improve font installation check on macOS

* Refactor setup script to fix conditional statement for CI environment

* Refactor setup script to fix font installation check on macOS

* Refactor setup script to include .hyper.js in dotfiles

* Refactor setup script to generalize installation of **env tools
  • Loading branch information
tqer39 authored Oct 20, 2024
1 parent 7133fa4 commit e706638
Show file tree
Hide file tree
Showing 10 changed files with 1,138 additions and 369 deletions.
58 changes: 58 additions & 0 deletions .bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# ------------------------------------------------------------------------------
# brew
# ------------------------------------------------------------------------------
detect_os() {
if [ "$(uname)" == "Darwin" ]; then
PLATFORM=mac
elif [ "$(uname -s)" == "MINGW" ]; then
PLATFORM=windows
elif [ "$(uname -s)" == "Linux" ]; then
PLATFORM=linux
else
PLATFORM="Unknown OS"
abort "Your platform ($(uname -a)) is not supported."
fi
}

is_exists() {
which "$1" >/dev/null 2>&1
return $?
}

is_linux() {
if [ "$PLATFORM" == 'linux' ]; then
return 0
else
return 1
fi
}

is_mac() {
if [ "$PLATFORM" == 'mac' ]; then
return 0
else
return 1
fi
}

if [[ $(command -v brew) ]]; then
if is_linux; then
if [ -r "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh" ]; then
# shellcheck source=/dev/null
. "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh"
fi
fi

if is_mac; then
if [ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]; then
# shellcheck source=/dev/null
. "/opt/homebrew/etc/profile.d/bash_completion.sh"
fi
fi
fi

# anyenv
export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"
294 changes: 294 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
#!/bin/bash

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
if test -r "$HOME/.dircolors";then
eval "$(dircolors -b ~/.dircolors)"
else
eval "$(dircolors -b)"
fi
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f "$HOME/.bash_aliases" ]; then
# shellcheck source=/dev/null
. "$HOME/.bash_aliases"
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# shellcheck source=/dev/null
. /etc/bash_completion
fi

# ------------------------------------------------------------------------------
# \shellcheck
# ------------------------------------------------------------------------------
if [[ $(command -v shellcheck) ]]; then
alias sc='shellcheck'
function schelp() {
curl -s https://raw.githubusercontent.com/wiki/koalaman/shellcheck/"$1".md
}
fi

alias help-me='echo "
ctrl+a\t\t:行頭に移動
ctrl+e\t\t:行末に移動
ctrl+h\t\t:後方に1文字削除
meta(esc)+b\t:一語後退
meta(esc)+f\t:一語前進
ctrl+u\t\t:行頭まで削除
ctrl+l\t\t:ターミナルの内容をクリア
ctrl+c\t\t:実行中のコマンドを終了
ctrl+r\t\t:コマンド履歴の検索
ctrl+insert\t:コピー
shift+insert\t:貼り付け
ctrl+d\t\t:ターミナルを強制終了
"'

# ------------------------------------------------------------------------------
# pre-commit
# ------------------------------------------------------------------------------
if [[ $(command -v pre-commit) ]]; then
alias pcv="pre-commit -V"
alias pci="pre-commit install --install-hooks"
alias pcra="pre-commit run -a"
fi

# ------------------------------------------------------------------------------
# Rancher Desktop
# ------------------------------------------------------------------------------
export PATH="/home/tqer39/.rd/bin:$PATH"

# shortcut
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias dl='cd ~/Downloads'
alias d='cd ~/Desktop'
alias work='cd ~/workspace'

# brew
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

# git
if [[ $(command -v git) ]]; then
alias g='git'
alias gb='git branch'
alias ga='git add'
alias gc='git commit -am'
alias gca='git commit --amend'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gm='git merge'
alias gr="git rebase"
alias grc="git rebase --continue"
alias gra="git rebase --abort"
alias gpl='git pull'
alias gps='git push'
alias gpso='git push origin'
alias gpso-this='git push --set-upstream origin $(git branch --contains | cut -d " " -f 2)'
alias gstt='git status'
alias gsts='git stash'
alias gsw='git switch'
alias gswc='git switch -c'
alias gl='git log --oneline'
alias gbm='git branch --merged'
alias gbm-all='git branch --merged|egrep -v "\*|develop|main"|xargs git branch' # -d で削除, -D で完全削除
fi

# anyenv
export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"

# direnv
eval "$(direnv hook zsh)"

# pbcopy/pbpaste
if command -v xsel &> /dev/null; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
fi

# fzf
if [[ $(command -v brew) ]]; then
if [ "$(brew list | grep -c "^fzf@*.*$")" -gt 0 ]; then
# shellcheck source=/dev/null
[ -f "$HOME/.fzf.bash" ] && . $HOME/.fzf.bash
fi
fi

# git
if command -v git &> /dev/null; then
alias g='git'
alias gb='git branch'
alias ga='git add'
alias gc='git commit -am'
alias gca='git commit --amend'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gm='git merge'
alias gr="git rebase"
alias grc="git rebase --continue"
alias gra="git rebase --abort"
alias gpl='git pull'
alias gps='git push'
alias gpso='git push origin'
alias gstt='git status'
alias gsts='git stash'
alias gsw='git switch'
alias gswc='git switch -c'
alias gl='git log --oneline'
alias gbm='git branch --merged'
alias gbm-all='git branch --merged|egrep -v "\*|develop|main"|xargs git branch' # -d で削除, -D で完全削除
fi

# bat
if command -v bat; then
alias cat="bat"
fi

# eza
if [[ $(command -v eza) ]]; then
alias e='eza --icons --git'
alias l=e
alias ls=e
alias ea='eza -a --icons --git'
alias la=ea
alias ee='eza -aahl --icons --git'
alias ll=ee
alias et='eza -T -L 3 -a -I "node_modules|.git|.cache" --icons'
alias lt=et
alias eta='eza -T -a -I "node_modules|.git|.cache" --color=always --icons | less -r'
alias lta=eta
alias l='clear && ls'
fi

# openjdk
if [[ $(command -v brew) ]]; then
if [ "$(brew list | grep -c "^openjdk@*.*$")" -gt 0 ]; then
PATH="$(brew --prefix openjdk@11)/bin:$PATH"
export PATH
fi
fi

# mysql-client
if [[ $(command -v brew) ]]; then
if [ "$(brew list | grep -c "^mysql-client@*.*$")" -gt 0 ]; then
PATH="$(brew --prefix mysql-client)/bin:$PATH"
export PATH
fi
fi

# terraform
if [[ $(command -v terraform) ]]; then
alias tf='terraform'
alias tfi='terraform init'
alias tfi='terraform init --auto-approve'
alias tff='terraform fmt'
alias tfp='terraform plan'
alias tfa='terraform apply'
alias tfi='terraform import'
alias tfaa='terraform apply --auto-approve'
alias tfsl='terraform state list'
fi

# Starship ... # see https://starship.rs/ja-jp/guide/
# ※ 一番最後の行に設定が必要
if command -v starship &> /dev/null; then
eval "$(starship init bash)"
fi

echo "bash..."
Loading

0 comments on commit e706638

Please sign in to comment.