Skip to content

Instantly share code, notes, and snippets.

@kevbost
Last active March 14, 2022 14:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevbost/eaec3e6c5dca330092d3b447dc4a62ca to your computer and use it in GitHub Desktop.
Save kevbost/eaec3e6c5dca330092d3b447dc4a62ca to your computer and use it in GitHub Desktop.
.oh-my-zsh - My configuration files for OSX
# PATH
# You'll probably need some other path stuff, put it here
# export PATH="$HOME/cool/path:/another/neat/path:$PATH"
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Zsh Theme
ZSH_THEME="nebirhos" # $ZSH/custom/themes/FILE_NAME.zsh-theme
# use async for zsh-autosuggestions
export ZSH_AUTOSUGGEST_USE_ASYNC=true
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# mkdir -p $ZSH_CUSTOM/plugins/kb_custom_plugins && touch $ZSH_CUSTOM/plugins/kb_custom_plugins/kb_custom_plugins.plugin.zsh
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# no commas, space seperated list: plugins=(plugin1 plugin2 plugin3)
plugins=(
git
alias-finder
# kb_custom_plugins # $ZSH_CUSTOM/plugins/kb_custom_plugins/kb_custom_plugins.plugin.zsh
zsh-syntax-highlighting # $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
zsh-autosuggestions # $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
)
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
source $ZSH/oh-my-zsh.sh
# ssh
export SSH_KEY_PATH="~/.ssh/rsa_id"
# See ~/.oh-my-zsh/custom/aliases.zsh for aliases
alias aliases="cat $ZSH_CUSTOM/aliases.zsh"
# Use BREW nano
# https://gist.github.com/BlakeGardner/5587269
alias nano="/usr/local/bin/nano"
# Pipe Highlight to less
# brew install highlight
LESSOPEN="| $(command -v highlight) %s --out-format xterm256 --quiet --force --style andes"
export LESSOPEN
export LESS=" -R"
alias less='less -m -g -i -J --underline-special'
alias more='less'
# Use "highlight" in place of "cat"
alias cat="highlight $1 --out-format xterm256 --quiet --force --style andes"
export PATH="/usr/local/sbin:$HOME/bin:$PATH"
# ---------------------------------------------------------------------------------------
#################
# CORE KB ADDED
#################
# Colors
Color_Off='\e[0m' # Text Reset
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
Reset='\e[0;39m' # Reset
# Useless show off commands with colors
alias ugh="echo -e '\t\n\n${Red}I know right lol\n\n'"
alias damnit="echo -e '\t\n\n${Red}FUCK!\n\n'"
alias awesome="echo -e '\t\n\n${Red}I dont appreciate your sarcasm\n\n'"
alias beautiful="echo -e '\t\n\n${Cyan}Oh stop it, youre making me blush!\n\n'"
alias perfect="echo -e '\t\n\n${Cyan}No, you are!\n\n'"
alias yes!="echo -e '\t\n\n${Cyan}. . . are you SURE that it worked??\n\n'"
alias notreally="echo -e '\t\n\n${Red}Run it and see what happens, nerd.\n\n'"
alias meme="say i luv 2 mehm. bruh, lol so good. i love me meemees."
alias lol="clear && figlet not && figlet today && figlet satan && sleep 1 && clear && echo lol"
# Git Aliases
alias g="git"
alias gs="git status"
alias pushthatshit="push"
alias gpts="git push"
alias gptsu="git push --set-upstream origin HEAD"
# alias gcdagp="git checkout develop && git pull" # see gcmdagp.zsh
# alias gcmagp="git checkout master && git pull" # see gcmdagp.zsh
# alias gcmdagp="gcmagp && gcdagp" # see gcmdagp.zsh
alias glg="git lg"
alias gac="git add . && git commit -m"
alias ghpages="git subtree push --prefix dist origin gh-pages"
alias ghexport="git subtree push --prefix export origin gh-pages"
alias gone="git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'"
alias gfav="git fetch -av"
# Git Log
alias gitlogless="git log --oneline --decorate --date=relative --all --color"
alias gitlog="git log --graph --oneline --decorate --date=relative --all --color"
alias gitlogmore="git log --graph --decorate --pretty=oneline --date=relative --all --color"
# Root Custom
alias c="cat"
alias reload=". ~/.zshrc"
alias delete="rm -rf"
alias edit="code ~/.oh-my-zsh/custom/aliases.zsh"
alias zshrc="code ~/Documents/VSCode_Workspaces/.oh-my-zsh.code-workspace"
alias no="cd .."
alias nono="cd ../.."
alias nonono="cd ../../.."
alias json="jq '.'"
#################
# Random
#################
# the_silver_searcher, ag default override
# brew install the_silver_searcher
alias ag="ag --path-to-ignore '~/.agignore'"
# search terminal history:
# IE: `search_history "search string"`
alias search_history="cat ~/.zsh_history | ag $1"
# Markdown viewer
# https://github.com/charmbracelet/glow
# brew install glow
alias md="glow"
# Overwrite vscode default with code-insiders
# alias codews="see ${ZSH_CUSTOM}/openvscodeworkspace.zsh"
# cat the global npm config file
alias npmrc="cat ~/.npmrc"
# GitKraken - Use in dir while gitkraken is closed - Command only, no args
alias gitkraken='open -na GitKraken --args -p "$(git rev-parse --show-toplevel)"'
# Speedtest
alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
# Finder
alias e.="open ."
# Matrix
alias matrix='LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
# Start Simple Python Server
alias server="python3 -m http.server 8000"
# fucking open .
alias fucking="sudo"
# please open .
alias please="sudo"
# copy instructions
# alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias copy="echo 'use pbcopy like this: pbcopy < file.txt'"
# serialport
# alias serialport="echo options are \"serialportlist\" and \"serialportterm\""
# Docker Aliases
alias dcu="docker-compose up"
alias dcd="docker-compose down"
alias dcb="docker-compose build"
alias dcr="docker-compose restart"
alias dcra="docker-compose run --rm app"
alias dcranpmt="dcra npm test"
# madge is awesome
# plot project dependencies in graph form
# https://www.npmjs.com/package/madge
# madge --image tmp/graph.png path/to/app.js
alias madge="madge"
# homebrew automated update and cleanup
alias brewski="brew update && brew upgrade && brew cleanup; brew doctor"
# run eslint on js & ts via npx
alias lint="npx eslint \"src/**/*.{ts,tsx}\""
# QMK Keyboard
alias qmkrc="codews qmk_firmware"
alias drop="qmk compile"
#################
# CUSTOM WORKSPACE ALIASES
#################
# Variables
Projects='~/Documents/_-Projects'
Workspaces='~/Documents/VSCode_Workspaces'
# Workspace Directory Aliases - Persistent
alias _-="cd ${Projects}"
alias 2014="cd ${Projects}/2014"
alias 2015="cd ${Projects}/2015"
alias 2016="cd ${Projects}/2016"
alias 2017="cd ${Projects}/2017"
alias 2018="cd ${Projects}/2018"
alias 2019="cd ${Projects}/2019"
alias 2020="cd ${Projects}/2020"
alias 2021="cd ${Projects}/2021"
alias 2022="cd ${Projects}/2022"
alias 2023="cd ${Projects}/2023"
alias 2024="cd ${Projects}/2024"
alias 2025="cd ${Projects}/2025"
alias cloned="cd ${Projects}/_Cloned-Repos"
alias downloads="cd ~/Downloads"
alias workspaces="cd ${Workspaces}"
alias ws="cd ${Workspaces}"
# Name stands for:
# "git checkout main develop and git pull"
# Built to pull from main/master, staging & develop branches
# switch to main branch => pull, switch to staging branch => pull, switch to develop branch => pull
# will chack if main branch is named master
# put this file in root ~/.oh-my-zsh/custom directory
# touch $ZSH_CUSTOM/gcmdagp.zsh
# for checking remote branches (a little slower)
# git ls-remote --heads origin BRANCH_NAME
# git checkout main develop and git pull
function gcmdagp() {
gcmagp && gcdagp
}
# git checkout main staging and git pull
function gcmsagp() {
gcmagp && gcsagp
}
# git checkout main staging develop and git pull
function gcmsdagp() {
gcmagp && gcsagp && gcdagp
}
function gcdagp() {
local gc_develop_agp="git checkout develop && git pull"
# If develop branch does NOT exist, exit
if [ ! "$(git branch --list develop)" ]; then
echo "develop branch does not exist, exiting"
return
else
eval "$gc_develop_agp"
fi
}
function gcsagp() {
local gc_staging_agp="git checkout staging && git pull"
# If develop branch does NOT exist, exit
if [ ! "$(git branch --list staging)" ]; then
echo "staging branch does not exist, exiting"
return
else
eval "$gc_staging_agp"
fi
}
function gcmagp() {
local gc_master_agp="git checkout master && git pull"
local gc_main_agp="git checkout main && git pull"
# use `main` if branch exists, else use `master`
if [ "$(git branch --list main)" ]; then
eval "$gc_main_agp"
elif [ "$(git branch --list master)" ]; then
eval "$gc_master_agp"
else
echo "neither main or master branches exist, exiting"
fi
}
# Based on nebirhos zsh theme, moving things around adding n and npm support
# Currently not handling non-git paths in a pretty way.
# Based on robbyrussell's theme, with host, node, and npm indicators. Example:
# @KB ➜ /Users/USERNAME/workspace/gitProjectDir
# # : git:(feature-branch)
# ✓✓✓ :
italic="%{%}"
no_italic="%{%}"
# Formats non-git directories (kindof).
HOST_PROMPT_="%{$fg_bold[cyan]%}@%n➜ %{$fg_bold[yellow]%}%d"$'\n'"###%{$reset_color%}:"
GIT_PROMPT_="%{$fg_bold[blue]%}\$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}"
NODE_PROMPT_="%{$fg_bold[blue]%}node:(%{$fg[green]%}$(node_prompt_info)%{$fg_bold[blue]%})%{$reset_color%}"
NPM_PROMPT_="%{$fg_bold[blue]%}npm:(%{$fg[green]%}$(npm_prompt_info)%{$fg_bold[blue]%}) %{$reset_color%}"
YARN_PROMPT_="%{$fg_bold[blue]%}yarn:(%{$fg[green]%}$(yarn_prompt_info)%{$fg_bold[blue]%}) %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" git:($italic%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%})$no_italic %{$fg[red]%}"$'\n'"✗✗✗%{$reset_color%}:"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})$no_italic %{$fg[green]%}"$'\n'"✓✓✓%{$reset_color%}:"
PROMPT="$HOST_PROMPT_$GIT_PROMPT_"
RPROMPT="$NPM_PROMPT_$YARN_PROMPT_$NODE_PROMPT_"
# get the global n node version
# put this file in root ~/.oh-my-zsh/custom directory
# touch $ZSH_CUSTOM/node.zsh
function node_prompt_info(){
if type node &> /dev/null
then
local node_prompt
node_prompt=$(node -v)
echo "${node_prompt}"
else
echo 'NODE NOT FOUND'
fi
}
# get the global n node version
# put this file in root ~/.oh-my-zsh/custom directory
# touch $ZSH_CUSTOM/npm.zsh
function npm_prompt_info() {
if type npm &> /dev/null
then
local npm_prompt
npm_prompt=$(npm -v)
echo "${npm_prompt}"
else
echo 'NPM NOT FOUND'
fi
}
# put this file in root ~/.oh-my-zsh/custom directory
# touch $ZSH_CUSTOM/codeworkspace.zsh
# - alias `codews` is established at the end of the file
# workspace file names
# MUST BE IDENTICAL TO DIRECTORY NAME
# For example: ~/Documents/VSCode_Workspaces/.oh-my-zsh.code-workspace
# codews .oh-my-zsh <-- will open the workspace file here ^^^
# usage:
# codews # opens current directory only if matching vscode workspace exists
# codews # if no workspace exists for current directory, nothing happens
# codews name-of-directory # checks if argument matches a workspace
# codews idklol # if argument doesnt match workspace, opens a file in vscode called idklol
# shellcheck disable=SC2154,SC2028
function openvscodeworkspace() {
# replace path with your workspace directory
local workspace_directory="${HOME}/Documents/VSCode_Workspaces"
# get directory name without full path
local directory_name=${PWD##*/}
if [ "${1}" ] && [ -f "${workspace_directory}/${1}.code-workspace" ]; then
# first argument exists && argument workspace exists, opening workspaces
code "${workspace_directory}/${1}.code-workspace"
elif [ "${1}" ]; then
# first argument exists && argument workspace does NOT exist, opening argument in code ${1}
code "${1}"
elif [ -f "${workspace_directory}/${directory_name}.code-workspace" ]; then
# no first arugment && workspace exists for directory, opening ${workspace_directory}/${directory_name}.code-workspace in code
code "${workspace_directory}/${directory_name}.code-workspace"
else
# no arguments passed, display error message & open VSCode in PWD
echo "\n${fg_bold[red]}!ALERT! - Workspace named ${fg_bold[cyan]}${directory_name}.code-workspace${fg_bold[red]} does not exist, opening code in PWD\n${reset_color}"
code .
fi
}
alias codews="openvscodeworkspace"
# get the global n node version
# put this file in root ~/.oh-my-zsh/custom directory
# touch $ZSH_CUSTOM/yarn.zsh
function yarn_prompt_info() {
if type yarn &> /dev/null
then
local yarn_prompt
yarn_prompt=$(yarn -v)
echo "${yarn_prompt}"
else
echo 'YARN NOT FOUND'
fi
}
@kevbost
Copy link
Author

kevbost commented Feb 20, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment