diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index abd961a..07e5399 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -9,5 +9,11 @@ jobs: - name: build env: CI_MODE: true - run: bash ./bootstrap.sh - + run: | + make + make bootstrap + make dotfiles + make macos + make asdf + make brew + make tmux diff --git a/.gitmodules b/.gitmodules index e69de29..c826d18 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,13 @@ +[submodule "dotbot"] + path = dotbot + url = https://github.com/anishathalye/dotbot + ignore = dirty +[submodule "dotbot-brew"] + path = dotbot-brew + url = https://github.com/d12frosted/dotbot-brew.git +[submodule "dotbot-asdf"] + path = dotbot-asdf + url = https://github.com/sobolevn/dotbot-asdf.git +[submodule "hammerspoon/stackline"] + path = hammerspoon/stackline + url = https://github.com/AdamWagner/stackline.git diff --git a/.zshrc b/.zshrc index 5f05379..7079fa1 100644 --- a/.zshrc +++ b/.zshrc @@ -1,98 +1,138 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH - -# you need to git clone git@github.com:zsh-users/antigen.git to $HOME -if [[ -d $HOME/antigen ]]; then - source $HOME/antigen/antigen.zsh +# 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 -if [[ -f "$HOME/antigen.zsh" ]]; then - source $HOME/antigen.zsh +if [[ ! -f ~/.zinit/bin/zinit.zsh ]]; then + mkdir ~/.zinit + git clone https://github.com/zdharma/zinit.git ~/.zinit/bin fi -if [[ -f "$HOME/dotfiles/wp-completion.bash" ]]; then - autoload bashcompinit - bashcompinit - source $HOME/dotfiles/wp-completion.bash -fi +# load zinit +source ~/.zinit/bin/zinit.zsh + +# 快速目录跳转 +zinit ice lucid wait='1' +# Turbo mode with "wait" +zinit light-mode lucid wait for \ + is-snippet OMZ::lib/history.zsh \ + MichaelAquilina/zsh-you-should-use \ + romkatv/zsh-prompt-benchmark \ + zdharma/history-search-multi-word \ + atload"unalias zi; alias zi='zinit'" \ + ajeetdsouza/zoxide + +# Ref: zdharma/fast-syntax-highlighting +# Note: Use wait 1 second works for kubectl +zinit wait lucid for \ + atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \ + zdharma/fast-syntax-highlighting \ + atload"zpcdreplay" wait"1" \ + OMZP::kubectl \ + blockf \ + zsh-users/zsh-completions \ + atload"!_zsh_autosuggest_start" \ + zsh-users/zsh-autosuggestions \ + as"completion" is-snippet \ + https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker \ + https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose + +# 语法高亮 +zinit ice lucid wait='0' atinit='zpcompinit' +zinit light zdharma/fast-syntax-highlighting + +# 自动建议 +zinit ice lucid wait="0" atload='_zsh_autosuggest_start' +zinit light zsh-users/zsh-autosuggestions + +# 补全 +zinit ice lucid wait='0' +zinit light zsh-users/zsh-completions + +# 加载 OMZ 框架及部分插件 +zinit snippet OMZ::lib/completion.zsh +zinit snippet OMZ::lib/history.zsh +zinit snippet OMZ::lib/key-bindings.zsh +zinit snippet OMZ::lib/theme-and-appearance.zsh +zinit snippet OMZ::plugins/colored-man-pages/colored-man-pages.plugin.zsh +zinit snippet OMZ::plugins/sudo/sudo.plugin.zsh +zinit snippet OMZ::plugins/git-flow/git-flow.plugin.zsh +zinit snippet OMZ::plugins/autojump/autojump.plugin.zsh +zinit snippet OMZ::plugins/mvn/mvn.plugin.zsh +zinit snippet OMZ::plugins/tmux/tmux.plugin.zsh +zinit snippet OMZ::plugins/tmuxinator/tmuxinator.plugin.zsh +zinit snippet OMZ::plugins/command-not-found/command-not-found.plugin.zsh +zinit snippet OMZ::plugins/pip/pip.plugin.zsh + +zinit ice lucid wait='1' +zinit snippet OMZ::plugins/git/git.plugin.zsh + +# Gitignore plugin – commands gii and gi +zinit ice wait"2" lucid +zinit load voronkovich/gitignore.plugin.zsh + +zinit load djui/alias-tips + export ASDF_DIR=$(brew --prefix asdf) -# Load the oh-my-zsh's library. -antigen use oh-my-zsh - -# Bundles from the default repo (robbyrussell's oh-my-zsh). -antigen bundle asdf -antigen bundle gem -antigen bundle git -antigen bundle git-extras -antigen bundle git-flow -antigen bundle mvn -antigen bundle tig -antigen bundle heroku -antigen bundle lein -antigen bundle command-not-found -antigen bundle tmux -antigen bundle tmuxinator -antigen bundle docker -antigen bundle docker-compose - -# Syntax highlighting bundle. -antigen bundle zsh-users/zsh-syntax-highlighting -antigen bundle zsh-users/zsh-autosuggestions -antigen bundle zsh-users/zsh-completions -antigen bundle Tarrasch/zsh-autoenv -antigen bundle rupa/z -antigen bundle supercrabtree/k -antigen bundle zsh-users/zsh-history-substring-search -#antigen bundle tylerreckart/hyperzsh -#antigen bundle extract -antigen bundle z -#antigen bundle mafredri/zsh-async -#antigen bundle sindresorhus/pure -antigen bundle unixorn/autoupdate-antigen.zshplugin - -antigen bundle djui/alias-tips - -# Python Plugins -antigen bundle pip -antigen bundle python -antigen bundle virtualenv +# ASDF +if [ -d "$HOME/.asdf" ]; then +# zinit ice wait lucid +# zinit light asdf-vm/asdf +# OR + load_asdf() { + source $HOME/.asdf/asdf.sh + } + + zinit light-mode wait lucid for \ + atload'load_asdf' \ + zdharma/null +fi + +# zinit light denysdovhan/spaceship-prompt +zinit ice depth=1; zinit light romkatv/powerlevel10k + +zinit ice as"program" from"gh-r" mv"exa* -> exa" pick"exa/exa" lucid atload"alias ls='exa --icons'" +zinit light ogham/exa # OS specific plugins case `uname` in Darwin) - antigen bundle brew - antigen bundle brew-cask - antigen bundle osx + # zinit bundle kiurchv/asdf.plugin.zsh ;; FreeBSD) ;; esac -if type brew &>/dev/null; then - echo "brew completion" - FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH - #fpath=$(brew --prefix)/share/zsh-completions:$fpath - fpath=($HOME/.asdf/completions $fpath) - - +#if type brew &>/dev/null; then +# echo "brew completion" +# FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH +# #fpath=$(brew --prefix)/share/zsh-completions:$fpath +# fpath=($HOME/.asdf/completions $fpath) +#fi + +#. $(brew --prefix asdf)/asdf.sh +#. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash +# Compinit : After zinits, before cdreplay +# https://carlosbecker.com/posts/speeding-up-zsh/ +autoload -Uz compinit +if [ $(date +'%j') != $(stat -f '%Sm' -t '%j' ~/.zcompdump) ]; then + compinit; +else + compinit -C; fi -autoload -Uz compinit && compinit -. $(brew --prefix asdf)/asdf.sh -. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash - - # Load the theme. -# antigen theme agnoster -# workaround for https://github.com/zsh-users/antigen/issues/675 -THEME=denysdovhan/spaceship-prompt -antigen list | grep $THEME; if [ $? -ne 0 ]; then antigen theme $THEME; fi +# zinit theme agnoster +# workaround for https://github.com/zsh-users/zinit/issues/675 + -# Tell Antigen that you're done. -antigen apply +# Tell zinit that you're done. +# zinit apply ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=6' @@ -118,14 +158,10 @@ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=6' # 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" -#transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi -#tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; } +#transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi +#tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; } source $HOME/dotfiles/zsh/common.zsh source $HOME/dotfiles/zsh/keybindings.zsh @@ -147,7 +183,7 @@ fi ZSH_DISABLE_COMPFIX=true -fpath=(~/.zsh/completions $fpath) +# fpath=(~/.zsh/completions $fpath) # space SPACESHIP_DIR_SHOW="${SPACESHIP_DIR_SHOW=true}" @@ -162,4 +198,5 @@ SPACESHIP_DIR_COLOR="${SPACESHIP_DIR_COLOR="cyan"}" # usage adb-screencap > screen.png alias adbcap="adb shell screencap -p" - +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh diff --git a/Brewfile b/Brewfile index cd910fa..968b268 100644 --- a/Brewfile +++ b/Brewfile @@ -1,3 +1,4 @@ +tap "buo/cask-upgrade" tap "homebrew/cask", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git" tap "homebrew/cask-drivers", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git" tap "homebrew/cask-fonts", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git" @@ -5,9 +6,9 @@ tap "homebrew/core", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew tap "homebrew/bundle" tap "homebrew/services" tap "homebrew/cask-versions" -tap "adoptopenjdk/openjdk" # primitives +brew "axel" # https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands brew "coreutils" brew "exa" @@ -32,7 +33,7 @@ brew "rsync" brew "lastpass-cli" brew "youtube-dl" brew "ffmpeg" -brew "imagemagic" +brew "imagemagick" brew "mas" brew "nmap" brew "p7zip" @@ -41,35 +42,27 @@ brew "proxychains-ng" brew "htop" brew "neofetch" brew "readline" -brew "asdf" brew "cmake" -brew "node" brew "sqlite" brew "xz" brew "zlib" # productivity -brew "axel" -brew "exa" -brew "fzf" brew "ripgrep" brew "fd" -brew "hexyl" -brew "xsv" +# brew "hexyl" +# brew "xsv" brew "jq" -brew "hledger" -brew "getantibody/tap/antibody" +# brew "hledger" # dev brew "ruby" brew "go" -brew "cmake" -brew "sqlite" # brew "postgresql" brew "youtube-dl" # brew "heroku" -brew "node" -brew "yarn" +# brew "node" +# brew "yarn" # brew "wrk" if ENV.key? 'CI_MODE' @@ -94,17 +87,13 @@ cask "jd-gui" cask "karabiner-elements" cask "keycastr" cask "licecap" -cask "maccy" cask "mos" cask "mpv" cask "nextcloud" cask "nitroshare" cask "visual-studio-code" cask "syncthing" -cask "shadowsocksx-ng" cask "neteasemusic" -cask "google-trends" -cask "oversight" # open broadcaster software cask "obs" # note-taking app @@ -116,6 +105,16 @@ cask "upic" cask "via" cask "vlc" +# Quick look +cask "qlcolorcode" +cask "qlstephen" +cask "qlmarkdown" +cask "quicklook-json" +cask "qlimagesize" +cask "suspicious-package" +cask "quicklookase" +cask "qlvideo" + mas "WeChat", id: 836500024 mas "Unsplash Wallpapers", id: 1284863847 mas "Microsoft OneNote", id: 784801555 diff --git a/Brewfile-essentials b/Brewfile-essentials new file mode 100644 index 0000000..d440e53 --- /dev/null +++ b/Brewfile-essentials @@ -0,0 +1,69 @@ +tap "homebrew/cask" +tap "homebrew/cask-fonts" +tap "github/gh" +tap "koekeishiya/formulae" +tap "narze/taps" +tap "yqrashawn/goku" + +brew "awscli" +brew "bat" +# brew "diff-so-fancy" +brew "ffmpeg" +brew "ghq" +brew "git" +brew "git-delta" +brew "git-flow" +brew "jq" +brew "mackup" +brew "magic-wormhole" +brew "mas" +brew "mpc" +brew "mpd" +brew "ncmpcpp" +brew "neofetch" +brew "reattach-to-user-namespace" +brew "terminal-notifier" +brew "tldr" +brew "tmux" +brew "tree" +brew "watch" +brew "zsh" + +brew "github/gh/gh" +brew "koekeishiya/formulae/skhd" +brew "koekeishiya/formulae/yabai" +brew "yqrashawn/goku/goku" + +cask "1password" +cask "alfred" +# cask "arq" # Wait for v5 compatability +cask "beardedspice" +cask "bitbar" +cask "dash" +cask "docker" +cask "dropbox" +cask "firefox" +cask "flux" +cask "font-firacode-nerd-font" +cask "font-fantasque-sans-mono-nerd-font" +cask "google-backup-and-sync" +cask "google-chrome" +cask "hazel" +cask "joplin" +cask "kitty" +cask "karabiner-elements" +cask "keyboard-maestro" +cask "ngrok" +cask "omnifocus" +cask "postgres" +cask "postman" +cask "rescuetime" +cask "setapp" +cask "slack" +cask "spotify" +cask "startupizer" +cask "syncthing" +cask "telegram" +cask "the-unarchiver" +cask "visual-studio-code" +cask "whatpulse" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0361a97 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +.PHONY: help + +help: ## Print command list + @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +_prepare: + @git submodule update --init --recursive + +_bootstrap: + @./install -c config/bootstrap.conf.yml + +bootstrap: _prepare dotfiles _bootstrap ## Bootstrap new machine + +dotfiles: ## Update dotfiles + @./install + +macos: ## Run macos script + @./macos/init_mac.sh + +brew: ## Install brew & cask packages + @./install -c config/packages.conf.yml --plugin-dir dotbot-brew + +tmux: ## Install non-brew tools eg. tmux package manager + @./install -c config/tmux.conf.yml + +asdf: ## Install asdf-vm + @./install -c config/asdf-install.conf.yml --plugin-dir dotbot-brew + @./install -c config/asdf.conf.yml --plugin-dir dotbot-asdf + +update: ## Update everything + @make _prepare + @./install -c config/update.conf.yml + +vim: ## Setup vim + @./install -c config/vim.conf.yml + +all: _prepare dotfiles _bootstrap brew tmux asdf ## Run all tasks at once diff --git a/README.md b/README.md index d8118e9..db997d1 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,14 @@ dotfiles config contain vim, zsh, tmux configurations. git clone git@github.com:einverne/dotfiles.git cd dotfiles - bash bootstrap.sh + ./install ## Overview -- zsh -- vim -- tmux - -With - -- [antigen](https://gtk.pw/antigen) to manage zsh plugins, `source ~/.zshrc` to install all zsh plugins -- [vim-plug](https://github.com/junegunn/vim-plug) to manage vim plugins, vim-plug relate configuration is under `vim-plug_vimrc`. In Vim, `:PlugInstall` to install all vim plugins. -- [tpm](https://github.com/tmux-plugins/tpm) to manage tmux plugins, in tmux, press `Ctrl +B` + `I` to install all tmux plugins. +- using [dotbot](https://github.com/anishathalye/dotbot/) to manage dotfiles +- zsh, using [zinit](https://github.com/zdharma/zinit/) as plugin management +- vim, using [vim-plug](https://github.com/junegunn/vim-plug) to manage vim plugins, vim-plug relate configuration is under `vim-plug_vimrc`. In Vim, `:PlugInstall` to install all vim plugins. +- tmux, using [tpm](https://github.com/tmux-plugins/tpm) to manage tmux plugins, in tmux, press `Ctrl +B` + `I` to install all tmux plugins. ### zsh config to see `.zshrc` file diff --git a/bootstrap.sh b/bootstrap.sh index 846c7d8..4e80748 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -12,9 +12,6 @@ fi echo "Setup hostname" sudo scutil --set HostName mac -echo "Install from brew.sh" -# bash brew.sh - echo "Install with Brew Bundle" set +e brew cleanup @@ -41,23 +38,6 @@ ln -s $PWD/git/global.gitconfig $HOME/.gitconfig echo "Setup Zsh" sudo sh -c 'echo /usr/local/bin/zsh >> /etc/shells' sudo chsh -s $(which zsh) -if [ -f ~/.zshrc ]; then - cat ~/.zshrc - mv ~/.zshrc ~/zshrc.bak -fi -ln -s $PWD/.zshrc $HOME/.zshrc - -echo "Setup Vim" -ln -s $PWD/.vimrc $HOME/.vimrc - -echo "Setup Tmux" -ln -s $PWD/tmux/.tmux.conf $HOME/.tmux.conf -ln -s $PWD/tmux/.tmux.conf.local $HOME/.tmux.conf.local - -echo "Setup idea vimrc" -ln -s $PWD/idea/.ideavimrc $HOME/.ideavimrc - -ls -al $HOME echo "Setup applications" echo "- fzf" @@ -69,10 +49,5 @@ echo "Link editors" mkdir -p ~/Applications/ sudo ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code -# echo "Setup Ruby" -# ./ruby/ruby -# echo "Setup Go" -# mkdir -p ~/go - echo "Setup macOS defaults" -bash init_mac.sh +bash etc/init_mac.sh diff --git a/brew.sh b/brew.sh deleted file mode 100644 index bfd9050..0000000 --- a/brew.sh +++ /dev/null @@ -1,27 +0,0 @@ -# https://github.com/mathiasbynens/dotfiles/blob/main/brew.sh -brew update -brew upgrade - -# Install GNU `find`, `locate`, `updatedb`, and `xargs`, `g`-prefixed. -brew install findutils -# Install GNU `sed`, overwriting the built-in `sed`. -brew install gnu-sed --with-default-names - -# Install more recent versions of some macOS tools. -brew install vim --with-override-system-vi -# GNU multiple precision arithmetic library -brew install gmp - -# Install font tools. -# brew tap bramstein/webfonttools -# brew install sfnt2woff -# brew install sfnt2woff-zopfli -# brew install woff2 - -brew install ack -brew install git-lfs -brew install imagemagick --with-webp -brew install p7zip - -# Remove outdated versions from the cellar. -brew cleanup diff --git a/config/asdf-install.conf.yml b/config/asdf-install.conf.yml new file mode 100644 index 0000000..cb9e007 --- /dev/null +++ b/config/asdf-install.conf.yml @@ -0,0 +1,23 @@ +# Asdf dependencies +- brew: + - coreutils + - automake + - autoconf + - openssl + - libyaml + - readline + - libxslt + - libtool + - unixodbc + - unzip + - curl + +- shell: + - description: Clone asdf + quiet: true + command: | + if cd ~/.asdf; + then git pull; + else git clone https://github.com/asdf-vm/asdf.git ~/.asdf; + fi + diff --git a/config/asdf.conf.yml b/config/asdf.conf.yml new file mode 100644 index 0000000..250d32f --- /dev/null +++ b/config/asdf.conf.yml @@ -0,0 +1,17 @@ +- asdf: + - plugin: python + url: https://github.com/danhper/asdf-python.git + global: 3.7.8 + versions: + - 3.7.8 + - 3.6.1 + - plugin: ruby + url: https://github.com/asdf-vm/asdf-ruby.git + global: 2.6.5 + versions: + - 2.6.5 + - plugin: neovim + url: https://github.com/richin13/asdf-neovim.git + global: nightly + versions: + - nightly diff --git a/config/bootstrap.conf.yml b/config/bootstrap.conf.yml new file mode 100644 index 0000000..cc8d2c4 --- /dev/null +++ b/config/bootstrap.conf.yml @@ -0,0 +1,40 @@ +- brew: + - git + - mackup + - mas + - zsh + +# Setup zinit +- create: + - ~/.zinit + +- shell: + - description: Clone zinit + quiet: true + command: | + if cd ~/.zinit/bin; + then git pull; + else git clone https://github.com/zdharma/zinit.git ~/.zinit/bin; fi + +# Change default shell to zsh +- shell: + - description: Change default shell to zsh + quiet: true + command: | + update_shell() { + local shell_path; + shell_path="$(command -v zsh)" + + fancy_echo "Changing your shell to zsh ..." + if ! grep "$shell_path" /etc/shells > /dev/null 2>&1 ; then + fancy_echo "Adding '$shell_path' to /etc/shells" + sudo sh -c "echo $shell_path >> /etc/shells" + fi + sudo chsh -s "$shell_path" "$USER" + } + + update_shell + +- cask: + - lastpass + - syncthing diff --git a/config/install.conf.yml b/config/install.conf.yml new file mode 100644 index 0000000..419f459 --- /dev/null +++ b/config/install.conf.yml @@ -0,0 +1,42 @@ +- defaults: + link: + relink: true + force: true + +- clean: ['~'] + +- link: + ~/.dotfiles: + force: true + path: '' + +- link: + ~/.zshrc: + path: .zshrc + ~/.gitconfig: + path: git/global.gitconfig + ~/.gitignore_global: + path: git/gitignore_global + ~/.tmux.conf: + path: tmux/.tmux.conf + ~/.tmux.conf.local: + path: tmux/.tmux.conf.local + ~/.vim: + path: .vim + ~/.vimrc: + path: .vimrc + ~/.ideavimrc: + path: idea/.ideavimrc + ~/.hammerspoon: + if: '[ `uname` = Darwin ]' + path: hammerspoon + ~/.mackup.cfg: + path: mackup/mackup.cfg + ~/.Brewfile: + path: Brewfile + ~/.skhdrc: + path: skhd/skhdrc + ~/.yabairc: + path: yabai/yabairc + ~/.yabai_focus_display: + path: yabai/yabai_focus_display diff --git a/config/packages.conf.yml b/config/packages.conf.yml new file mode 100644 index 0000000..2348b8f --- /dev/null +++ b/config/packages.conf.yml @@ -0,0 +1,2 @@ +- brewfile: + - ~/.Brewfile diff --git a/config/projects.conf.yml b/config/projects.conf.yml new file mode 100644 index 0000000..102cd4b --- /dev/null +++ b/config/projects.conf.yml @@ -0,0 +1,10 @@ +- defaults: + link: + relink: true + +- create: + - ~/Git + - ~/projects + +- shell: + - cd ~/Git && git clone git@github.com:einverne/einverne.github.io.git diff --git a/config/tmux.conf.yml b/config/tmux.conf.yml new file mode 100644 index 0000000..d035d09 --- /dev/null +++ b/config/tmux.conf.yml @@ -0,0 +1,15 @@ +- brew: + - tmux + +# Setup tpm : tmux plugin manager +- create: + - ~/.tmux/plugins + +- shell: + - description: Clone tpm + quiet: true + command: | + if cd ~/.tmux/plugins/tpm; + then git pull; + else git clone https://github.com/tmux-plugins/tpm.git ~/.tmux/plugins/tpm; + fi diff --git a/config/update.conf.yml b/config/update.conf.yml new file mode 100644 index 0000000..e3b0a6b --- /dev/null +++ b/config/update.conf.yml @@ -0,0 +1,10 @@ +- shell: + - description: Zinit self update + command: zsh -i -c "zinit self-update" + - description: Zinit update + command: zsh -i -c "zinit update" + + - description: Brew update + command: brew update + - description: Cask update + command: brew cu -acy diff --git a/dotbot b/dotbot new file mode 160000 index 0000000..5294594 --- /dev/null +++ b/dotbot @@ -0,0 +1 @@ +Subproject commit 5294594f5aa9c3affd0d656ba6843c1c0b0bce60 diff --git a/dotbot-asdf b/dotbot-asdf new file mode 160000 index 0000000..6aa5289 --- /dev/null +++ b/dotbot-asdf @@ -0,0 +1 @@ +Subproject commit 6aa52891d85fbd7ab00d74484847cdb18533ce80 diff --git a/dotbot-brew b/dotbot-brew new file mode 160000 index 0000000..f67b270 --- /dev/null +++ b/dotbot-brew @@ -0,0 +1 @@ +Subproject commit f67b2704b7d28b7efcb20e544b79a4fa04484400 diff --git a/git/gitignore_global b/git/gitignore_global new file mode 100644 index 0000000..b649761 --- /dev/null +++ b/git/gitignore_global @@ -0,0 +1,49 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +/*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Redis snapshot +dump.rdb + +.vscode +.elixir_ls + +.githooks +.local +.history + +*.gitignored.* diff --git a/hammerspoon/Spoons/BingDaily.spoon/init.lua b/hammerspoon/Spoons/BingDaily.spoon/init.lua index d6e5ef9..096e88f 100644 --- a/hammerspoon/Spoons/BingDaily.spoon/init.lua +++ b/hammerspoon/Spoons/BingDaily.spoon/init.lua @@ -80,7 +80,7 @@ end function obj:init() create_dir(obj.bing_path) if obj.timer == nil then - obj.timer = hs.timer.doEvery(60, function() bingRequest() end) + obj.timer = hs.timer.doEvery(7200, function() bingRequest() end) obj.timer:setNextTrigger(5) else obj.timer:start() diff --git a/hammerspoon/ime.lua b/hammerspoon/ime.lua index ecf1d9d..4bbb615 100644 --- a/hammerspoon/ime.lua +++ b/hammerspoon/ime.lua @@ -8,26 +8,28 @@ end -- app to expected ime config local app2Ime = { - {'/System/Library/CoreServices/Finder.app', 'English'}, - {'/Applications/Alfred 4.app', 'English'}, - {'/Applications/Bitwarden.app', 'English'}, + {'/System/Library/CoreServices/Finder.app', 'Chinese'}, + {'/Applications/Alfred 4.app', 'Chinese'}, + {'/Applications/Bitwarden.app', 'Chinese'}, + {'/Applications/Dash.app', 'Chinese'}, {'/Applications/iTerm.app', 'Chinese'}, - {'/Applications/Xcode.app', 'English'}, + {'/Applications/Lark.app', 'Chinese'}, + {'/Applications/Xcode.app', 'Chinese'}, {'/Applications/GoldenDict.app', 'Chinese'}, {'/Applications/Google Chrome.app', 'Chinese'}, {'/Applications/DingTalk.app', 'Chinese'}, - {'/Applications/Kindle.app', 'English'}, + {'/Applications/Kindle.app', 'Chinese'}, {'/Applications/NeteaseMusic.app', 'Chinese'}, {'/Applications/WeChat.app', 'Chinese'}, {'/Applications/Lark.app', 'Chinese'}, - {'/Applications/System Preferences.app', 'English'}, - {'/Applications/Dash.app', 'English'}, + {'/Applications/System Preferences.app', 'Chinese'}, {'/Applications/MindNode.app', 'Chinese'}, - {'/Applications/Preview.app', 'Chinese'}, {'/Applications/Obsidian.app', 'Chinese'}, - {'/Applications/wechatwebdevtools.app', 'English'}, - {'/Applications/Sketch.app', 'English'}, - {'/Users/einverne/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.8538.31/IntelliJ IDEA.app', 'English'}, + {'/Applications/Preview.app', 'Chinese'}, + {'/Applications/Sketch.app', 'Chinese'}, + {'/Applications/wechatwebdevtools.app', 'Chinese'}, + {'/Applications/WeChat.app', 'Chinese'}, + {'/Users/einverne/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.8538.31/IntelliJ IDEA.app', 'Chinese'}, } function updateFocusAppInputMethod() diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 4f8b602..3aa4493 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -6,6 +6,16 @@ require 'autoscript' require 'ime' -- require 'usb' + +local module = { + 'ime', + 'autoscript' +} + +local function loadModuleByName(modName) +end + + -- hs.loadSpoon("ReloadConfiguration") -- spoon.ReloadConfiguration:start() -- hs.alert.show("Config reload!") @@ -107,6 +117,8 @@ end function ssidChangedCallback() newSSID = hs.wifi.currentNetwork() + local devices = hs.usb.attachedDevices() + if newSSID == homeSSID and lastSSID ~= homeSSID then -- We just joined our home WiFi network hs.alert.show("Welcome home!") @@ -123,10 +135,10 @@ function ssidChangedCallback() if newSSID == workSSID then hs.alert.show("work karabiner setup") - selectKarabinerProfile("Work") + selectKarabinerProfile("goku") else hs.alert.show("built-in karabiner setup") - selectKarabinerProfile("Built-in") + selectKarabinerProfile("goku") end lastSSID = newSSID @@ -194,10 +206,15 @@ else end end +function reloadConfig() + hs.reload() + hs.execute("/bin/launchctl kickstart -k \"gui/${UID}/homebrew.mxcl.yabai\"") +end + hsreload_keys = {hyper, "R"} hsreload_keys = hsreload_keys or {{"cmd", "shift", "ctrl"}, "R"} if string.len(hsreload_keys[2]) > 0 then - hs.hotkey.bind(hsreload_keys[1], hsreload_keys[2], "Reload Configuration", function() hs.reload() end) + hs.hotkey.bind(hsreload_keys[1], hsreload_keys[2], "Reload Configuration", reloadConfig) hs.notify.new({title="Hammerspoon config reloaded", informativeText="Manually trigged via keyboard shortcut"}):send() end @@ -339,19 +356,6 @@ if spoon.ClipShow then spoon.ModalMgr:deactivate({"clipshowM"}) end) - -- Register clipshowM with modal supervisor - hsclipsM_keys = hsclipsM_keys or {"alt", "C"} - if string.len(hsclipsM_keys[2]) > 0 then - spoon.ModalMgr.supervisor:bind(hsclipsM_keys[1], hsclipsM_keys[2], "Enter clipshowM Environment", function() - -- We need to take action upon hsclipsM_keys is pressed, since pressing another key to showing ClipShow panel is redundant. - spoon.ClipShow:toggleShow() - -- Need a little trick here. Since the content type of system clipboard may be "URL", in which case we don't need to activate clipshowM. - if spoon.ClipShow.canvas:isShowing() then - spoon.ModalMgr:deactivateAll() - spoon.ModalMgr:activate({"clipshowM"}) - end - end) - end end ---------------------------------------------------------------------------------------------------- @@ -368,14 +372,6 @@ if spoon.HSaria2 then end end ----------------------------------------------------------------------------------------------------- --- Register Hammerspoon Search -if spoon.HSearch then - hsearch_keys = hsearch_keys or {"alt", "G"} - if string.len(hsearch_keys[2]) > 0 then - spoon.ModalMgr.supervisor:bind(hsearch_keys[1], hsearch_keys[2], 'Launch Hammerspoon Search', function() spoon.HSearch:toggleShow() end) - end -end ---------------------------------------------------------------------------------------------------- -- Register Hammerspoon API manual: Open Hammerspoon manual in default browser @@ -426,15 +422,6 @@ if spoon.CountDown then end end ----------------------------------------------------------------------------------------------------- --- Register lock screen -hslock_keys = hslock_keys or {"alt", "L"} -if string.len(hslock_keys[2]) > 0 then - spoon.ModalMgr.supervisor:bind(hslock_keys[1], hslock_keys[2], "Lock Screen", function() - hs.caffeinate.lockScreen() - end) -end - ---------------------------------------------------------------------------------------------------- -- resizeM modal environment if spoon.WinWin then @@ -549,13 +536,17 @@ if string.len(hstype_keys[2]) > 0 then end) end ----------------------------------------------------------------------------------------------------- --- Register Hammerspoon console -hsconsole_keys = hsconsole_keys or {"alt", "Z"} -if string.len(hsconsole_keys[2]) > 0 then - spoon.ModalMgr.supervisor:bind(hsconsole_keys[1], hsconsole_keys[2], "Toggle Hammerspoon Console", function() hs.toggleConsole() end) -end - ---------------------------------------------------------------------------------------------------- -- Finally we initialize ModalMgr supervisor spoon.ModalMgr.supervisor:enter() + +stackline = require "stackline.stackline.stackline" +local myStackline = { + appearance = { + showIcons = true, -- default is true + }, + features = { + clickToFocus = true + } +} +stackline:init(myStackline) diff --git a/hammerspoon/stackline b/hammerspoon/stackline new file mode 160000 index 0000000..c93a0bd --- /dev/null +++ b/hammerspoon/stackline @@ -0,0 +1 @@ +Subproject commit c93a0bd889f5dc1170a87b0ea7d74c85b06283fe diff --git a/install b/install new file mode 100755 index 0000000..589e7a7 --- /dev/null +++ b/install @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +CONFIG="config/install.conf.yml" +DOTBOT_DIR="dotbot" + +DOTBOT_BIN="bin/dotbot" +BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +cd "${BASEDIR}" +git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive +git submodule update --init --recursive "${DOTBOT_DIR}" + +"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" \ + --verbose \ + --plugin-dir dotbot-brew \ + -c "${CONFIG}" "${@}" diff --git a/install.sh b/install.sh index 1ca62f2..6b78eea 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,6 @@ VIMDIR=${1:-$HOME} # install ctags to solve "Exuberant ctags not found in PATH" error sudo apt-get install -y git zsh zsh-antigen vim vim-gtk tmux -chsh -s $(which zsh) sudo apt-get install -y exuberant-ctags sudo apt-get install -y htop tree zip unzip wget nethogs @@ -34,7 +33,6 @@ if [ "$use_vim_configs" == "Y" ] || [ "$use_vim_configs" == "y" ]; then # link zshrc ln -rsf $PWD/.zshrc $VIMDIR/.zshrc 2> /dev/null #curl -L git.io/antigen > $VIMDIR/antigen.zsh - git clone git@github.com:zsh-users/antigen.git $HOME/antigen fi # install asdf diff --git a/karabiner/karabiner.edn b/karabiner/karabiner.edn index 8d0ae50..c28e674 100644 --- a/karabiner/karabiner.edn +++ b/karabiner/karabiner.edn @@ -45,10 +45,11 @@ :applications {:chrome ["^com\\.google\\.Chrome$"] :chrome-canary [ "^com\\.google\\.Chrome\\.canary$"] :chromes ["^com\\.google\\.Chrome$" "^com\\.google\\.Chrome\\.canary$"] - :ctrlnp ["md\\.obsidian", - "com\\.jetbrains\\.intellij", - "com.electron.lark" - "com\\.google\\.Chrome"] + :ctrlnp ["^md\\.obsidian", + "^com\\.jetbrains\\.intellij", + "^com\\.electron\\.lark" + "^com\\.tencent\\.xinWeChat" + "^com\\.google\\.Chrome"] :finder ["^com\\.apple\\.finder$"] :terminals ["com\\.apple\\.Terminal", "com\\.googlecode\\.iterm2"] diff --git a/karabiner/karabiner.json b/karabiner/karabiner.json index 0432716..8d8c59d 100644 --- a/karabiner/karabiner.json +++ b/karabiner/karabiner.json @@ -2606,10 +2606,11 @@ "conditions": [ { "bundle_identifiers": [ - "md\\.obsidian", - "com\\.jetbrains\\.intellij", - "com.electron.lark", - "com\\.google\\.Chrome" + "^md\\.obsidian", + "^com\\.jetbrains\\.intellij", + "^com\\.electron\\.lark", + "^com\\.tencent\\.xinWeChat", + "^com\\.google\\.Chrome" ], "type": "frontmost_application_if" } @@ -2633,10 +2634,11 @@ "conditions": [ { "bundle_identifiers": [ - "md\\.obsidian", - "com\\.jetbrains\\.intellij", - "com.electron.lark", - "com\\.google\\.Chrome" + "^md\\.obsidian", + "^com\\.jetbrains\\.intellij", + "^com\\.electron\\.lark", + "^com\\.tencent\\.xinWeChat", + "^com\\.google\\.Chrome" ], "type": "frontmost_application_if" } diff --git a/mackup/mackup.cfg b/mackup/mackup.cfg new file mode 100644 index 0000000..7e5c1a2 --- /dev/null +++ b/mackup/mackup.cfg @@ -0,0 +1,11 @@ +[storage] +engine = file_system +path = Sync +directory = Mackup + +[applications_to_sync] +macosx + +[applications_to_ignore] +karabiner-elements + diff --git a/init_mac.sh b/macos/init_mac.sh similarity index 100% rename from init_mac.sh rename to macos/init_mac.sh diff --git a/skhd/skhdrc b/skhd/skhdrc new file mode 100644 index 0000000..2485a3b --- /dev/null +++ b/skhd/skhdrc @@ -0,0 +1,352 @@ +#!/bin/bash + +# NOTE(koekeishiya): A list of all built-in modifier and literal keywords can +# be found at https://github.com/koekeishiya/skhd/issues/1 +# +# A hotkey is written according to the following rules: +# +# hotkey = '<' | +# +# mode = 'name of mode' | ',' +# +# action = '[' ']' | '->' '[' ']' +# ':' | '->' ':' +# ';' | '->' ';' +# +# keysym = '-' | +# +# mod = 'modifier keyword' | '+' +# +# key = | +# +# literal = 'single letter or built-in keyword' +# +# keycode = 'apple keyboard kVK_ values (0x3C)' +# +# proc_map_lst = * +# +# proc_map = ':' +# +# string = '"' 'sequence of characters' '"' +# +# command = command is executed through '$SHELL -c' and +# follows valid shell syntax. if the $SHELL environment +# variable is not set, it will default to '/bin/bash'. +# when bash is used, the ';' delimeter can be specified +# to chain commands. +# +# to allow a command to extend into multiple lines, +# prepend '\' at the end of the previous line. +# +# an EOL character signifies the end of the bind. +# +# -> = keypress is not consumed by skhd +# +# NOTE(koekeishiya): A mode is declared according to the following rules: +# +# mode_decl = '::' '@' ':' | '::' ':' | +# '::' '@' | '::' +# +# name = desired name for this mode, +# +# @ = capture keypresses regardless of being bound to an action +# +# command = command is executed through '$SHELL -c' and +# follows valid shell syntax. if the $SHELL environment +# variable is not set, it will default to '/bin/bash'. +# when bash is used, the ';' delimeter can be specified +# to chain commands. +# +# to allow a command to extend into multiple lines, +# prepend '\' at the end of the previous line. +# +# an EOL character signifies the end of the bind. + +# add an on_enter command to the default mode +# :: default : chunkc border::color 0xff775759 +# +# defines a new mode 'test' with an on_enter command, that captures keypresses +# :: test @ : chunkc border::color 0xff24ccaa +# +# from 'default' mode, activate mode 'test' +# cmd - x ; test +# +# from 'test' mode, activate mode 'default' +# test < cmd - x ; default +# +# launch a new terminal instance when in either 'default' or 'test' mode +# default, test < cmd - return : open -na /Applications/Terminal.app + +# application specific bindings +# +# cmd - n [ +# "kitty" : echo "hello kitty" +# "qutebrowser" : echo "hello qutebrowser" +# "finder" : false +# ] + +# narze's config +# Legends +# Leader : Alt +# Navigation : H / J / K / L (vim) +# Prew / Next : < / > +# Move : Leader + Shift +# Resize : Leader + Cmd +# Monitor : I / O +# Desktop : U / P or Leader + Ctrl + +# Keycodes +# 0x23 = Colemak semicolon / Qwerty P +# 0x2B = Comma / < +# 0x2F = Fullstop / > +# 0x2C = Slash +# open terminal +# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d ~ &> /dev/null + +# close focused window +# alt - w : yabai -m window --close + +# focus window +alt - j : yabai -m window --focus south +alt - h : yabai -m window --focus west +alt - k : yabai -m window --focus north +alt - l : yabai -m window --focus east +# alt - m : yabai -m window --focus recent + +# focus window in stack +alt - 0x2B : yabai -m window --focus stack.prev +alt - 0x2F : yabai -m window --focus stack.next +alt - 0x2C : yabai -m window --focus stack.recent + +# focus monitor +alt - u : ~/.yabai_focus_display prev +# alt + ctrl - h : ~/.yabai_focus_display prev +alt - y : ~/.yabai_focus_display next +# alt + ctrl - i : ~/.yabai_focus_display next + +# move window +alt + cmd + shift - j : yabai -m window --warp south +alt + cmd + shift - h : yabai -m window --warp west +alt + cmd + shift - k : yabai -m window --warp north +alt + cmd + shift - l : yabai -m window --warp east + +# swap window +alt + shift - j : yabai -m window --swap south +alt + shift - h : yabai -m window --swap west +alt + shift - k : yabai -m window --swap north +alt + shift - l : yabai -m window --swap east + +# stack window +alt + ctrl + shift - h : yabai -m window --stack west +alt + ctrl + shift - j : yabai -m window --stack south +alt + ctrl + shift - k : yabai -m window --stack north +alt + ctrl + shift - l : yabai -m window --stack east + +# make floating window fill screen, make it float if not already floating +ctrl + alt + cmd - t : yabai -m window --toggle float; \ + floating=$(yabai -m query --windows --window | jq .floating); \ + [ $floating -eq 1 ] && yabai -m window --grid 1:1:0:0:1:1 + +# float fill left half +ctrl + alt + cmd - h : yabai -m window --grid 1:2:0:0:1:1 +ctrl + alt + cmd - m : yabai -m window --grid 1:2:0:0:1:1 + +# float fill right half +ctrl + alt + cmd - i : yabai -m window --grid 1:2:1:0:1:1 + +# float fill bottom half +ctrl + alt + cmd - n : yabai -m window --grid 2:1:0:1:1:1 + +# float fill top half +ctrl + alt + cmd - e : yabai -m window --grid 2:1:0:0:1:1 + + +# create desktop +ctrl + cmd + alt - m : yabai -m space --create; + +# create desktop, move window and follow focus +ctrl + alt + cmd - k : yabai -m space --create; \ + yabai -m window --space last; \ + yabai -m space --focus last; \ + yabai -m window --grid 1:1:0:0:1:1 + +# destroy desktop +ctrl + cmd + alt + shift - w : yabai -m space --focus prev; \ + yabai -m space next --destroy + +# fast focus desktop +# alt + ctrl - 0x2B : yabai -m space --focus recent +# alt - l : yabai -m space --focus prev +# alt + ctrl - h : yabai -m space --focus prev +# alt - 0x23 : yabai -m space --focus next +# alt + ctrl - i : yabai -m space --focus next +alt - 1 : yabai -m space --focus 1 +alt - 2 : yabai -m space --focus 2 +alt - 3 : yabai -m space --focus 3 +alt - 4 : yabai -m space --focus 4 + +# send window to desktop +# alt + ctrl + shift - 0x2B : yabai -m window --space recent +# alt + shift - l : yabai -m window --space prev +# alt + ctrl + shift - h : yabai -m window --space prev +# alt + shift - 0x23 : yabai -m window --space next +shift + alt - 1 : yabai -m window --space 1 +shift + alt - 2 : yabai -m window --space 2 +shift + alt - 3 : yabai -m window --space 3 +shift + alt - 4 : yabai -m window --space 4 +shift + alt + cmd - 1 : yabai -m window --space 1; yabai -m space --focus 1 +shift + alt + cmd - 2 : yabai -m window --space 2; yabai -m space --focus 2 +shift + alt + cmd - 3 : yabai -m window --space 3; yabai -m space --focus 3 +shift + alt + cmd - 4 : yabai -m window --space 4; yabai -m space --focus 4 + +# send window to desktop and follow focus +# shift + cmd - x : yabai -m window --space $(chunkc get _last_active_desktop); yabai -m space --focus $(chunkc get _last_active_desktop) +# shift + cmd - z : yabai -m window --space prev; yabai -m space --focus prev +# shift + cmd - c : yabai -m window --space next; yabai -m space --focus next +# shift + cmd - 1 : yabai -m window --space 1; yabai -m space --focus 1 +# shift + cmd - 2 : yabai -m window --space 2; yabai -m space --focus 2 +# shift + cmd - 3 : yabai -m window --space 3; yabai -m space --focus 3 +# shift + cmd - 4 : yabai -m window --space 4; yabai -m space --focus 4 + +ctrl + alt - 1 : yabai -m display --focus 1 +ctrl + alt - 2 : yabai -m display --focus 2 +ctrl + alt - 3 : yabai -m display --focus 3 + +# send window to monitor and follow focus +alt + shift - u : yabai -m window --display prev; yabai -m display --focus prev +alt + shift - y : yabai -m window --display next; yabai -m display --focus next +# shift + alt + cmd - 1 : yabai -m window --display 1; yabai -m display --focus 1 +# shift + alt + cmd - 2 : yabai -m window --display 2; yabai -m display --focus 2 +# shift + alt + cmd - 3 : yabai -m window --display 3; yabai -m display --focus 3 + +# increase region size +alt + cmd - a : yabai -m window --resize left:-80:0 +alt + cmd - r : yabai -m window --resize bottom:0:80 +alt + cmd - w : yabai -m window --resize top:0:-80 +alt + cmd - s : yabai -m window --resize right:80:0 + +# decrease region size +alt + cmd + ctrl - a : yabai -m window --resize left:80:0 +alt + cmd + ctrl - r : yabai -m window --resize bottom:0:-80 +alt + cmd + ctrl - w : yabai -m window --resize top:0:80 +alt + cmd + ctrl - s : yabai -m window --resize right:-80:0 + +# set insertion point for focused container +ctrl + alt - h : yabai -m window --insert west +ctrl + alt - m : yabai -m window --insert west +ctrl + alt - n : yabai -m window --insert south +ctrl + alt - e : yabai -m window --insert north +ctrl + alt - i : yabai -m window --insert east + +# rotate tree +alt - r : yabai -m space --rotate 90 + +# mirror tree y-axis +alt + shift - x : yabai -m space --mirror vertical + +# mirror tree x-axis +alt - x : yabai -m space --mirror horizontal + +# toggle desktop padding +alt - a : yabai -m space --toggle padding + +# toggle window fullscreen +alt - f : yabai -m window --toggle fullscreen + +# toggle window native fullscreen +shift + alt - f : yabai -m window --toggle native-fullscreen + +# toggle window zoom +alt - z : yabai -m window --toggle zoom-fullscreen + +# toggle window split type +alt - c : yabai -m window --toggle split + +# toggle window fade +alt - q : yabai -m window --toggle fade + +# float / unfloat window and center on screen +alt - t : yabai -m window --toggle float;\ + yabai -m window --grid 6:6:1:1:4:4 + +# toggle sticky +alt - s : yabai -m window --toggle sticky + +# toggle border +alt - b : yabai -m window --toggle border + +# classic pip +alt - p : yabai -m window --toggle float;\ + yabai -m window --toggle sticky;\ + yabai -m window --toggle topmost;\ + yabai -m window --grid 5:5:3:0:2:2 + +# toggle sticky, float and resize to picture-in-picture size +alt + shift - p : yabai -m window --toggle sticky;\ + yabai -m window --toggle topmost;\ + yabai -m window --toggle border;\ + yabai -m window --toggle pip + +# float next window to be tiled +# shift + alt - t : chunkc set window_float_next 1 + +# change layout of desktop +ctrl + alt - a : yabai -m space --layout bsp; \ + terminal-notifier -title Yabai -message "Bsp mode activated" +ctrl + alt - r: yabai -m space --layout float; \ + terminal-notifier -title Yabai -message "Float mode activated" +ctrl + alt - s : yabai -m space --layout stack; \ + terminal-notifier -title Yabai -message "Stack mode activated" + +# ctrl + alt - l : yabai -m space --deserialize ~/.chunkwm_layout +# ctrl + alt + cmd - l : yabai -m space --serialize ~/.chunkwm_layout + +# Fix screenshot taking in app mode +cmd + shift - 4 -> : yabai -m window --toggle border; sleep 3; yabai -m window --toggle border; +ctrl + cmd + shift - 4 -> : yabai -m window --toggle border; sleep 3; yabai -m window --toggle border; + +# MPC commands +ctrl + alt + cmd + shift - 0x23 : mpc toggle +ctrl + alt + cmd - 0x2B : mpc prev +ctrl + alt + cmd - 0x2F : mpc next + +# Reload yabai +ctrl + alt + cmd - z : osascript -e 'tell application "Keyboard Maestro Engine" to do script "Hide All Windows"' && \ + launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai" + +# Float everything in screen except current window +ctrl + alt + cmd - x : ids=$(yabai -m query --windows --space | jq -r ".[] | select(.floating == 0) | .id") && \ + while IFS= read -r id; do \ + yabai -m window $id --toggle float; \ + done <<< "$ids" && \ + ids=$(yabai -m query --windows --space | jq -r ".[] | select(.floating == 1) | .id") && \ + while IFS= read -r id; do \ + yabai -m window $id --grid 6:6:1:1:4:4; \ + done <<< "$ids" && \ + +# Unfloat +ctrl + alt + cmd - c : ids=$(yabai -m query --windows --space | jq -r ".[] | select(.floating == 1) | .id") && \ + while IFS= read -r id; do \ + yabai -m window $id --toggle float ; \ + done <<< "$ids" + +# Balance windows +alt - 0x2C : yabai -m space --balance + +# Toggle space windows gap +alt - d : yabai -m space --toggle gap + +# Toggle space windows padding +alt - g : yabai -m space --toggle padding + +# Task randomizer +ctrl + alt + cmd + shift - d : osascript ~/Library/Scripts/omnifocus-task-randomizer.applescript + +# Hyper 1-0 +ctrl + alt + cmd + shift - 1 : /Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge + +# change layout of desktop +ctrl + alt - a : yabai -m space --layout bsp +ctrl + alt - d : yabai -m space --layout float +ctrl + alt - s : yabai -m space --layout $(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "float" else "bsp" end') + diff --git a/wp-completion.bash b/wp-completion.bash deleted file mode 100644 index 9df572b..0000000 --- a/wp-completion.bash +++ /dev/null @@ -1,23 +0,0 @@ -# bash completion for the `wp` command - -_wp_complete() { - local OLD_IFS="$IFS" - local cur=${COMP_WORDS[COMP_CWORD]} - - IFS=$'\n'; # want to preserve spaces at the end - local opts="$(wp cli completions --line="$COMP_LINE" --point="$COMP_POINT")" - - if [[ "$opts" =~ \\s* ]] - then - COMPREPLY=( $(compgen -f -- $cur) ) - elif [[ $opts = "" ]] - then - COMPREPLY=( $(compgen -f -- $cur) ) - else - COMPREPLY=( ${opts[*]} ) - fi - - IFS="$OLD_IFS" - return 0 -} -complete -o nospace -F _wp_complete wp diff --git a/yabai/yabai_focus_display b/yabai/yabai_focus_display new file mode 100755 index 0000000..111bb79 --- /dev/null +++ b/yabai/yabai_focus_display @@ -0,0 +1,25 @@ +#!/bin/sh + +# https://github.com/koekeishiya/yabai/issues/225 + +case "${1}" in + next) + step=1 + ;; + prev) + step=-1 + ;; + *) + echo >&2 "ERROR: must provide an argument 'next' or 'prev'!" + exit 1 + ;; +esac + +jq -nr \ + --argjson displays "$(yabai -m query --displays)" \ + --argjson focused "$(yabai -m query --displays --display)" \ + --argjson step "$step" \ + '$displays + | sort_by(.frame.x) + | .[index($focused) + if (index($focused) + $step) < 0 then 0 else $step end].index // $focused.index' \ + | xargs yabai -m display --focus diff --git a/yabai/yabairc b/yabai/yabairc new file mode 100755 index 0000000..38b1693 --- /dev/null +++ b/yabai/yabairc @@ -0,0 +1,69 @@ +#!/usr/bin/env sh + +# global settings +yabai -m config mouse_follows_focus on +yabai -m config focus_follows_mouse autofous +yabai -m config window_placement second_child +yabai -m config window_topmost off +yabai -m config window_shadow on +yabai -m config window_opacity off +yabai -m config window_opacity_duration 0.0 +yabai -m config active_window_opacity 1.0 +yabai -m config normal_window_opacity 0.85 +yabai -m config split_ratio 0.55 +yabai -m config auto_balance off +yabai -m config mouse_modifier fn +yabai -m config mouse_action1 move +yabai -m config mouse_action2 resize +yabai -m config mouse_drop_action stack + +# border +yabai -m config window_border off +yabai -m config window_border_width 6 +yabai -m config active_window_border_color 0xff775759 +yabai -m config normal_window_border_color 0xff555555 +yabai -m config insert_feedback_color 0xffd75f5f + +# general space settings +yabai -m config layout bsp +yabai -m config top_padding 5 +yabai -m config bottom_padding 5 +yabai -m config left_padding 5 +yabai -m config right_padding 5 +yabai -m config window_gap 4 + +yabai -m window --stack next + + +# space label +yabai -m space 1 --label main +yabai -m space 2 --label code +yabai -m space 3 --label git +yabai -m space 4 --label other + +yabai -m rule --add label="Activity Monitor" app="^Activity Monitor$" manage=off +yabai -m rule --add label="Adobe Lightroom Classic" app="Adobe Lightroom Classic" manage=off space=main +yabai -m rule --add label="Alfred Preferences" app="^Alfred Preferences$" manage=off +yabai -m rule --add label="App Store" app="^App Store$" manage=off +yabai -m rule --add label="Calculator" app="^Calculator$" manage=off +yabai -m rule --add label="Dash" app="Dash" manage=off +yabai -m rule --add label="DataGrip" app="DataGrip" manage=off +yabai -m rule --add app="^Discord$" space=7 grid=1:1:0:0:1:1 manage=off +yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off +yabai -m rule --add label="GoldenDict" app="GoldenDict" manage=off +yabai -m rule --add label="IntelliJ IDEA" app="IntelliJ IDEA" manage=off space=code +yabai -m rule --add label="Preview" app="Preview" manage=off +yabai -m rule --add label="System Preferences" app="^System Preferences$" manage=off +yabai -m rule --add label="SmartGit" app="SmartGit" manage=off space=git +yabai -m rule --add label="VirtualBox" app="^VirtualBox$" manage=off + + + +# signals +# focus mouse hovered window when a window is closed, minimized or terminated +yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" +yabai -m signal --add event=window_minimized action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" +yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" + + +echo "yabai configuration loaded.." diff --git a/zsh/alias.zsh b/zsh/alias.zsh index 09d97ba..8ff21a2 100644 --- a/zsh/alias.zsh +++ b/zsh/alias.zsh @@ -1,6 +1,7 @@ alias tmux="TERM=screen-256color tmux -2" alias vi="vim" alias ls="exa" +alias cd="z" alias mux="TERM=screen-256color tmuxinator" #alias ls="ls -alh" alias cp="cp -i"