Skip to content

Instantly share code, notes, and snippets.

@secmohammed
Last active May 6, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secmohammed/ab213d620f78b6634c68532b28ce1240 to your computer and use it in GitHub Desktop.
Save secmohammed/ab213d620f78b6634c68532b28ce1240 to your computer and use it in GitHub Desktop.
zsh configuration
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/mohammed/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="zeta"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# 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=13
# 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.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# 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?
# Standard 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=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_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`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
eval "$(thefuck --alias)"
export PATH=$HOME/bin:/usr/local/bin:$PATH
#hugo
export PATH="$PATH:$HOME/usr/local/bin"
export PATH="$PATH:~/.composer/vendor/bin"
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export ANDROID_HOME="$HOME/Library/Android/sdk"
function fix_postgres() {
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
sudo rm -rf /usr/local/bar/.postgres_bak
brew services restart postgresql
}
alias ls="exa --tree --level=1"
alias art="php artisan"
alias serve="art serve"
alias migrate="art migrate"
alias fresh="art migrate:fresh"
alias phpunit="./vendor/bin/phpunit "
alias pf="phpunit --filter "
alias mp3="youtube-dl --extract-audio --audio-format mp3 "
alias mp4="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' "
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
#antigen
source $HOME/antigen.zsh
# Load the oh-my-zsh's library
antigen use oh-my-zsh
antigen bundle <<EOBUNDLES
git
github
node
npm
command-not-found
autojump
oz/safe-paste
zsh-users/zsh-syntax-highlighting
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-history-substring-search
EOBUNDLES
# Tell antigen that you're done
antigen apply
export NVM_DIR="/Users/mohammed/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
function wlop() {
lsof -nP -i4TCP:"$1" | grep LISTEN
}
# Zeta theme for oh-my-zsh
# Tested on Linux, Unix and Windows under ANSI colors.
# Copyright: Skyler Lee, 2015
# Colors: black|red|blue|green|yellow|magenta|cyan|white
local black=$fg[black]
local red=$fg[red]
local blue=$fg[blue]
local green=$fg[green]
local yellow=$fg[yellow]
local magenta=$fg[magenta]
local cyan=$fg[cyan]
local white=$fg[white]
local black_bold=$fg_bold[black]
local red_bold=$fg_bold[red]
local blue_bold=$fg_bold[blue]
local green_bold=$fg_bold[green]
local yellow_bold=$fg_bold[yellow]
local magenta_bold=$fg_bold[magenta]
local cyan_bold=$fg_bold[cyan]
local white_bold=$fg_bold[white]
local highlight_bg=$bg[red]
local zeta='ΞΆ'
local emojis=("πŸ”₯" "πŸ’€" "πŸ‘‘" "🐸" "🐡" "πŸ€‘" "🍻" "πŸš€" "πŸ’‘" "πŸŽ‰" "πŸ”‘" "πŸŒ™" "😍" "πŸ™Œ" "πŸ˜₯" "🎩" "πŸ’ƒ" "πŸ‘Ό" "🧠" "πŸ‘€" "πŸ™ˆ" "🍺" "🍯" "🎈" "🧨" "βš“" "πŸ†" "πŸ™…" "πŸ’β€β™€οΈ" "πŸ‘©β€πŸŽ“" "πŸ§›" "πŸ‡" "πŸ„" "🦝" "πŸ‡" "πŸ‰" "πŸ”" "πŸ§€" "πŸ–" "🌭" "πŸ₯™" "🌏" "πŸ—»" "πŸ•‹" "🌚")
local RAND_EMOJI_N=$(($RANDOM % ${#emojis[@]} + 1))
# Machine name.
function get_box_name {
if [ -f ~/.box-name ]; then
cat ~/.box-name
else
echo $HOST
fi
}
# User name.
function get_usr_name {
local name="%n"
if [[ "$USER" == 'root' ]]; then
name="%{$highlight_bg%}%{$white_bold%}$name%{$reset_color%}"
fi
echo $name
}
# Directory info.
function get_current_dir {
echo "${PWD/#$HOME/~}"
}
# Git info.
ZSH_THEME_GIT_PROMPT_PREFIX="%{$blue_bold%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$green_bold%} βœ” "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$red_bold%} ✘ "
# Git status.
ZSH_THEME_GIT_PROMPT_ADDED="%{$green_bold%}+"
ZSH_THEME_GIT_PROMPT_DELETED="%{$red_bold%}-"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$magenta_bold%}*"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$blue_bold%}>"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$cyan_bold%}="
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$yellow_bold%}?"
# Git sha.
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="[%{$yellow%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}]"
function get_git_prompt {
if [[ -n $(git rev-parse --is-inside-work-tree 2>/dev/null) ]]; then
local git_status="$(git_prompt_status)"
if [[ -n $git_status ]]; then
git_status="[$git_status%{$reset_color%}]"
fi
local git_prompt=" <$(git_prompt_info)$git_status>"
echo $git_prompt
fi
}
function get_time_stamp {
echo "%*"
}
function get_space {
local str=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local len=${#${(S%%)str//$~zero/}}
local size=$(( $COLUMNS - $len - 1 ))
local space=""
while [[ $size -gt 0 ]]; do
space="$space "
let size=$size-1
done
echo $space
}
# Prompt: # USER@MACHINE: DIRECTORY <BRANCH [STATUS]> --- (TIME_STAMP)
# > command
function print_prompt_head {
local left_prompt="\
%{$emojis[$RAND_EMOJI_N]%} \
%{$green_bold%}$(get_usr_name) \
%{$yellow_bold%}$(get_current_dir)%{$reset_color%}\
$(get_git_prompt) "
local right_prompt="%{$blue%}($(get_time_stamp))%{$reset_color%} "
print -rP "$left_prompt$(get_space $left_prompt $right_prompt)$right_prompt"
}
function get_prompt_indicator {
if [[ $? -eq 0 ]]; then
echo "%{$magenta_bold%}$zeta %{$reset_color%}"
else
echo "πŸ’© %{$red_bold%}$zeta %{$reset_color%}"
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd print_prompt_head
setopt prompt_subst
PROMPT='$(get_prompt_indicator)'
RPROMPT='$(git_prompt_short_sha) '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment