Skip to content

Commit

Permalink
Merge pull request #23 from nomutin/bash
Browse files Browse the repository at this point in the history
Bash
  • Loading branch information
nomutin authored Aug 6, 2024
2 parents 8abfa2a + 9a2c6a8 commit 3b4c2d7
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 420 deletions.
7 changes: 0 additions & 7 deletions Makefile

This file was deleted.

19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

# .dotfiles

Dotfiles for my host `macOS` and guest `Linux`.
Dotfiles for my `macOS` and `Linux`.

![platform](https://img.shields.io/badge/platform-macOS%20|%20Linux-blue)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/nomutin/dotfiles)
![GitHub repo size](https://img.shields.io/github/repo-size/nomutin/dotfiles)
![LOC](https://sloc.xyz/github/nomutin/dotfiles)
[![ci](https://github.com/nomutin/dotfiles/actions/workflows/ci.yaml/badge.svg)](https://github.com/nomutin/dotfiles/actions/workflows/ci.yaml)

</div>
Expand All @@ -15,12 +18,8 @@ bash -c "$(curl https://raw.githubusercontent.com/nomutin/dotfiles/master/script

## Contents

| App Group | App | Host/Guest | Config |
| --- | --- | --- | :---: |
| Shell | [zsh](https://www.zsh.org) | Host | [🔍](./xdg_config/zsh/.zshrc) |
| | [bash](https://www.gnu.org/software/bash/) | Guest | [🔍](./config/.bashrc.local) |
| Package Manager | [Homebrew](https://brew.sh) | Host | [🔍](./config/Brewfile) |
| | [mise](https://mise.jdx.dev/) | Host/Guest | [🔍](./xdg_config/mise/config.toml) |
| Terminal Emulator | [Alacritty](https://alacritty.org/) | Host | [🔍](./xdg_config/alacritty/alacritty.toml) |
| Terminal Multiplexer | [zellij](https://zellij.dev) | Host/Guest | [🔍](./xdg_config/zellij/config.kdl) |
| Text Editor | [neovim](https://neovim.io) | Host/Guest | [🔍](./xdg_config/nvim/init.lua) |
- Shell - [bash](https://www.gnu.org/software/bash/)
- Package Manager - [Homebrew](https://brew.sh), [mise](https://mise.jdx.dev/)
- Terminal Emulator - [Alacritty](https://alacritty.org/)
- Terminal Multiplexer - [zellij](https://zellij.dev)
- Text Editor - [neovim](https://neovim.io)
17 changes: 0 additions & 17 deletions config/.bashrc.local

This file was deleted.

1 change: 0 additions & 1 deletion config/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ tap "homebrew/bundle"
tap "homebrew/cask-fonts"

brew "mas"
brew "wget"

cask "arc"
cask "alacritty"
Expand Down
40 changes: 40 additions & 0 deletions config/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# ===== Settings =====
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize

# ===== XGD PATH =====
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_STATE_HOME="$HOME/.local/state"

mkdir -p "${XDG_STATE_HOME}"/bash
export ANDROID_USER_HOME="$XDG_DATA_HOME"/android
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
export HISTFILE="$XDG_STATE_HOME"/bash/history
export KERAS_HOME="$XDG_STATE_HOME"/keras
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
export LESSHISTFILE="$XDG_STATE_HOME"/less/history
export TERMINFO="$XDG_DATA_HOME"/terminfo
export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo

# ===== Aliases =====
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias wget='wget --hsts-file="$XDG_DATA_HOME"/wget-hsts'

# ===== Plugins =====
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
eval "$(~/.local/bin/mise activate bash)"
source "$HOME/.rye/env"
24 changes: 0 additions & 24 deletions scripts/deploy.sh

This file was deleted.

47 changes: 15 additions & 32 deletions scripts/init_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,59 @@

set -eu

# ===== Install Xcode Command Line Tools =====
if ! (xcode-select -p &>/dev/null); then
xcode-select --install
fi

# ===== Install Homebrew =====
if ! (type 'brew' >/dev/null 2>&1); then
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

# ===== Install apps =====
brew bundle install --file="${HOME}"/.dotfiles/config/Brewfile

# terminalの表示名を`MBA`に変更
# ===== Mac settings =====
# Terminal display name
sudo scutil --set HostName MBA

# 動きを高速化
# Fasten
defaults write -g com.apple.trackpad.scaling 3
defaults write -g com.apple.mouse.scaling 1.5
defaults write -g KeyRepeat -int 1
defaults write -g InitialKeyRepeat -int 10

# タップしたときクリック
# Click to tap
defaults write -g com.apple.mouse.tapBehavior -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true

# クラッシュレポートを無効化する
defaults write com.apple.CrashReporter DialogType -string "none"

# 未確認のアプリケーションを実行する際のダイアログを無効にする
defaults write com.apple.LaunchServices LSQuarantine -bool false

# ダウンロードしたファイルを開くときの警告ダイアログをなくす
defaults write com.apple.LaunchServices LSQuarantine -bool false

# ゴミ箱を空にする前の警告の無効化
defaults write com.apple.finder WarnOnEmptyTrash -bool false

# Dock関連
# Dock
defaults write com.apple.dock autohide-time-modifier -int 0
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock show-recents -bool false
defaults write com.apple.dock tilesize -int 128

# ネットワークストアファイルを作成しない
# Disable .DS_Store creation
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

# Bluetoothのマルチタッチトラックパッドでクリックを有効化
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true

# Finder関連
# Finder
defaults write com.apple.finder NewWindowTarget -string PfHm
defaults write com.apple.finder NewWindowTargetPath -string "file:///Users/nomura/"
defaults write com.apple.finder ShowRecentTags -int 0
defaults write com.apple.finder ShowMountedServersOnDesktop -int 0
defaults write com.apple.finder SidebarTagsSctionDisclosedState -int 1
defaults write com.apple.finder PreferencesWindow.LastSelection -string SDBR
defaults write -g AppleShowAllExtensions -bool true
defaults write com.apple.finder AppleShowAllFiles -bool YES && killall Finder

# テキストエディットをプレーンテキストで使う
# TextEdit
defaults write com.apple.TextEdit RichText -int 0

# 隠しファイルを常にファインダーに表示する
defaults write com.apple.finder AppleShowAllFiles -bool YES && killall Finder

# スクリーンショットをjpgで保存
# Screenshot
defaults write com.apple.screencapture type jpg

# 全ての拡張子のファイルを表示する
defaults write -g AppleShowAllExtensions -bool true

# .DS_Storeを作成しない
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

killall Finder
killall Dock
sudo shutdown -r now
27 changes: 19 additions & 8 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ set -eu

cd "${HOME}"

# Install my dotfiles
# ===== Install repo =====
if [ ! -d .dotfiles ]; then
git clone https://github.com/nomutin/dotfiles.git .dotfiles
fi

# Install mise
# ===== Install mise =====
if ! (type 'mise' >/dev/null 2>&1); then
curl https://mise.run | sh
fi

cd .dotfiles

# Deploy
make deploy
# ===== Deploy xdg-based configs =====
src="${HOME}/.dotfiles/xdg_config"
tgt="${HOME}/.config"
mkdir -p "$tgt"
for item in "$src"/*; do
ln -s "$item" "$tgt/$(basename "$item")"
done

# ===== Deploy bashrc =====
if [ -f "${HOME}"/.bashrc ]; then
echo 'source "$HOME/.dotfiles/config/bashrc"' >>~/.bashrc
else
ln -s "${HOME}"/.dotfiles/config/bashrc "${HOME}"/.bashrc
fi

# ===== Install dependencies =====
mise install -y

# Set up macOS
# ===== Set up Macos =====
if [ "$(uname)" = "Darwin" ]; then
make init_macos
bash scripts/init_macos.sh
fi
2 changes: 1 addition & 1 deletion xdg_config/alacritty/alacritty.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shell = "zsh"
shell = "bash"

[env]
TERM = "xterm-256color"
Expand Down
1 change: 0 additions & 1 deletion xdg_config/mise/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ lua-language-server = "latest"
neovim = "nightly"
node = "20"
ripgrep = "latest"
rust = "latest"
rye = "latest"
shfmt = "latest"
stylua = "latest"
Expand Down
4 changes: 4 additions & 0 deletions xdg_config/npm/npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prefix=${XDG_DATA_HOME}/npm
cache=${XDG_CACHE_HOME}/npm
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js
logs-dir=${XDG_STATE_HOME}/npm/logs
Loading

0 comments on commit 3b4c2d7

Please sign in to comment.