Skip to content

Commit

Permalink
Freshy setting 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
nijicha committed Nov 21, 2022
0 parents commit 4f97def
Show file tree
Hide file tree
Showing 26 changed files with 10,713 additions and 0 deletions.
1 change: 1 addition & 0 deletions .chezmoiroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./chezmoi
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: nijicha
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
secrets.yml
../../../Workspace/ghq/github.com/nijicha/dotfiles/.idea
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/chezmoi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Nathakorn Chaninthanadecha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dotfiles
---
15 changes: 15 additions & 0 deletions archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# dotfiles

> dotfiles managed by [chezmoi](https://chezmoi.io)
## Usage
```shell
ASK=1 sh -c "$(curl -fsSL https://raw.githubusercontent.com/nijicha/dotfiles/master/bin/remote_install.sh) -v"
```

## TODO
- [ ] Add Brewfile required by `brew bundle`
- [ ] Add 1password-cli integration
- [ ] Add age | gpg encryption
- [ ] More Config chezmoi https://github.com/twpayne/chezmoi
- [ ] Add .plist of some apps
Empty file added archive/bin/install.sh
Empty file.
27 changes: 27 additions & 0 deletions archive/bin/remote-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Install remotely from single shell command
# Usage : sh -c "$(curl -fsSL https://raw.githubusercontent.com/nijicha/dotfiles/chezmoi/remote_install.sh)"

echo "Installing Xcode Command Line Tools"
xcode-select --install

set -e # -e: exit on error

if [ ! "$(command -v chezmoi)" ]; then
bin_dir="$HOME/.local/bin"
chezmoi="$bin_dir/chezmoi"
if [ "$(command -v curl)" ]; then
sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$bin_dir"
elif [ "$(command -v wget)" ]; then
sh -c "$(wget -qO- https://git.io/chezmoi)" -- -b "$bin_dir"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
else
chezmoi=chezmoi
fi

# exec: replace current process with chezmoi init
exec "$chezmoi" init --apply nijicha
37 changes: 37 additions & 0 deletions archive/chezmoi/dot_antigenrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Load oh-my-zsh library.
antigen use oh-my-zsh

# Load bundles from the default repo (oh-my-zsh).

# Cloud Services
antigen bundle aws
antigen bundle docker

# Node.js
antigen bundle node
antigen bundle npm
antigen bundle yarn

# Ruby
antigen bundle bundler
antigen bundle gem
antigen bundle rails
antigen bundle ruby

# MISC
antigen bundle command-not-found

# VCS
antigen bundle git

# Load bundles from external repos.
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting

# Themes
# Used instead if starship in Arm64 for a while
antigen theme romkatv/powerlevel10k

# Tell Antigen that you're done.
antigen apply
216 changes: 216 additions & 0 deletions archive/chezmoi/dot_zshrc.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# Fig pre block. Keep at the top of this file.
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Apple M1
if [ "$(uname -m)" = "arm64" ]; then
# Use arm64 brew, with fallback to x86 brew
if [ -f /opt/homebrew/bin/brew ]; then
export PATH="/usr/local/bin${PATH+:$PATH}";
eval $(/opt/homebrew/bin/brew shellenv)
fi
else
# Use x86 brew, with fallback to arm64 brew
if [ -f /usr/local/bin/brew ]; then
export PATH="/opt/homebrew/bin${PATH+:$PATH}";
eval $(/usr/local/bin/brew shellenv)
fi
fi

# Load Antigen
CHEZMOI_TMP_PATH=${HOME}/.local/tmp
if [[ ! -f ${CHEZMOI_TMP_PATH}/antigen.zsh ]]; then
printf >&2 "\033[33mantigen\033[0m: ▼ Pull latest antigen script...\n"

if [[ ! -d $CHEZMOI_TMP_PATH ]]; then
mkdir $CHEZMOI_TMP_PATH
fi

curl -L git.io/antigen > "${CHEZMOI_TMP_PATH}/antigen.zsh"
fi

. "${CHEZMOI_TMP_PATH}/antigen.zsh"
antigen init "${HOME}/.antigenrc"

# Google Cloud SDk
# Update PATH
[[ -f "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" ]] && source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
# Source Autocomplete
[[ -f "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" ]] && source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"

# Load powerlevel10k
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# Zsh autocomplete
# Homebrew autocomplete
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH

autoload -Uz compinit
compinit
fi

# User configuration

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
export USE_GKE_GCLOUD_AUTH_PLUGIN=True

# Chezmoi cached variables
export CM_computer_name={{ .computer_name }}
export CM_hostname={{ .hostname }}

# Load asdf
[ -s "/$(brew --prefix asdf)/libexec/asdf.sh" ] && . $(brew --prefix asdf)/libexec/asdf.sh

# Set file size for lib
#
# Use this instead
# https://facebook.github.io/watchman/docs/install.html#mac-os-file-descriptor-limits
#
# Set file size for lib
# ulimit -n 8192

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Alias

alias loip=get_local_ip_address

# ghq
alias wsp="cd $(ghq root)"
alias plgr="cd ~/Workspace/playground"

# Finder
RELAUNCH_FINDER="killall Finder /System/Library/CoreServices/Finder.app"
alias show_dot_files="defaults write com.apple.finder AppleShowAllFiles YES; eval $RELAUNCH_FINDER"
alias hide_dot_files="defaults write com.apple.finder AppleShowAllFiles NO; eval $RELAUNCH_FINDER"

# Quicklook
alias list_ql_quarantine="xattr -r ${HOME}/Library/QuickLook"
alias remove_ql_quarantine="xattr -d -r com.apple.quarantine ${HOME}/Library/QuickLook"

# Functions
function get_local_ip_address {
ifconfig | grep 'inet ' | grep -Fv 127.0.0.1 | awk '{print $2}'
}

# Ref : https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/tools/screenshotTable.sh
function color_table {
T='awesome' # The test text

echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";

for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
}

# P10K Apple silicon | Rosetta2 identicator
function prompt_p10k_my_arch() {
local arch=`uname -m`
case $arch in
"arm64" )
p10k segment -t "m1" -b 0 -f 248;;
"x86_64" )
p10k segment -t "intel" -b 0 -f 248;;
"arm64e" )
p10k segment -t "m1-silicon" -b 0 -f 248;;
"x86_64h" )
p10k segment -t "intel (haswell)" -b 0 -f 248;;
"i386" )
p10k segment -t "intel-32" -b 0 -f 248;;
* )
p10k segment -t "unknown" -b 5 -f 248;;
esac
}

# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"
Loading

0 comments on commit 4f97def

Please sign in to comment.