From 51c22e985ca72168097be13afc65b0cb663879aa Mon Sep 17 00:00:00 2001 From: craftscat Date: Mon, 18 Mar 2024 22:47:31 +0900 Subject: [PATCH] Recreate dotfiles --- .Brewfile | 56 ++ .config/gh/config.yml | 17 + .config/gh/hosts.yml | 5 + .config/git/ignore | 5 + .../complex_modifications/1710735955.json | 797 ++++++++++++++++++ .config/karabiner/karabiner.json | 223 +++++ .config/starship.toml | 162 ++++ .gitconfig | 91 ++ .gitignore | 3 + .zsh/commands.zsh | 106 +++ .zsh/config.zsh | 47 ++ .zsh/fzf.zsh | 34 + .zsh/plugins.zsh | 18 + .zshrc | 28 + Makefile | 30 + README.md | 12 + bin/git-browse | 14 + bin/git-fzf-add | 14 + bin/git-fzf-reset | 14 + bin/git-fzf-switch | 15 + scripts/macos.sh | 151 ++++ 21 files changed, 1842 insertions(+) create mode 100644 .Brewfile create mode 100644 .config/gh/config.yml create mode 100644 .config/gh/hosts.yml create mode 100644 .config/git/ignore create mode 100644 .config/karabiner/assets/complex_modifications/1710735955.json create mode 100644 .config/karabiner/karabiner.json create mode 100644 .config/starship.toml create mode 100644 .gitconfig create mode 100644 .gitignore create mode 100644 .zsh/commands.zsh create mode 100644 .zsh/config.zsh create mode 100644 .zsh/fzf.zsh create mode 100644 .zsh/plugins.zsh create mode 100644 .zshrc create mode 100644 Makefile create mode 100644 README.md create mode 100755 bin/git-browse create mode 100755 bin/git-fzf-add create mode 100755 bin/git-fzf-reset create mode 100755 bin/git-fzf-switch create mode 100644 scripts/macos.sh diff --git a/.Brewfile b/.Brewfile new file mode 100644 index 0000000..730352b --- /dev/null +++ b/.Brewfile @@ -0,0 +1,56 @@ +tap "homebrew/bundle" +tap "homebrew/cask-fonts" +brew "actionlint" +brew "awscli" +brew "bat" +brew "curl" +brew "deno" +brew "diff-so-fancy" +brew "expect" +brew "eza" +brew "fd" +brew "ffmpeg" +brew "fzf" +brew "gh" +brew "ghq" +brew "git" +brew "go" +brew "golangci-lint" +brew "goreleaser" +brew "httpie" +brew "hugo" +brew "jq" +brew "k9s" +brew "kubernetes-cli" +brew "kubectx" +brew "neovim" +brew "nodenv" +brew "ranger" +brew "ripgrep" +brew "shellcheck" +brew "starship" +brew "tmux" +brew "tree" +brew "wget" +brew "z" +brew "zsh" +cask "1password" +cask "alacritty" +cask "clipy" +cask "discord" +cask "docker" +cask "font-hack-nerd-font" +cask "google-chrome" +cask "google-cloud-sdk" +cask "google-japanese-ime" +cask "iterm2" +cask "karabiner-elements" +cask "onyx" +cask "raycast" +cask "rectangle" +cask "sequel-ace" +cask "slack" +cask "spotify" +cask "the-unarchiver" +cask "visual-studio-code" +cask "vlc" diff --git a/.config/gh/config.yml b/.config/gh/config.yml new file mode 100644 index 0000000..5d14b83 --- /dev/null +++ b/.config/gh/config.yml @@ -0,0 +1,17 @@ +# The current version of the config schema +version: 1 +# What protocol to use when performing git operations. Supported values: ssh, https +git_protocol: https +# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment. +editor: +# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled +prompt: enabled +# A pager program to send command output to, e.g. "less". If blank, will refer to environment. Set the value to "cat" to disable the pager. +pager: +# Aliases allow you to create nicknames for gh commands +aliases: + co: pr checkout +# The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport. +http_unix_socket: +# What web browser gh should use when opening URLs. If blank, will refer to environment. +browser: diff --git a/.config/gh/hosts.yml b/.config/gh/hosts.yml new file mode 100644 index 0000000..ed856cc --- /dev/null +++ b/.config/gh/hosts.yml @@ -0,0 +1,5 @@ +github.com: + git_protocol: ssh + users: + craftscat: + user: craftscat diff --git a/.config/git/ignore b/.config/git/ignore new file mode 100644 index 0000000..c30890b --- /dev/null +++ b/.config/git/ignore @@ -0,0 +1,5 @@ +.DS_Store +Thumbs.d +.idea/ +.vscode/ +*.code-workspace diff --git a/.config/karabiner/assets/complex_modifications/1710735955.json b/.config/karabiner/assets/complex_modifications/1710735955.json new file mode 100644 index 0000000..130fa01 --- /dev/null +++ b/.config/karabiner/assets/complex_modifications/1710735955.json @@ -0,0 +1,797 @@ +{ + "title": "For Japanese (日本語環境向けの設定) (rev 6)", + "rules": [ + { + "description": "コマンドキーを単体で押したときに、英数・かなキーを送信する。(左コマンドキーは英数、右コマンドキーはかな) (rev 3)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "CTRLキーを単体で押したときに、英数・かなキーを送信する。(左CTRLキーは英数、右CTRLキーはかな)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_control", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_control" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_control", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_control" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "オプションキーを単体で押したときに、英数・かなキーを送信する。(左オプションキーは英数キー、右オプションキーはかなキー)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_option", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_option", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_option" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_option", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_option", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_option" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "コマンドキー(左右どちらでも)を単体で押したときに、英数・かなをトグルで切り替える。 (rev 2)", + "manipulators": [ + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "en" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + }, + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "en" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "右コマンドキーを、英数・かなのトグルに変更する", + "manipulators": [ + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "conditions": [ + { + "input_sources": [ + { + "language": "en" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "英数・かなキーを他のキーと同時に押したときに、Optionキーを送信する (rev 3)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "japanese_eisuu", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_alone_timeout_milliseconds": 200 + }, + "to": [ + { + "key_code": "left_option" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "japanese_kana", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_alone_timeout_milliseconds": 200 + }, + "to": [ + { + "key_code": "right_option" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "escキーを押したときに、英数キーも送信する(vim用)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "escape" + }, + "to": [ + { + "key_code": "escape" + }, + { + "key_code": "japanese_eisuu" + } + ] + } + ] + }, + { + "description": "Ctrl+[を押したときに、英数キーも送信する(vim用) (rev 2)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "open_bracket", + "modifiers": { + "mandatory": [ + "control" + ] + } + }, + "to": [ + { + "key_code": "open_bracket", + "modifiers": [ + "control" + ] + }, + { + "key_code": "japanese_eisuu" + } + ], + "conditions": [ + { + "type": "keyboard_type_if", + "keyboard_types": [ + "ansi", + "iso" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "close_bracket", + "modifiers": { + "mandatory": [ + "control" + ] + } + }, + "to": [ + { + "key_code": "close_bracket", + "modifiers": [ + "control" + ] + }, + { + "key_code": "japanese_eisuu" + } + ], + "conditions": [ + { + "type": "keyboard_type_if", + "keyboard_types": [ + "jis" + ] + } + ] + } + ] + }, + { + "description": "Ctrl+[を押したときに、escキーと英数キーを送信する", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "open_bracket", + "modifiers": { + "mandatory": [ + "control" + ] + } + }, + "to": [ + { + "key_code": "escape" + }, + { + "key_code": "japanese_eisuu" + } + ], + "conditions": [ + { + "type": "keyboard_type_if", + "keyboard_types": [ + "ansi", + "iso" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "close_bracket", + "modifiers": { + "mandatory": [ + "control" + ] + } + }, + "to": [ + { + "key_code": "escape" + }, + { + "key_code": "japanese_eisuu" + } + ], + "conditions": [ + { + "type": "keyboard_type_if", + "keyboard_types": [ + "jis" + ] + } + ] + } + ] + }, + { + "description": "英数・かなキーをtoggle方式にする", + "manipulators": [ + { + "conditions": [ + { + "type": "input_source_if", + "input_sources": [ + { + "language": "ja" + } + ] + } + ], + "type": "basic", + "from": { + "key_code": "japanese_kana" + }, + "to": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "conditions": [ + { + "type": "input_source_unless", + "input_sources": [ + { + "language": "ja" + } + ] + } + ], + "type": "basic", + "from": { + "key_code": "japanese_eisuu" + }, + "to": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "右コマンドキーを単体で押したときに、かなキーを送信、左コントロールキーを単体で押したときに、英数キーを送信する。 (rev 2)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_control", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_control" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_command" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + }, + { + "description": "シフトキーを単体で押したときに、英数・かなキーを送信する。(左シフトキーは英数、右シフトキーはかな)", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_shift", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_shift", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "left_shift" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_shift", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_shift", + "lazy": true + } + ], + "to_if_held_down": [ + { + "key_code": "right_shift" + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ] + } + ] + } + ] +} diff --git a/.config/karabiner/karabiner.json b/.config/karabiner/karabiner.json new file mode 100644 index 0000000..ed5b885 --- /dev/null +++ b/.config/karabiner/karabiner.json @@ -0,0 +1,223 @@ +{ + "global": { + "ask_for_confirmation_before_quitting": true, + "check_for_updates_on_startup": true, + "show_in_menu_bar": true, + "show_profile_name_in_menu_bar": false, + "unsafe_ui": false + }, + "profiles": [ + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500, + "mouse_motion_to_scroll.speed": 100 + }, + "rules": [ + { + "description": "コマンドキーを単体で押したときに、英数・かなキーを送信する。(左コマンドキーは英数、右コマンドキーはかな) (rev 3)", + "manipulators": [ + { + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "japanese_eisuu" + } + ], + "to_if_held_down": [ + { + "key_code": "left_command" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "parameters": { + "basic.to_if_held_down_threshold_milliseconds": 100 + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "japanese_kana" + } + ], + "to_if_held_down": [ + { + "key_code": "right_command" + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": [ + { + "consumer_key_code": "display_brightness_decrement" + } + ] + }, + { + "from": { + "key_code": "f2" + }, + "to": [ + { + "consumer_key_code": "display_brightness_increment" + } + ] + }, + { + "from": { + "key_code": "f3" + }, + "to": [ + { + "apple_vendor_keyboard_key_code": "mission_control" + } + ] + }, + { + "from": { + "key_code": "f4" + }, + "to": [ + { + "apple_vendor_keyboard_key_code": "spotlight" + } + ] + }, + { + "from": { + "key_code": "f5" + }, + "to": [ + { + "consumer_key_code": "dictation" + } + ] + }, + { + "from": { + "key_code": "f6" + }, + "to": [ + { + "key_code": "f6" + } + ] + }, + { + "from": { + "key_code": "f7" + }, + "to": [ + { + "consumer_key_code": "rewind" + } + ] + }, + { + "from": { + "key_code": "f8" + }, + "to": [ + { + "consumer_key_code": "play_or_pause" + } + ] + }, + { + "from": { + "key_code": "f9" + }, + "to": [ + { + "consumer_key_code": "fast_forward" + } + ] + }, + { + "from": { + "key_code": "f10" + }, + "to": [ + { + "consumer_key_code": "mute" + } + ] + }, + { + "from": { + "key_code": "f11" + }, + "to": [ + { + "consumer_key_code": "volume_decrement" + } + ] + }, + { + "from": { + "key_code": "f12" + }, + "to": [ + { + "consumer_key_code": "volume_increment" + } + ] + } + ], + "name": "Default profile", + "parameters": { + "delay_milliseconds_before_open_device": 1000 + }, + "selected": true, + "simple_modifications": [], + "virtual_hid_keyboard": { + "country_code": 0, + "indicate_sticky_modifier_keys_state": true, + "mouse_key_xy_scale": 100 + } + } + ] +} \ No newline at end of file diff --git a/.config/starship.toml b/.config/starship.toml new file mode 100644 index 0000000..f9f92a6 --- /dev/null +++ b/.config/starship.toml @@ -0,0 +1,162 @@ +"$schema" = 'https://starship.rs/config-schema.json' + +format = """ +[](color_orange)\ +$os\ +$username\ +[](bg:color_yellow fg:color_orange)\ +$directory\ +[](fg:color_yellow bg:color_aqua)\ +$git_branch\ +$git_status\ +[](fg:color_aqua bg:color_blue)\ +$c\ +$rust\ +$golang\ +$nodejs\ +$php\ +$java\ +$kotlin\ +$haskell\ +$python\ +[](fg:color_blue bg:color_bg3)\ +$docker_context\ +[](fg:color_bg3 bg:color_bg1)\ +$time\ +[ ](fg:color_bg1)\ +$line_break$character""" + +palette = 'gruvbox_dark' + +[palettes.gruvbox_dark] +color_fg0 = '#fbf1c7' +color_bg1 = '#3c3836' +color_bg3 = '#665c54' +color_blue = '#458588' +color_aqua = '#689d6a' +color_green = '#98971a' +color_orange = '#d65d0e' +color_purple = '#b16286' +color_red = '#cc241d' +color_yellow = '#d79921' + +[os] +disabled = false +style = "bg:color_orange fg:color_fg0" + +[os.symbols] +Windows = "󰍲" +Ubuntu = "󰕈" +SUSE = "" +Raspbian = "󰐿" +Mint = "󰣭" +Macos = "󰀵" +Manjaro = "" +Linux = "󰌽" +Gentoo = "󰣨" +Fedora = "󰣛" +Alpine = "" +Amazon = "" +Android = "" +Arch = "󰣇" +Artix = "󰣇" +CentOS = "" +Debian = "󰣚" +Redhat = "󱄛" +RedHatEnterprise = "󱄛" + +[username] +show_always = true +style_user = "bg:color_orange fg:color_fg0" +style_root = "bg:color_orange fg:color_fg0" +format = '[ $user ]($style)' + +[directory] +style = "fg:color_fg0 bg:color_yellow" +format = "[ $path ]($style)" +truncation_length = 3 +truncation_symbol = "…/" + +[directory.substitutions] +"Documents" = "󰈙 " +"Downloads" = " " +"Music" = "󰝚 " +"Pictures" = " " +"Developer" = "󰲋 " + +[git_branch] +symbol = "" +style = "bg:color_aqua" +format = '[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)' + +[git_status] +style = "bg:color_aqua" +format = '[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)' + +[nodejs] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[c] +symbol = " " +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[rust] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[golang] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[php] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[java] +symbol = " " +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[kotlin] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[haskell] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[python] +symbol = "" +style = "bg:color_blue" +format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)' + +[docker_context] +symbol = "" +style = "bg:color_bg3" +format = '[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)' + +[time] +disabled = false +time_format = "%R" +style = "bg:color_bg1" +format = '[[  $time ](fg:color_fg0 bg:color_bg1)]($style)' + +[line_break] +disabled = false + +[character] +disabled = false +success_symbol = '[](bold fg:color_green)' +error_symbol = '[](bold fg:color_red)' +vimcmd_symbol = '[](bold fg:color_green)' +vimcmd_replace_one_symbol = '[](bold fg:color_purple)' +vimcmd_replace_symbol = '[](bold fg:color_purple)' +vimcmd_visual_symbol = '[](bold fg:color_yellow)' diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..1150f4b --- /dev/null +++ b/.gitconfig @@ -0,0 +1,91 @@ +# use separate file for username / github token / etc +[include] + path = ~/.gitconfig.local + +[alias] + # add + ad = !git-fzf-add + adu = add -u + adup = add -u -p + # branch + br = branch + # clone + cl = clone --recursive # Clone a repository including all submodules. + # commit + co = commit -S + cm = commit -S -m + ca = commit -S --amend -m + fixc = commit -S --amend --reuse-message=HEAD + # config + aliases = config --get-regexp alias + # fetch + fc = fetch + # stash + load = !git stash list | fzf --select-1 --preview='' | awk -F ':' '{print $1}' | xargs -r git stash apply + drop = !git stash list | fzf --select-1 --preview='' | awk -F ':' '{print $1}' | xargs -r git stash drop + # status + ss = status -s + # switch + sw = switch + new = switch -c + cd = !git-fzf-switch + # log + l = log --pretty=format:\"%Cgreen%h %Creset%cd %Cblue[%cn] %Creset%s%C(yellow)%d%C(reset)\" --graph --date=relative --decorate --all + lg = log --graph --name-status --pretty=format:\"%C(red)%h %C(reset)(%cd) %C(green)%an %Creset%s %C(yellow)%d%Creset\" --date=relative + his = !git-browse + # push + ps = "!git push origin $(git rev-parse --abbrev-ref HEAD)" + # pull + pl = pull --recurse-submodules + ub = "!git pull origin $(git rev-parse --abbrev-ref HEAD) --recurse-submodules" + ub = pull --rebase origin main + # reset + rs = !git-fzf-reset + undo = reset --soft HEAD^ + cancel = reset --hard HEAD^ + # restore + rst = !git status -s | fzf --preview='' | awk '{print $2}' | xargs git restore + # edit conflicted file on merge + edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; vim `f`" + # add conflicted file on merge + add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`" + +[branch] + # Show most recently changed branches first. + sort = -committerdate + +[color] + status = auto + diff = auto + branch = auto + interactive = auto + grep = auto + ui = auto + +[color "branch"] + current = yellow reverse + local = yellow + remote = green + +[commit] + # https://help.github.com/articles/signing-commits-using-gpg/ + gpgsign = true + +[core] + editor = nvim + +[diff] + tool = nvimdiff + +[difftool "nvimdiff"] + cmd = nvim -d \"$LOCAL\" \"$REMOTE\" + +[mergetool "nvimdiff"] + cmd = nvim -d \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" + trustExitCode = true + +[ghq] + root = Projects + +[pull] + rebase = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..866d010 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.gitconfig.local +.config/gcloud +Brewfile.lock.json diff --git a/.zsh/commands.zsh b/.zsh/commands.zsh new file mode 100644 index 0000000..c4f3ff2 --- /dev/null +++ b/.zsh/commands.zsh @@ -0,0 +1,106 @@ +# ---------------------------- +# self-made commands +# ---------------------------- +export PATH=$PATH:$HOME/bin +export PATH=$PATH:/usr/local/sbin + +# ---------------------------- +# cat / bat +# ---------------------------- +if type "bat" > /dev/null 2>&1; then + alias cat="bat" +fi + +# ---------------------------- +# cd +# ---------------------------- +# auto cd +setopt AUTO_CD +cdpath=(.. ~ ~/src) + +# auto ls +chpwd() { + if [[ $(pwd) != $HOME ]]; then; + ls + fi +} + +# ---------------------------- +# docker +# ---------------------------- +alias dp="docker ps" +alias dcu="docker compose up -d" +alias dcd="docker compose down" +alias dce="docker compose exec" + +# ---------------------------- +# editors +# ---------------------------- +alias v="nvim" + +# ---------------------------- +# git +# ---------------------------- +alias g="git" + +# ---------------------------- +# go +# ---------------------------- +export GO111MODULE=on +export PATH="$(go env GOROOT)/bin:$PATH" +export PATH="$(go env GOPATH)/bin:$PATH" + +# ---------------------------- +# grep / ripgrep +# ---------------------------- +if type "lg" > /dev/null 2>&1; then + alias grep="rg" +fi + +# ---------------------------- +# homebrew +# ---------------------------- +eval $(/opt/homebrew/bin/brew shellenv) + +# ---------------------------- +# kubectl +# ---------------------------- +alias k="kubectl" + +# ---------------------------- +# ls / exa +# ---------------------------- +if type "eza" > /dev/null 2>&1; then + alias ls="eza --icons" +fi +export LSCOLORS=gxfxcxdxbxegedabagacad + +# ---------------------------- +# node +# ---------------------------- +if type "nodenv" > /dev/null 2>&1; then + eval "$(nodenv init -)" +fi + +# ---------------------------- +# ruby +# ---------------------------- +if type "rbenv" > /dev/null 2>&1; then + eval "$(rbenv init - zsh)" +fi +alias be="bundle exec" +alias dbe="RAILS_ENV=development bundle exec" +alias tbe="RAILS_ENV=test bundle exec" +alias bi="bundle install -j4 --path 'vendor/bundle'" +alias rspec="bundle exec rspec" +alias rubocop="RAILS_ENV=local bundle exec rubocop" + +# ---------------------------- +# rust +# ---------------------------- +export PATH="$PATH:$HOME/.cargo/bin" + +# ---------------------------- +# z +# ---------------------------- +. `brew --prefix`/etc/profile.d/z.sh diff --git a/.zsh/config.zsh b/.zsh/config.zsh new file mode 100644 index 0000000..d367946 --- /dev/null +++ b/.zsh/config.zsh @@ -0,0 +1,47 @@ +# ---------------------------- +# Language +# ---------------------------- +if [ -z $$LC_ALL ]; then + export LC_ALL=C +fi +if [ -z $LANG ]; then + export LANG=ja_JP.UTF-8 +fi + +# ---------------------------- +# Color +# ---------------------------- +autoload -Uz colors +colors + +# ---------------------------- +# History +# ---------------------------- +HISTFILE=~/.zsh_history +export HISTSIZE=10000 +export SAVEHIST=100000 + +# share .zshhistory +setopt inc_append_history +setopt share_history + +# Searches the history for commands that begin with the characters you entered +# and completes them with the up and down arrows key. +autoload -U up-line-or-beginning-search +autoload -U down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search +bindkey "^[[A" up-line-or-beginning-search +bindkey "^[[B" down-line-or-beginning-search + +# ---------------------------- +# Editor +# ---------------------------- +export EDITOR="nvim" + +# ---------------------------- +# Others +# ---------------------------- +alias loadzshrc="source $HOME/.zshrc" +alias relogin='exec $SHELL -l' + diff --git a/.zsh/fzf.zsh b/.zsh/fzf.zsh new file mode 100644 index 0000000..25b61dc --- /dev/null +++ b/.zsh/fzf.zsh @@ -0,0 +1,34 @@ +# ---------------------------- +# Setup +# ---------------------------- +if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then + export PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin" +fi + +# ---------------------------- +# Default Setting +# ---------------------------- +export FZF_DEFAULT_COMMAND="fd --type file -I -H -E '.git/'" +export FZF_DEFAULT_OPTS=" + --height 90% --reverse --border + --prompt='➜ ' --margin=1,1 --inline-info + --select-1 --exit-0 --multi + --color fg:-1,bg:-1,hl:33,fg+:250,bg+:235,hl+:33 + --color info:37,prompt:37,pointer:230,marker:230,spinner:37 + --preview 'bat -r :100 --color=always --style=header,grid {}' +" + +# ---------------------------- +# File Search +# ---------------------------- +export FZF_CTRL_T_COMMAND="fd --type file -I -H -E '.git/'" +export FZF_CTRL_T_OPTS=" + --preview 'bat -r :100 --color=always --style=header,grid {}' +" + +# ---------------------------- +# History Search +# ---------------------------- +export FZF_CTRL_R_OPTS=" + --preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview' +" diff --git a/.zsh/plugins.zsh b/.zsh/plugins.zsh new file mode 100644 index 0000000..6e6cec8 --- /dev/null +++ b/.zsh/plugins.zsh @@ -0,0 +1,18 @@ +# ---------------------------- +# Theme +# ---------------------------- +zinit ice as"command" from"gh-r" \ + atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \ + atpull"%atclone" src"init.zsh" +zinit light starship/starship + +# ---------------------------- +# Completions +# ---------------------------- +zinit ice wait'0' lucid; zinit light zsh-users/zsh-completions +zinit ice wait'0' lucid; zinit light zsh-users/zsh-autosuggestions + +# ---------------------------- +# Syntax Highlighting +# ---------------------------- +zinit ice wait'0' lucid; zinit light z-shell/F-Sy-H diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..27bf186 --- /dev/null +++ b/.zshrc @@ -0,0 +1,28 @@ +# -------------------------- +# Plugin manager +# -------------------------- +### Added by Zinit's installer +if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then + print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" + command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" + command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ + print -P "%F{33} %F{34}Installation successful.%f%b" || \ + print -P "%F{160} The clone has failed.%f%b" +fi + +source "$HOME/.local/share/zinit/zinit.git/zinit.zsh" +autoload -Uz _zinit +(( ${+_comps} )) && _comps[zinit]=_zinit + +# -------------------------- +# Loading split files +# -------------------------- +ZSHHOME="${HOME}/.zsh" +if [ -d $ZSHHOME -a -r $ZSHHOME -a -x $ZSHHOME ]; then + for i in $ZSHHOME/*; do + [[ ${i##*/} = *.zsh ]] && + [ \( -f $i -o -h $i \) -a -r $i ] && . $i + done +fi + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6ce202c --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +DOTPATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) +TARGETS := $(wildcard .??*) bin +EXCLUSIONS := .DS_Store .git .gitmodules .github +DOTFILES := $(filter-out $(EXCLUSIONS), $(TARGETS)) + +.DEFAULT_GOAL := help + +.PHONY: list +list: # Show dotfiles + @$(foreach val, $(DOTFILES), /bin/ls -dF $(val);) + +.PHONY: deploy +deploy: # Create symbolic links to home directory + @echo "==> Start to deploy dotfiles to home directory." + @$(foreach val, $(DOTFILES), ln -sfnv $(abspath $(val)) $(HOME)/$(val);) + @echo "==> Grant execution rights to '~/bin/**'." + @chmod +x ~/bin/** + @echo "==> Done." + +ifeq ($(shell uname),Darwin) +.PHONY: init +setup: # Install Homebrew & setup(MacOS ONLY) + @sh scripts/macos.sh +endif + +.PHONY: help +help: # Self-documented Makefile + @grep -E '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/README.md b/README.md new file mode 100644 index 0000000..037a60b --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# dotfiles +![init script test](https://github.com/craft-cat/dotfiles/workflows/init%20script%20test/badge.svg) +![lint](https://github.com/craft-cat/dotfiles/workflows/lint/badge.svg) + +## Installation +```shell +git clone https://github.com/craft-cat/dotfiles.git ~/.dotfiles +cd ~/.dotfiles + +make deploy +make setup +``` diff --git a/bin/git-browse b/bin/git-browse new file mode 100755 index 0000000..60ee236 --- /dev/null +++ b/bin/git-browse @@ -0,0 +1,14 @@ +#!/bin/sh + +# ----------------------- +# git commit browser +# ----------------------- +_gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1" +_viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'" + +git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr% C(auto)%an" "$@" | + fzf --no-sort --reverse --tiebreak=index --no-multi \ + --ansi --preview="$_viewGitLogLine" \ + --header "enter to view, alt-y to copy hash" \ + --bind "enter:execute:$_viewGitLogLine | less -R" \ + --bind "alt-y:execute:$_gitLogLineToHash | xclip" \ No newline at end of file diff --git a/bin/git-fzf-add b/bin/git-fzf-add new file mode 100755 index 0000000..82527d6 --- /dev/null +++ b/bin/git-fzf-add @@ -0,0 +1,14 @@ +#!/bin/sh + +# -------------------------------- +# git status & fzf diff & add +# -------------------------------- +chenges=$(unbuffer git status -s | + fzf -m --ansi --query="$1" --preview="echo {} | awk '{print \$2}' | xargs git diff --color" | + awk '{print $2}') +if [ -n "$chenges" ]; then + selected=$(echo "$chenges" | tr '\n' ' ') + echo "$selected" | xargs git add +fi + +git status -s diff --git a/bin/git-fzf-reset b/bin/git-fzf-reset new file mode 100755 index 0000000..8c586bb --- /dev/null +++ b/bin/git-fzf-reset @@ -0,0 +1,14 @@ +#!/bin/sh + +# -------------------------------------------------- +# git status & fzf diff & reset (unstaging) +# -------------------------------------------------- +changes=$(unbuffer git status -s | + fzf -m --ansi --query="$1" --preview="echo {} | awk '{print \$2}' | xargs git diff --color" | + awk '{print $2}') +if [ -n "$changes" ]; then + selected=$(echo "$changes" | tr '\n' ' ') + echo "$selected" | xargs git reset HEAD +fi + +git status -s diff --git a/bin/git-fzf-switch b/bin/git-fzf-switch new file mode 100755 index 0000000..9f936ef --- /dev/null +++ b/bin/git-fzf-switch @@ -0,0 +1,15 @@ +#!/bin/sh + +# -------------------------------- +# git branch browse & switch +# -------------------------------- +branch=$( + git branch -a | + fzf --exit-0 --layout=reverse --info=hidden --select-1 --query="$1" --preview-window="right,65%" --prompt="CHECKOUT BRANCH > " --preview="echo {} | tr -d ' *' | xargs git lg --color=always" | + head -n 1 | + perl -pe "s/\s//g; s/\*//g; s/remotes\/origin\///g" +) + +if [ -n "$branch" ]; then + git switch "$branch" +fi diff --git a/scripts/macos.sh b/scripts/macos.sh new file mode 100644 index 0000000..bf28a4b --- /dev/null +++ b/scripts/macos.sh @@ -0,0 +1,151 @@ +#!/bin/sh + +##### Setup script for macOS ##### + +if [ "$(uname)" != "Darwin" ] ; then + echo "Not macOS!" + exit 1 +fi + +# Command Line Tools +echo "==> Start to install command Line Tools." +sudo xcode-select --install > /dev/null +echo "==> Command Line Tools are installed." + +# Rosseta +echo "==> Start to install Rosetta." +sudo softwareupdate --install-rosetta --agree-to-license > /dev/null +echo "==> Rosseta is installed." + +# Shell +chsh -s /bin/zsh +echo "==> Set zsh as the default shell" + +# Homebrew +echo "==> Start to install Homebrew." +xcode-select --install > /dev/null +if ! (type "brew" > /dev/null 2>&1); then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" > /dev/null +fi +echo "==> Homebrew is installed." + +echo "==> Start MacOS setup" +# Disable start up sound +sudo nvram StartupMute=%01 +# ----------------------------------------------- +# Finder +# ----------------------------------------------- +sudo chflags nohidden ~/Library +# Show all file name extensions +defaults write com.apple.finder AppleShowAllExtensions -bool true +# Do not show hidden files +defaults write com.apple.finder AppleShowAllFiles -bool false +# Add a quit option to the Finder +defaults write com.apple.Finder QuitMenuItem -bool true +# Show bars +defaults write com.apple.finder ShowToolbar -bool true +defaults write com.apple.finder ShowTabView -bool true +defaults write com.apple.finder ShowPathbar -bool true +defaults write com.apple.finder ShowStatusBar -bool true +# Disable animations +defaults write com.apple.finder DisableAllAnimations -bool true +# Put directories in front of sort by name when selecting sort by name +defaults write com.apple.finder _FXSortFoldersFirst -bool true + +# ----------------------------------------------- +# Dock +# ----------------------------------------------- +# Disable the animation when openning applications +defaults write com.apple.dock launchanim -bool false +# Automatically hide or show the Dock +defaults write com.apple.dock autohide -bool true +# Wipe all app icons from the Dock +defaults write com.apple.dock persistent-apps -array +# Icons +defaults write com.apple.dock magnification -bool true +defaults write com.apple.dock largesize -int 48 +defaults write com.apple.dock tilesize -int 36 +# Position on Screen +defaults write com.apple.dock orientation -string left +# Recently used apps +defaults write com.apple.dock show-recents -bool false +# No apps can be added or removed from the Dock +defaults write com.apple.dock contents-immutable -boolean true + +# ----------------------------------------------- +# Mission Controll +# ----------------------------------------------- +defaults write com.apple.dock mru-spaces -bool true + +# ----------------------------------------------- +# Menubar +# ----------------------------------------------- +# Automatically hide and show the menu bar in full screen +defaults write -g AppleMenuBarVisibleInFullscreen -bool true +# Show Bluetooth option in menubar +defaults write com.apple.controlcenter "NSStatusItem Visible Bluetooth" -bool true +# # Display date, day, and time in the menu bar +defaults write com.apple.menuextra.clock DateFormat -string 'EEE d MMM HH:mm:ss' +# Display battery level in the menu bar +defaults write com.apple.menuextra.battery ShowPercent -bool true + +# ----------------------------------------------- +# Keyboard & Mouse +# ----------------------------------------------- +# Faster key repeat +defaults write NSGlobalDomain KeyRepeat -int 2 +defaults write NSGlobalDomain InitialKeyRepeat -int 15 +# Faster mouse speed +defaults write -g com.apple.mouse.scaling 3 +defaults write -g com.apple.trackpad.scaling 1.5 + +# ----------------------------------------------- +# Audio +# ----------------------------------------------- +defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80 +defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 48 +defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 40 + +# ----------------------------------------------- +# Dialog +# ----------------------------------------------- +# Disable crash report +defaults write com.apple.CrashReporter DialogType -string "none" +# Disable dialog when running unidentified applications +defaults write com.apple.LaunchServices LSQuarantine -bool false +# Disable warning dialog when opening downloaded files +defaults write com.apple.LaunchServices LSQuarantine -bool false + +# ----------------------------------------------- +# Others +# ----------------------------------------------- +# Always display scrollbars +defaults write -g AppleShowScrollBars -string "Always" +# Disable animation when opening and closing windows +defaults write -g NSAutomaticWindowAnimationsEnabled -bool false +# Accelerate window size adjustment +defaults write -g NSWindowResizeTime -float 0.001 +# Disable Quick Look window animation +defaults write -g QLPanelAnimationDuration -float 0 +# Disable dashboard +defaults write com.apple.dashboard mcx-disabled -bool true +# Do not allow .DS_Store files to be created +defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true +defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true +# Use only UTF-8 in terminal +defaults write com.apple.terminal StringEncodings -array 4 + +# Restart the apps +for app in "Finder" \ + "Dock" \ + "SystemUIServer"; do + killall "${app}" > /dev/null +done + +# Install packages with Homebrew. +/opt/homebrew/bin/brew bundle --global --no-lock +# Install fzf key bindings & auto-completion. +echo 'y' | /opt/homebrew/opt/fzf/install + +echo "==> Done." +exec $SHELL -l