Unverified Commit 8c95c523 authored by Kozlov Alexander's avatar Kozlov Alexander Committed by GitHub
Browse files

Merge branch 'master' into master

parents dd30cf10 3d8f2bda
...@@ -22,6 +22,9 @@ OPTIONS ...@@ -22,6 +22,9 @@ OPTIONS
\fB\-c\fR \fB\-c\fR
restrict matches to subdirectories of the current directory restrict matches to subdirectories of the current directory
.TP .TP
\fB\-e\fR
echo the best match, don't cd
.TP
\fB\-h\fR \fB\-h\fR
show a brief help message show a brief help message
.TP .TP
...@@ -90,7 +93,8 @@ Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode. ...@@ -90,7 +93,8 @@ Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line added above.) (These settings should go in .bashrc/.zshrc before the line added above.)
.RE .RE
.RS .RS
Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR. Install the provided man page \fBz.1\fR somewhere in your \f$MANPATH, like
\fB/usr/local/man/man1\fR.
.RE .RE
.SS .SS
Aging: Aging:
......
# Copyright (c) 2009 rupa deadwyler under the WTFPL license # Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
# maintains a jump-list of the directories you actually use # maintains a jump-list of the directories you actually use
# #
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
# * z -r foo # cd to highest ranked dir matching foo # * z -r foo # cd to highest ranked dir matching foo
# * z -t foo # cd to most recently accessed dir matching foo # * z -t foo # cd to most recently accessed dir matching foo
# * z -l foo # list matches instead of cd # * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD # * z -c foo # restrict matches to subdirs of $PWD
[ -d "${_Z_DATA:-$HOME/.z}" ] && { [ -d "${_Z_DATA:-$HOME/.z}" ] && {
...@@ -31,9 +32,21 @@ _z() { ...@@ -31,9 +32,21 @@ _z() {
local datafile="${_Z_DATA:-$HOME/.z}" local datafile="${_Z_DATA:-$HOME/.z}"
# if symlink, dereference
[ -h "$datafile" ] && datafile=$(readlink "$datafile")
# bail if we don't own ~/.z and $_Z_OWNER not set # bail if we don't own ~/.z and $_Z_OWNER not set
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
_z_dirs () {
local line
while read line; do
# only count directories
[ -d "${line%%\|*}" ] && echo "$line"
done < "$datafile"
return 0
}
# add entries # add entries
if [ "$1" = "--add" ]; then if [ "$1" = "--add" ]; then
shift shift
...@@ -49,10 +62,7 @@ _z() { ...@@ -49,10 +62,7 @@ _z() {
# maintain the data file # maintain the data file
local tempfile="$datafile.$RANDOM" local tempfile="$datafile.$RANDOM"
while read line; do _z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
# only count directories
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN { BEGIN {
rank[path] = 1 rank[path] = 1
time[path] = now time[path] = now
...@@ -75,7 +85,7 @@ _z() { ...@@ -75,7 +85,7 @@ _z() {
} else for( x in rank ) print x "|" rank[x] "|" time[x] } else for( x in rank ) print x "|" rank[x] "|" time[x]
} }
' 2>/dev/null >| "$tempfile" ' 2>/dev/null >| "$tempfile"
# do our best to avoid clobbering the datafile in a race condition # do our best to avoid clobbering the datafile in a race condition.
if [ $? -ne 0 -a -f "$datafile" ]; then if [ $? -ne 0 -a -f "$datafile" ]; then
env rm -f "$tempfile" env rm -f "$tempfile"
else else
...@@ -85,17 +95,15 @@ _z() { ...@@ -85,17 +95,15 @@ _z() {
# tab completion # tab completion
elif [ "$1" = "--complete" -a -s "$datafile" ]; then elif [ "$1" = "--complete" -a -s "$datafile" ]; then
while read line; do _z_dirs | awk -v q="$2" -F"|" '
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v q="$2" -F"|" '
BEGIN { BEGIN {
if( q == tolower(q) ) imatch = 1
q = substr(q, 3) q = substr(q, 3)
gsub(" ", ".*", q) if( q == tolower(q) ) imatch = 1
gsub(/ /, ".*", q)
} }
{ {
if( imatch ) { if( imatch ) {
if( tolower($1) ~ tolower(q) ) print $1 if( tolower($1) ~ q ) print $1
} else if( $1 ~ q ) print $1 } else if( $1 ~ q ) print $1
} }
' 2>/dev/null ' 2>/dev/null
...@@ -106,11 +114,12 @@ _z() { ...@@ -106,11 +114,12 @@ _z() {
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;; --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) local fnd="^$PWD $fnd";; c) local fnd="^$PWD $fnd";;
h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;; e) local echo=1;;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) local list=1;; l) local list=1;;
r) local typ="rank";; r) local typ="rank";;
t) local typ="recent";; t) local typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;; esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";; *) local fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done esac; local last=$1; [ "$#" -gt 0 ] && shift; done
...@@ -119,16 +128,14 @@ _z() { ...@@ -119,16 +128,14 @@ _z() {
# if we hit enter on a completion just go there # if we hit enter on a completion just go there
case "$last" in case "$last" in
# completions will always start with / # completions will always start with /
/*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;; /*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
esac esac
# no file yet # no file yet
[ -f "$datafile" ] || return [ -f "$datafile" ] || return
local cd local cd
cd="$(while read line; do cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) { function frecent(rank, time) {
# relate frequency and time # relate frequency and time
dx = t - time dx = t - time
...@@ -137,19 +144,21 @@ _z() { ...@@ -137,19 +144,21 @@ _z() {
if( dx < 604800 ) return rank / 2 if( dx < 604800 ) return rank / 2
return rank / 4 return rank / 4
} }
function output(files, out, common) { function output(matches, best_match, common) {
# list or return the desired directory # list or return the desired directory
if( list ) { if( list ) {
cmd = "sort -n >&2" cmd = "sort -n >&2"
for( x in files ) { for( x in matches ) {
if( files[x] ) printf "%-10s %s\n", files[x], x | cmd if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
} }
if( common ) { if( common ) {
printf "%-10s %s\n", "common:", common > "/dev/stderr" printf "%-10s %s\n", "common:", common > "/dev/stderr"
} }
} else { } else {
if( common ) out = common if( common ) best_match = common
print out print best_match
} }
} }
function common(matches) { function common(matches) {
...@@ -160,11 +169,9 @@ _z() { ...@@ -160,11 +169,9 @@ _z() {
} }
} }
if( short == "/" ) return if( short == "/" ) return
# use a copy to escape special characters, as we want to return for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
# the original. yeah, this escaping is awful. return
clean_short = short }
gsub(/\[\(\)\[\]\|\]/, "\\\\&", clean_short)
for( x in matches ) if( matches[x] && x !~ clean_short ) return
return short return short
} }
BEGIN { BEGIN {
...@@ -197,8 +204,10 @@ _z() { ...@@ -197,8 +204,10 @@ _z() {
} }
} }
')" ')"
[ $? -gt 0 ] && return
[ "$cd" ] && cd "$cd" [ $? -eq 0 ] && [ "$cd" ] && {
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
}
fi fi
} }
...@@ -212,11 +221,11 @@ if type compctl >/dev/null 2>&1; then ...@@ -212,11 +221,11 @@ if type compctl >/dev/null 2>&1; then
# populate directory list, avoid clobbering any other precmds. # populate directory list, avoid clobbering any other precmds.
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() { _z_precmd() {
_z --add "${PWD:a}" (_z --add "${PWD:a}" &)
} }
else else
_z_precmd() { _z_precmd() {
_z --add "${PWD:A}" (_z --add "${PWD:A}" &)
} }
fi fi
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || { [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
...@@ -237,7 +246,7 @@ elif type complete >/dev/null 2>&1; then ...@@ -237,7 +246,7 @@ elif type complete >/dev/null 2>&1; then
[ "$_Z_NO_PROMPT_COMMAND" ] || { [ "$_Z_NO_PROMPT_COMMAND" ] || {
# populate directory list. avoid clobbering other PROMPT_COMMANDs. # populate directory list. avoid clobbering other PROMPT_COMMANDs.
grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || { grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || {
PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;' PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);'
} }
} }
fi fi
...@@ -2,33 +2,97 @@ ...@@ -2,33 +2,97 @@
#autoload #autoload
# in order to make this work, you will need to have the gem zeus installed # in order to make this work, you will need to have the gem zeus installed
# zeus zsh completion
# zeus zsh completion, based on adb completion
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( if [[ -e .zeus.sock ]]; then
'console:Lets you interact with your Rails application from the command line. (alias = c)' _1st_arguments=(
'cucumber:Runs cucumber.' 'console:Lets you interact with your Rails application from the command line. (alias = c)'
'dbconsole:Figures out which database you are using and drops you into whichever command line interface.' 'cucumber:Runs cucumber.'
'destroy:Figures out what generate did, and undoes it. (alias = d)' 'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
'generate:Uses templates to create a whole lot of things. (alias = g)' 'destroy:Figures out what generate did, and undoes it. (alias = d)'
'rake:Execute rake tasks.' 'generate:Uses templates to create a whole lot of things. (alias = g)'
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)' 'rake:Execute rake tasks.'
'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)' 'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
'start:Preloads the zeus environment' 'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
'test:Runs RSpec tests. (alias = rspec, testrb)' 'test:Runs RSpec tests. (alias = rspec, testrb)'
'version:Shows the version number.' 'version:Shows the version number.'
) )
else
_1st_arguments=(
'start:Preloads the zeus environment'
'init:Generate a zeus.json file'
)
fi
_rails_generate_arguments() {
generate_arguments=(
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration
stylesheets
)
}
_rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then return 0;
else
accurate=$(stat -f%m .rake_tasks)
changed=$(stat -f%m Rakefile)
return $(expr $accurate '>=' $changed)
fi
}
_zrake ()
{
local expl
declare -a tasks
if [ -f Rakefile ]; then
if _rake_does_task_list_need_generating; then
echo "\nGenerating .rake_tasks..." > /dev/stderr
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
fi
tasks=(`cat .rake_tasks`)
_wanted tasks expl 'rake' compadd $tasks
fi
}
local expl local expl
local -a pkgs installed_pkgs local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \ _arguments -C \
'*:: :->subcmds' && return 0 ':command:->command' \
'*::options:->options'
if (( CURRENT == 1 )); then
_describe -t commands "zeus subcommand" _1st_arguments
return
fi
_files case $state in
(command)
_describe -t commands "zeus subcommand" _1st_arguments
return
;;
(options)
case $line[1] in
(rake)
_zrake
;;
(generate|g|destroy|d)
_rails_generate_arguments
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments
;;
esac
;;
esac
...@@ -27,7 +27,7 @@ GPLv3 License ...@@ -27,7 +27,7 @@ GPLv3 License
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
...@@ -671,7 +671,7 @@ the "copyright" line and a pointer to where the full notice is found. ...@@ -671,7 +671,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
...@@ -690,11 +690,11 @@ might be different; for a GUI interface, you would use an "about box". ...@@ -690,11 +690,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school, You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>. <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>. <https://www.gnu.org/philosophy/why-not-lgpl.html>.
File mode changed from 100755 to 100644
# zsh_reload plugin
The zsh_reload plugin defines a function to reload the zsh session with
just a few keystrokes.
To use it, add `zsh_reload` to the plugins array in your zshrc file:
```zsh
plugins=(... zsh_reload)
```
## Usage
To reload the zsh session, just run `src`:
```zsh
$ vim ~/.zshrc # enabled a plugin
$ src
re-compiling /home/user/.zshrc.zwc: succeeded
re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
# you now have a fresh zsh session. happy hacking!
```
# reload zshrc src() {
function src() local cache="$ZSH_CACHE_DIR"
{ autoload -U compinit zrecompile
local cache=$ZSH_CACHE_DIR compinit -i -d "$cache/zcomp-$HOST"
autoload -U compinit zrecompile
compinit -d "$cache/zcomp-$HOST"
for f in ~/.zshrc "$cache/zcomp-$HOST"; do for f in ~/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old zrecompile -p $f && command rm -f $f.zwc.old
done done
source ~/.zshrc # Use $SHELL if available; remove leading dash if login shell
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
} }
...@@ -4,23 +4,23 @@ ...@@ -4,23 +4,23 @@
# Path to your oh-my-zsh installation. # Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random" # Set name of the theme to load --- if set to "random", it will
# it'll load a random theme each time that oh-my-zsh is loaded. # 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 # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell" ZSH_THEME="robbyrussell"
# Set list of themes to load # Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random # Setting this variable when ZSH_THEME=random will cause zsh to load
# cause zsh load theme from this variable instead of # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# looking in ~/.oh-my-zsh/themes/ # If set to an empty array, this variable will have no effect.
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion. # Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true" # CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case # Uncomment the following line to use hyphen-insensitive completion.
# sensitive completion must be off. _ and - will be interchangeable. # Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true" # HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks. # Uncomment the following line to disable bi-weekly auto-update checks.
...@@ -48,13 +48,17 @@ ZSH_THEME="robbyrussell" ...@@ -48,13 +48,17 @@ ZSH_THEME="robbyrussell"
# Uncomment the following line if you want to change the command execution time # Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output. # stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # 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" # HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom? # Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder # ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # 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/ # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse) # Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup. # Add wisely, as too many plugins slow down shell startup.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# # a) displaying a pseudo-random message from a database of quotations # # a) displaying a pseudo-random message from a database of quotations
# # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29) # # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29)
# # b) displaying randomly command line tips from The command line fu # # b) displaying randomly command line tips from The command line fu
# # (http://www.commandlinefu.com) community: in order to make use of this functionality # # (https://www.commandlinefu.com) community: in order to make use of this functionality
# # you will need Internet connection. # # you will need Internet connection.
# # This theme provides as well information for the current user's context, like; # # This theme provides as well information for the current user's context, like;
# # branch and status for the current version control system (git and svn currently # # branch and status for the current version control system (git and svn currently
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
# # optionally: # # optionally:
# # -Oh-myzsh vcs plug-ins git and svn. # # -Oh-myzsh vcs plug-ins git and svn.
# # -Solarized theme (https://github.com/altercation/solarized/) # # -Solarized theme (https://github.com/altercation/solarized/)
# # -OS X: iTerm 2 (http://www.iterm2.com/) # # -OS X: iTerm 2 (https://iterm2.com/)
# # -font Source code pro (https://github.com/adobe/source-code-pro) # # -font Source code pro (https://github.com/adobe/source-code-pro)
# # # #
# # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info: # # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
# # http://pthree.org/2008/11/23/727/ # # https://pthree.org/2008/11/23/727/
# # enjoy! # # enjoy!
########## COLOR ########### ########## COLOR ###########
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
......
...@@ -13,9 +13,13 @@ ...@@ -13,9 +13,13 @@
# #
# In addition, I recommend the # In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - # using it on Mac OS X, [iTerm 2](https://iterm2.com/) over Terminal.app -
# it has significantly better color fidelity. # it has significantly better color fidelity.
# #
# If using with "light" variant of the Solarized color schema, set
# SOLARIZED_THEME variable to "light". If you don't specify, we'll assume
# you're using the "dark" variant.
#
# # Goals # # Goals
# #
# The aim of this theme is to only show you *relevant* information. Like most # The aim of this theme is to only show you *relevant* information. Like most
...@@ -30,6 +34,11 @@ ...@@ -30,6 +34,11 @@
CURRENT_BG='NONE' CURRENT_BG='NONE'
case ${SOLARIZED_THEME:-dark} in
light) CURRENT_FG='white';;
*) CURRENT_FG='black';;
esac
# Special Powerline characters # Special Powerline characters
() { () {
...@@ -80,28 +89,31 @@ prompt_end() { ...@@ -80,28 +89,31 @@ prompt_end() {
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi fi
} }
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { prompt_git() {
(( $+commands[git] )) || return (( $+commands[git] )) || return
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
return
fi
local PL_BRANCH_CHAR local PL_BRANCH_CHAR
() { () {
local LC_ALL="" LC_CTYPE="en_US.UTF-8" local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH_CHAR=$'\ue0a0' #  PL_BRANCH_CHAR=$'\ue0a0' # 
} }
local ref dirty mode repo_path local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty) dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment yellow black
else else
prompt_segment green black prompt_segment green $CURRENT_FG
fi fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then if [[ -e "${repo_path}/BISECT_LOG" ]]; then
...@@ -151,7 +163,7 @@ prompt_bzr() { ...@@ -151,7 +163,7 @@ prompt_bzr() {
prompt_hg() { prompt_hg() {
(( $+commands[hg] )) || return (( $+commands[hg] )) || return
local rev status local rev st branch
if $(hg id >/dev/null 2>&1); then if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
...@@ -164,7 +176,7 @@ prompt_hg() { ...@@ -164,7 +176,7 @@ prompt_hg() {
st='±' st='±'
else else
# if working copy is clean # if working copy is clean
prompt_segment green black prompt_segment green $CURRENT_FG
fi fi
echo -n $(hg prompt "☿ {rev}@{branch}") $st echo -n $(hg prompt "☿ {rev}@{branch}") $st
else else
...@@ -178,7 +190,7 @@ prompt_hg() { ...@@ -178,7 +190,7 @@ prompt_hg() {
prompt_segment yellow black prompt_segment yellow black
st='±' st='±'
else else
prompt_segment green black prompt_segment green $CURRENT_FG
fi fi
echo -n "☿ $rev@$branch" $st echo -n "☿ $rev@$branch" $st
fi fi
...@@ -187,7 +199,7 @@ prompt_hg() { ...@@ -187,7 +199,7 @@ prompt_hg() {
# Dir: current working directory # Dir: current working directory
prompt_dir() { prompt_dir() {
prompt_segment blue black '%~' prompt_segment blue $CURRENT_FG '%~'
} }
# Virtualenv: current working virtualenv # Virtualenv: current working virtualenv
...@@ -203,8 +215,8 @@ prompt_virtualenv() { ...@@ -203,8 +215,8 @@ prompt_virtualenv() {
# - am I root # - am I root
# - are there background jobs? # - are there background jobs?
prompt_status() { prompt_status() {
local symbols local -a symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
......
...@@ -9,7 +9,7 @@ rbenv_version() { ...@@ -9,7 +9,7 @@ rbenv_version() {
} }
PROMPT=' PROMPT='
%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} %{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
$ ' $ '
# Must use Powerline font, for \uE0A0 to render. # Must use Powerline font, for \uE0A0 to render.
......
...@@ -8,7 +8,7 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="" ...@@ -8,7 +8,7 @@ ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="*" ZSH_THEME_GIT_PROMPT_DIRTY="*"
ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_CLEAN=""
# See http://geoff.greer.fm/lscolors/ # See https://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxbxbxbxbxbxbx" export LSCOLORS="exfxcxdxbxbxbxbxbxbxbx"
export LS_COLORS="di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=31;40:cd=31;40:su=31;40:sg=31;40:tw=31;40:ow=31;40:" export LS_COLORS="di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=31;40:cd=31;40:su=31;40:sg=31;40:tw=31;40:ow=31;40:"
...@@ -50,9 +50,7 @@ function _ruby_version() { ...@@ -50,9 +50,7 @@ function _ruby_version() {
# use a neutral color, otherwise colors will vary according to time. # use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() { function _git_time_since_commit() {
# Only proceed if there is actually a commit. # Only proceed if there is actually a commit.
if git log -1 > /dev/null 2>&1; then if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
# Get the last commit.
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
now=$(date +%s) now=$(date +%s)
seconds_since_last_commit=$((now-last_commit)) seconds_since_last_commit=$((now-last_commit))
...@@ -65,7 +63,7 @@ function _git_time_since_commit() { ...@@ -65,7 +63,7 @@ function _git_time_since_commit() {
sub_hours=$((hours % 24)) sub_hours=$((hours % 24))
sub_minutes=$((minutes % 60)) sub_minutes=$((minutes % 60))
if [ $hours -gt 24 ]; then if [ $hours -ge 24 ]; then
commit_age="${days}d" commit_age="${days}d"
elif [ $minutes -gt 60 ]; then elif [ $minutes -gt 60 ]; then
commit_age="${sub_hours}h${sub_minutes}m" commit_age="${sub_hours}h${sub_minutes}m"
...@@ -104,7 +102,7 @@ ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" ...@@ -104,7 +102,7 @@ ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}" ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
# LS colors, made with http://geoff.greer.fm/lscolors/ # LS colors, made with https://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad" export LSCOLORS="exfxcxdxbxegedabagacad"
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
export GREP_COLOR='1;33' export GREP_COLOR='1;33'
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png # ZSH Theme - Preview: https://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
......
...@@ -17,7 +17,7 @@ function box_name { ...@@ -17,7 +17,7 @@ function box_name {
} }
PROMPT=' PROMPT='
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}$(box_name)%{$reset_color%}:%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) %{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}$(box_name)%{$reset_color%}:%{$fg_bold[green]%}%~%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )$ ' %(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )$ '
ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[magenta]%}branch: " ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[magenta]%}branch: "
......
...@@ -9,6 +9,6 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%} " ...@@ -9,6 +9,6 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✗" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✗"
# LS colors, made with http://geoff.greer.fm/lscolors/ # LS colors, made with https://geoff.greer.fm/lscolors/
export LSCOLORS="Gxfxcxdxbxegedabagacad" export LSCOLORS="Gxfxcxdxbxegedabagacad"
export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
...@@ -6,5 +6,5 @@ PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%}%p %{$fg[gr ...@@ -6,5 +6,5 @@ PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%}%p %{$fg[gr
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}⚡%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}⚡ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]"
\ No newline at end of file
...@@ -9,7 +9,7 @@ function virtualenv_info { ...@@ -9,7 +9,7 @@ function virtualenv_info {
} }
PROMPT=' PROMPT='
%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) %{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)
$(virtualenv_info)$(prompt_char) ' $(virtualenv_info)$(prompt_char) '
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
......
# user, host, full path, and time/date # user, host, full path, and time/date
# on two lines for easier vgrepping # on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 # entry in a nice long thread on the Arch Linux forums: https://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;34m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}%!%{\e[0;34m%}%B]%b%{\e[0m%} PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;34m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}%!%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]%{\e[0m%}%b ' %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]%{\e[0m%}%b '
RPROMPT='[%*]' RPROMPT='[%*]'
......
...@@ -68,6 +68,10 @@ prompt_glyph="%{%(#.${root_prompt}.${user_prompt}) %2G%}" ...@@ -68,6 +68,10 @@ prompt_glyph="%{%(#.${root_prompt}.${user_prompt}) %2G%}"
setopt promptsubst setopt promptsubst
# Workaround for zsh 5.2 release (kudos to @timothybasanov)
autoload +X VCS_INFO_nvcsformats
functions[VCS_INFO_nvcsformats]=${functions[VCS_INFO_nvcsformats]/local -a msgs/}
autoload -U add-zsh-hook autoload -U add-zsh-hook
autoload -Uz vcs_info autoload -Uz vcs_info
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment