Skip to content

Instantly share code, notes, and snippets.

@kelabang
Created February 18, 2021 17:04
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 kelabang/dddf7b62d76755942576dbe5f8fa1fa0 to your computer and use it in GitHub Desktop.
Save kelabang/dddf7b62d76755942576dbe5f8fa1fa0 to your computer and use it in GitHub Desktop.
zprezto
#
# Executes commands at login post-zshrc.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Execute code that does not affect the current session in the background.
{
# Compile the completion dump to increase startup speed.
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
zcompile "$zcompdump"
fi
} &!
# Print a random, hopefully interesting, adage.
if (( $+commands[fortune] )); then
fortune -a
print
fi
#
# Executes commands at logout.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Set the Zsh modules to load (man zshmodules).
# zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
# zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
'environment' \
'terminal' \
'history' \
'history-substring-search' \
'directory' \
'spectrum' \
'utility' \
'completion' \
'syntax-highlighting' \
'pacman' \
'git' \
'prompt'
#
# Editor
#
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'emacs'
# Auto convert .... to ../..
zstyle ':prezto:module:editor' dot-expansion 'yes'
#
# Git
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
# zstyle ':prezto:module:git:status:ignore' submodules 'all'
#
# GNU Utility
#
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
#
# History Substring Search
#
# Set the query found color.
# zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
# zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
# zstyle ':prezto:module:history-substring-search' globbing-flags ''
#
# Pacman
#
# Set the Pacman frontend.
zstyle ':prezto:module:pacman' frontend 'yaourt'
#
# Prompt
#
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'powermike'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
#
# Screen
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'
#
# SSH
#
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
#
# Syntax Highlighting
#
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
zstyle ':prezto:module:syntax-highlighting' highlighters \
'main' \
'brackets' \
'pattern' \
'cursor' \
'root'
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
#
# Terminal
#
# Auto set the tab and window titles.
zstyle ':prezto:module:terminal' auto-title 'yes'
# Set the window title format.
zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'
# Set the tab title format.
zstyle ':prezto:module:terminal:tab-title' format '%m: %s'
#
# Tmux
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
#
# Executes commands at login pre-zshrc.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# Browser
#
if [[ "$OSTYPE" == darwin* ]]; then
export BROWSER='open'
fi
#
# Editors
#
export PAGER='less'
if [[ -n "$DISPLAY" ]]; then
export EDITOR='subl'
export BROWSER='chromium'
else
export EDITOR='nano'
export BROWSER='elinks'
fi
#
# Language
#
if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8'
fi
#
# Paths
#
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
# Set the the list of directories that cd searches.
# cdpath=(
# $cdpath
# )
# Set the list of directories that Zsh searches for programs.
path=(
/usr/local/{bin,sbin}
$path
)
#
# Less
#
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS=' -g -i -M -R -S -w -z-4'
# Set the Less input preprocessor.
if (( $+commands[lesspipe.sh] )); then
export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-'
fi
#
# Temporary Files
#
if [[ ! -d "$TMPDIR" ]]; then
export TMPDIR="/tmp/$USER"
mkdir -p -m 700 "$TMPDIR"
fi
TMPPREFIX="${TMPDIR%/}/zsh"
if [[ ! -d "$TMPPREFIX" ]]; then
mkdir -p "$TMPPREFIX"
fi
# local scripts
if [ -d "$HOME/.scripts" ]; then
PATH="$HOME/.scripts:$PATH"
fi
# Take off!
[[ $(fgconsole 2>/dev/null) == 1 ]] && exec startx -- vt1 &> /dev/null
#
# Defines environment variables.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Ensure that a non-login, non-interactive shell has a defined environment.
if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
source "${ZDOTDIR:-$HOME}/.zprofile"
fi
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Customize to your needs...
#
# Powermike zsh theme. By mike.
#
# Symbols
# arrow="❱"
# backarrow="❰"
# success="✔"
# fail="✘"
# branch="⌥"
function prompt_powermike_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
}
function prompt_powermike_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
user=$(id -u -n)
_close=$'%f%b'
if [[ $user == "root" ]]; then
_start=$'%F{red}'
_dir=$'%F{white}%~'
elif [[ $user == "mike" ]]; then
_start=$'%F{cyan}'
_dir=$'%F{white}%c'
else
_start=$'%F{magenta}'
_dir=$'%F{white}%~'
fi
if [[ -n $SSH_CLIENT ]]; then
_start=$'%F{yellow}'
_user=$'%n@%m ❱ '
else
_user=$'%n ❱ '
fi
PROMPT=${_start}"❱ "${_user}${_dir}" ❱ "${_close}
# Git on the right
___get_git() {
if [ -d .git ] ; then
if [[ -z $(git status --short) ]]; then
git="%F{green}"
else
git="%F{yellow}"
fi
git=$git'⌥ '$(git branch | sed -n "/\* /s///p")
echo $git
fi
}
_rgit=$' $(___get_git)'
_rexitcode=$' %(?.%F{green}✔.%F{red}✘ %?)'
RPROMPT=${_rgit}${_rexitcode}${_close}
}
prompt_powermike_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment