diff --git a/dot_config/.keep b/dot_config/.keep new file mode 100644 index 0000000..e69de29 diff --git a/dot_config/zsh/.keep b/dot_config/zsh/.keep new file mode 100644 index 0000000..e69de29 diff --git a/dot_config/zsh/editor.zsh b/dot_config/zsh/editor.zsh new file mode 100644 index 0000000..adbf0a8 --- /dev/null +++ b/dot_config/zsh/editor.zsh @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +# Neovim +if command -v nvim &> /dev/null; then + alias vi="nvim" + alias ni="nvim" + alias vim="nvim" + export EDITOR="nvim" +else + export EDITOR="vi" +fi + +alias edit="${EDITOR}" diff --git a/dot_config/zsh/homebrew.zsh b/dot_config/zsh/homebrew.zsh new file mode 100644 index 0000000..d2147d8 --- /dev/null +++ b/dot_config/zsh/homebrew.zsh @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +# Add packages not linked by homebrew to the PATH +PREFIX=$(brew --prefix) +if command -v brew &>/dev/null; then + for pkg in bison flex llvm openjdk; do + if [ -d "$PREFIX/opt/$pkg/bin" ]; then + export PATH="$PREFIX/opt/$pkg/bin":$PATH + fi + done +fi diff --git a/dot_config/zsh/misc.zsh b/dot_config/zsh/misc.zsh new file mode 100644 index 0000000..6d1d087 --- /dev/null +++ b/dot_config/zsh/misc.zsh @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +# Reload zsh configuration +alias reload='. ~/.zshrc' + +# Change Kitty themes +alias set-dark-theme='kitty +kitten themes Rose-pine-moon' +alias set-light-theme='kitty +kitten themes Rose-pine-dawn' + +# MiniZinc +export BIGBAD="compute.optimisation-2020.cloud.edu.au" diff --git a/dot_config/zsh/programming.zsh b/dot_config/zsh/programming.zsh new file mode 100644 index 0000000..29edbef --- /dev/null +++ b/dot_config/zsh/programming.zsh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +### C++ ### +# CMake output compile_commands.json +export CMAKE_EXPORT_COMPILE_COMMANDS=1 +# CMake use Ninja by default +export CMAKE_GENERATOR="Ninja Multi-Config" + +### MiniZinc ### + +if [ -d "/opt/homebrew/share/minizinc/solvers" ]; then + export MZN_SOLVER_PATH=$MZN_SOLVER_PATH:"/opt/homebrew/share/minizinc/solvers" +fi + + +### Python ### +# Add pipx installed binaries to PATH +if [ -d "$HOME/.local/bin" ]; then + export PATH=$PATH:"$HOME/.local/bin" +fi + +### Rust ### +# Add cargo installed binaries to PATH +if [ -d "$HOME/.cargo/bin" ]; then + export PATH=$PATH:"$HOME/.cargo/bin" +fi + diff --git a/dot_config/zsh/ragequit.zsh b/dot_config/zsh/ragequit.zsh new file mode 100644 index 0000000..18e8add --- /dev/null +++ b/dot_config/zsh/ragequit.zsh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +function flip() { + perl -C3 -Mutf8 -lpe '$_=reverse;y/a-zA-Z.['\'',({?!\"<_;‿⁅∴\r/ɐqɔpǝɟƃɥıɾʞ|ɯuodbɹsʇnʌʍxʎzɐqɔpǝɟƃɥıɾʞ|ɯuodbɹsʇnʌʍxʎz˙],'\'')}¿¡,>‾؛⁀⁆∵\n/' <<< "$1" +} + +function fuck() { + CMD="pkill" + which $CMD >/dev/null || CMD="killall" + echo + if [ "$1" "==" "off" ]; then + shift + FLIP=(' (ノಠ益ಠ)ノ彡' '(ノಠ-ಠ)ノ彡') + SIG="-9" + else + [ "$1" "==" "you" ] && shift + FLIP=(' (╯°□°)╯︵' '(ノ ゜Д゜)ノ ︵' '(ノಥДಥ)ノ︵' ' ヽ(`Д´)ノ︵' ' (ノಥ益ಥ)ノ ') + SIG="" + fi + [ -z "$1" ] && { echo "┬─┬ ノ( ゜-゜ノ) patience young grasshopper"; echo; return; } + F=${FLIP[$RANDOM % ${#FLIP[@]} ]} + if $CMD $SIG "$1"; then + echo "$F$(flip $1)"; echo + else + echo "┬─┬ ︵ /(.□. \)"; echo + fi +} diff --git a/dot_config/zsh/tools.zsh b/dot_config/zsh/tools.zsh new file mode 100644 index 0000000..f2fc1b9 --- /dev/null +++ b/dot_config/zsh/tools.zsh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh + +# ls +if command -v exa &> /dev/null; then + alias ls="exa" + alias l="exa -la" +else + alias l="ls -lah" +fi + +# cat +if command -v bat &> /dev/null; then + alias cat="bat" + alias less="bat" +fi + +# fzf - Command line fuzzy finder +if command -v fd &> /dev/null; then + export FZF_DEFAULT_COMMAND='fd --type f' +fi diff --git a/dot_zshrc b/dot_zshrc new file mode 100644 index 0000000..ae02314 --- /dev/null +++ b/dot_zshrc @@ -0,0 +1,50 @@ +export ZPLUG_HOME=$(brew --prefix zplug) +source $ZPLUG_HOME/init.zsh + +zplug "plugins/extract", from:oh-my-zsh +zplug "plugins/git", from:oh-my-zsh +zplug "plugins/gpg-agent", from:oh-my-zsh +zplug "zsh-users/zsh-history-substring-search" +zplug "plugins/history-substring-search", from:oh-my-zsh +zplug "zsh-users/zsh-syntax-highlighting", defer:2 +export _Z_DATA=$HOME/.cache/zjumpdata +zplug "rupa/z", use:z.sh + +zplug "~/.config/zsh/", from:local + +if ! zplug check --verbose; then + printf "Install? [y/N]: " + if read -q; then + echo; zplug install + fi +fi +zplug load + +set -o vi +if zplug check zsh-users/zsh-history-substring-search; then + bindkey '^[[A' history-substring-search-up + bindkey '^[[B' history-substring-search-down +fi + +# History file configuration +[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" +HISTSIZE=50000 +SAVEHIST=10000 + +# History command configuration +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt inc_append_history # add commands to HISTFILE in order of execution +setopt share_history # share command history data +setopt autocd # change directory when given dir without cmd + +# Case insensitive autocompletion +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + +# Start Starship Prompt +if command -v starship &> /dev/null; then + eval "$(starship init zsh)" +fi