Last active
December 6, 2018 07:28
-
-
Save Kadrei/b5bfa262aad868578e94dd27a5726726 to your computer and use it in GitHub Desktop.
Oh My Zsh Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ZSH CONFIGURATION FILE | |
# BY BENEDIKT KUSEMANN | |
# VERSION 16.07.2018 | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/benedikt.kusemann/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
SPACESHIP_TIME_SHOW=true | |
SPACESHIP_CHAR_SYMBOL="△" | |
SPACESHIP_CHAR_SUFFIX=" " | |
SPACESHIP_TIME_SHOW=true | |
SPACESHIP_EXIT_CODE_SHOW="true" | |
SPACESHIP_GIT_STATUS_DIVERGED="⚡" #"⇕" | |
ZSH_THEME="spaceship" | |
# Uncomment the following line to use case-sensitive completion. | |
CASE_SENSITIVE="false" | |
# Uncomment the following line to use hyphen-insensitive completion. Case | |
# sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment the following line to disable bi-weekly auto-update checks. | |
# DISABLE_AUTO_UPDATE="true" | |
# Uncomment the following line to change how often to auto-update (in days). | |
export UPDATE_ZSH_DAYS=7 | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
HIST_STAMPS="dd.mm.yyyy" | |
HIST_IGNORE_SPACE="true" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=/path/to/new-custom-folder | |
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=(alias-tips brew brew-cask common-alias dash docker git gradle httpie jira k osx sudo sublime yarn zsh-autosuggestions z) | |
# User configuration | |
DEFAULT_USER="benedikt.kusemann" | |
export PATH="/usr/local/opt/gnu-getopt/bin:/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:.$PATH" | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANG=en_US.UTF-8 | |
# Set Language to show ä,ö,ü correctly | |
export LANG=de_DE.UTF-8 | |
# Preferred editor for local and remote sessions | |
if [[ -n $SSH_CONNECTION ]]; then | |
export EDITOR='vim' | |
else | |
export EDITOR='code' | |
fi | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# gpg | |
GPG_TTY=$(tty) | |
export GPG_TTY | |
# ssh | |
export SSH_KEY_PATH="$HOME/.ssh/dsa_id" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# ZSH Aliases | |
alias refresh="source ~/.zshrc" | |
alias zshconfig="$EDITOR ~/.zshrc" | |
alias ohmyzsh="$EDITOR ~/.oh-my-zsh" | |
alias clear-history="rm -f $HISTFILE" | |
eval $(thefuck --alias) | |
# Terminal Aliases | |
alias cat="bat" | |
alias cls="clear" | |
alias ls='ls -GFh' | |
alias preview="fzf --preview 'bat --color \"always\" {}'" | |
alias top="sudo htop" # alias top and fix high sierra bug | |
# Directory Movement Aliases | |
alias .='cd ..' | |
alias ..='cd ../..' | |
alias ...='cd ../../..' | |
alias d='dirs -v | head -10' | |
alias 1='cd -' | |
alias 2='cd -2' | |
alias 3='cd -3' | |
alias 4='cd -4' | |
alias 5='cd -5' | |
alias 6='cd -6' | |
alias 7='cd -7' | |
alias 8='cd -8' | |
alias 9='cd -9' | |
# Weather | |
alias weather="curl -s wttr.in | sed -n '1,7p'" #current weather | |
alias weatherl="curl -s wttr.in | sed -n '1,38p'" #long weather.. all data | |
alias weathertd="curl -s wttr.in | sed -n '1,17p'" #weather today | |
alias weathertm="curl -s wttr.in | sed -n '18,27p'" #weather tomorrow | |
# Docker | |
alias docker-clean-unused='docker system prune --all --force --volumes' | |
alias docker-clean-all='docker stop $(docker container ls -a -q) && docker system prune -a -f --volumes' | |
alias docker-clean-containers='docker container stop $(docker container ls -a -q) && docker container rm $(docker container ls -a -q)' | |
# Development Task Aliases | |
alias chrome_debug='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome —remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug' | |
alias finder='open $PWD' | |
# File aliases | |
alias -s {js,md,jsx,ts,tsx}=code | |
# update EVERYTHING | |
function update() { | |
# update brew | |
echo "updating with brew" | |
brew update | |
brew upgrade | |
brew prune | |
brew doctor | |
brew cask doctor | |
brew cask upgrade | |
brew cleanup | |
echo "" | |
# update oh-my-zsh | |
echo "updating oh-my-zsh & spaceship theme" | |
upgrade_oh_my_zsh | |
# npm install -g spaceship-zsh-theme | |
echo "" | |
# echo "updating npm" | |
# npm i -g npm | |
# echo "" | |
# update project dependencies | |
if [ -f package.json ] | |
then | |
echo "updating yarn/packages" | |
yarn upgrade | |
yarn outdated | |
echo "" | |
else | |
echo 'skipping yarn/packages' | |
fi | |
echo "" | |
if [ -d .git ] | |
then | |
echo "fetching git/repo" | |
git fetch -p | |
echo "" | |
else | |
echo 'skipping git fetch' | |
fi | |
#echo "updating rust/cargo" | |
#cargo install-update -a | |
echo "updating sdkman" | |
sdk selfupdate | |
sdk update | |
echo "updating tldr" | |
tldr --update | |
} | |
# Fuzzy git branch search | |
fbr() { | |
local branches branch | |
branches=$(git branch -a) && | |
branch=$(echo "$branches" | fzf +s +m -e) && | |
#git checkout $(echo "$branch" | sed "s/.* //") | |
git checkout $(echo "$branch" | sed "s:.* remotes/origin/::" | sed "s:.* ::") | |
} | |
function gitrebase() { | |
git rebase -i HEAD~$1 | |
} | |
gitclean() { | |
git reflog expire --expire=1.minute refs/heads/master | |
git fsck --unreachable | |
git prune | |
git gc | |
git remote prune origin | |
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d | |
} | |
branchclean() { | |
git branch --merged | grep -v \* | xargs git branch -D | |
} | |
gradleclean () { | |
find ~/.gradle -type f -atime +30 -delete | |
find ~/.gradle -type d -mindepth 1 -empty -delete | |
} | |
# Change directory to the current Finder directory | |
cdf() { | |
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'` | |
if [ "$target" != "" ]; then | |
cd "$target"; pwd | |
else | |
echo 'No Finder window found' >&2 | |
fi | |
} | |
# turn hidden files on/off in Finder | |
function hiddenOn() { defaults write com.apple.Finder AppleShowAllFiles YES ; } | |
function hiddenOff() { defaults write com.apple.Finder AppleShowAllFiles NO ; } | |
#mkdir and cd | |
function mkcd() { mkdir -p "$@" && cd "$_" || exit; } | |
# display a neatly formatted path | |
function path() { | |
echo $PATH | tr ":" "\n" | \ | |
awk "{ \ | |
sub(\"/usr\", \"$fg_no_bold[green]/usr$reset_color\"); \ | |
sub(\"/bin\", \"$fg_no_bold[blue]/bin$reset_color\"); \ | |
sub(\"/opt\", \"$fg_no_bold[cyan]/opt$reset_color\"); \ | |
sub(\"/sbin\", \"$fg_no_bold[magenta]/sbin$reset_color\"); \ | |
sub(\"/local\", \"$fg_no_bold[yellow]/local$reset_color\"); \ | |
print \ | |
}" | |
} | |
# view man pages in Preview | |
function pman() { ps=`mktemp -t manpageXXXX`.ps ; man -t $@ > "$ps" ; open "$ps" ; } | |
# Key Bindings | |
bindkey "^K" kill-whole-line # [Ctrl-K] erase whole line | |
bindkey '^[[1;5C' forward-word # [Alt-RightArrow] - move forward one word | |
bindkey '^[[1;5D' backward-word # [Alt-LeftArrow] - move backward one word | |
bindkey '^?' backward-delete-char # [Backspace] - delete backward | |
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward | |
bindkey '\e[2~' overwrite-mode # [Insert] - toggles overwrite mode | |
bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history | |
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history | |
bindkey "^[[A" history-search-backward # start typing + [Up-Arrow] - fuzzy find history forward | |
bindkey "^[[B" history-search-forward # start typing + [Down-Arrow] - fuzzy find history backward | |
# === fzf === | |
if [[ ! "$PATH" == */usr/local/fzf/bin* ]]; then | |
export PATH="$PATH:/usr/local/fzf/bin" | |
fi | |
# Auto-completion | |
[[ $- == *i* ]] && source "/usr/local/opt/fzf/shell/completion.zsh" 2> /dev/null | |
# Key bindings | |
source "/usr/local/opt/fzf/shell/key-bindings.zsh" | |
# add support for ctrl+o to open selected file in VS Code | |
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" | |
# Setting ag as the default source for fzf | |
export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git --ignore node_modules -g ""' | |
# To apply the command to CTRL-T as well | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
_fzf_compgen_path() { | |
ag -g "" "$1" | |
} | |
source $ZSH/oh-my-zsh.sh | |
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
source "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | |
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! | |
export SDKMAN_DIR="/Users/benedikt.kusemann/.sdkman" | |
[[ -s "/Users/benedikt.kusemann/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/benedikt.kusemann/.sdkman/bin/sdkman-init.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment