mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge remote-tracking branch 'upstream/master'
Conflicts: tools/install.sh
This commit is contained in:
commit
316c46767e
12 changed files with 253 additions and 170 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
function zsh_stats() {
|
function zsh_stats() {
|
||||||
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstall_oh_my_zsh() {
|
function uninstall_oh_my_zsh() {
|
||||||
|
|
|
||||||
23
lib/grep.zsh
23
lib/grep.zsh
|
|
@ -3,11 +3,22 @@
|
||||||
# Examples: http://rubyurl.com/ZXv
|
# Examples: http://rubyurl.com/ZXv
|
||||||
#
|
#
|
||||||
|
|
||||||
# avoid VCS folders
|
GREP_OPTIONS="--color=auto"
|
||||||
GREP_OPTIONS=
|
|
||||||
for PATTERN in .cvs .git .hg .svn; do
|
# avoid VCS folders (if the necessary grep flags are available)
|
||||||
GREP_OPTIONS+="--exclude-dir=$PATTERN "
|
grep-flag-available() {
|
||||||
done
|
echo | grep $1 "" >/dev/null 2>&1
|
||||||
GREP_OPTIONS+="--color=auto"
|
}
|
||||||
|
if grep-flag-available --exclude-dir=.cvs; then
|
||||||
|
for PATTERN in .cvs .git .hg .svn; do
|
||||||
|
GREP_OPTIONS+=" --exclude-dir=$PATTERN"
|
||||||
|
done
|
||||||
|
elif grep-flag-available --exclude=.cvs; then
|
||||||
|
for PATTERN in .cvs .git .hg .svn; do
|
||||||
|
GREP_OPTIONS+=" --exclude=$PATTERN"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
unfunction grep-flag-available
|
||||||
|
|
||||||
export GREP_OPTIONS="$GREP_OPTIONS"
|
export GREP_OPTIONS="$GREP_OPTIONS"
|
||||||
export GREP_COLOR='1;32'
|
export GREP_COLOR='1;32'
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ __rm() {
|
||||||
|
|
||||||
__rmi() {
|
__rmi() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'(-f,--force=)'{-f,--force=}'[Force]' \
|
'(-f,--force=)'{-f,--force=}'[Force]'
|
||||||
__docker_images
|
__docker_images
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ symbols = {
|
||||||
}
|
}
|
||||||
|
|
||||||
output, error = Popen(
|
output, error = Popen(
|
||||||
['git', 'status'], stdout=PIPE, stderr=PIPE).communicate()
|
['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate()
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
import sys
|
import sys
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,13 @@ function history-substring-search-down() {
|
||||||
zle -N history-substring-search-up
|
zle -N history-substring-search-up
|
||||||
zle -N history-substring-search-down
|
zle -N history-substring-search-down
|
||||||
|
|
||||||
bindkey '\e[A' history-substring-search-up
|
zmodload zsh/terminfo
|
||||||
bindkey '\e[B' history-substring-search-down
|
if [[ -n "$terminfo[kcuu1]" ]]; then
|
||||||
|
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||||
|
fi
|
||||||
|
if [[ -n "$terminfo[kcud1]" ]]; then
|
||||||
|
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||||
|
fi
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# implementation details
|
# implementation details
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ function itunes() {
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
print "Unkonwn option: $opt"
|
print "Unknown option: $opt"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
56
plugins/per-directory-history/README.md
Normal file
56
plugins/per-directory-history/README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
[Per-Directory-History][6]
|
||||||
|
=========================
|
||||||
|
|
||||||
|
Per directory history for zsh, as well as global history, and the
|
||||||
|
ability to toggle between them with ^G.
|
||||||
|
|
||||||
|
This is a implementation of per directory history for zsh, some
|
||||||
|
implementations of which exist in bash[1][],[2][]. It also implements
|
||||||
|
a per-directory-history-toggle-history function to change from using the
|
||||||
|
directory history to using the global history. In both cases the history is
|
||||||
|
always saved to both the global history and the directory history, so the
|
||||||
|
toggle state will not effect the saved histories. Being able to switch
|
||||||
|
between global and directory histories on the fly is a novel feature as far
|
||||||
|
as I am aware.
|
||||||
|
|
||||||
|
This is a standalone repository for the script, however it is also included in
|
||||||
|
[oh-my-zsh][4] as a plugin.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
Usage
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
1. Load this script into your interactive ZSH session:
|
||||||
|
|
||||||
|
% source zsh-per-directory-history.zsh
|
||||||
|
|
||||||
|
2. The default mode if per directory history, interact with your history as normal.
|
||||||
|
|
||||||
|
3. Press ^G (the Control and G keys simultaneously) to toggle between local
|
||||||
|
and global histories.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Configuration
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* HISTORY_BASE a global variable that defines the base directory in which the
|
||||||
|
directory histories are stored
|
||||||
|
* per-directory-history-toggle-history is the function to toggle the history
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
History
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
The idea/inspiration for a per directory history is from [Stewart MacArthur][1]
|
||||||
|
and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
|
||||||
|
implementation is by [Jim Hester][5] in September 2012.
|
||||||
|
|
||||||
|
[1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||||
|
[2]: http://dieter.plaetinck.be/per_directory_bash
|
||||||
|
[3]: http://www.zsh.org/mla/users/1997/msg00226.html
|
||||||
|
[4]: https://github.com/robbyrussell/oh-my-zsh
|
||||||
|
[5]: http://jimhester.com
|
||||||
|
[6]: http://github.com/jimhester/per-directory-history
|
||||||
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
#!/usr/bin/env zsh
|
|
||||||
#
|
|
||||||
# This is a implementation of per directory history for zsh, some
|
|
||||||
# implementations of which exist in bash[1,2]. It also implements
|
|
||||||
# a per-directory-history-toggle-history function to change from using the
|
|
||||||
# directory history to using the global history. In both cases the history is
|
|
||||||
# always saved to both the global history and the directory history, so the
|
|
||||||
# toggle state will not effect the saved histories. Being able to switch
|
|
||||||
# between global and directory histories on the fly is a novel feature as far
|
|
||||||
# as I am aware.
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Configuration
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# HISTORY_BASE a global variable that defines the base directory in which the
|
|
||||||
# directory histories are stored
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# History
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
|
||||||
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
|
||||||
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
|
||||||
#
|
|
||||||
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
|
||||||
# [2]: http://dieter.plaetinck.be/per_directory_bash
|
|
||||||
# [3]: http://www.zsh.org/mla/users/1997/msg00226.html
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# Copyright (c) 2012 Jim Hester
|
|
||||||
#
|
|
||||||
# This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
# In no event will the authors be held liable for any damages arising from the
|
|
||||||
# use of this software.
|
|
||||||
#
|
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
|
||||||
# including commercial applications, and to alter it and redistribute it
|
|
||||||
# freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not claim
|
|
||||||
# that you wrote the original software. If you use this software in a product,
|
|
||||||
# an acknowledgment in the product documentation would be appreciated but is
|
|
||||||
# not required.
|
|
||||||
#
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
# misrepresented as being the original software.
|
|
||||||
#
|
|
||||||
# 3. This notice may not be removed or altered from any source distribution..
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# configuration, the base under which the directory histories are stored
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# toggle global/directory history used for searching - ctrl-G by default
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function per-directory-history-toggle-history() {
|
|
||||||
if [[ $_per_directory_history_is_global == true ]]; then
|
|
||||||
_per-directory-history-set-directory-history
|
|
||||||
print "\nusing local history\n"
|
|
||||||
else
|
|
||||||
_per-directory-history-set-global-history
|
|
||||||
print "\nusing global history\n"
|
|
||||||
fi
|
|
||||||
zle .push-line
|
|
||||||
zle .accept-line
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload per-directory-history-toggle-history
|
|
||||||
zle -N per-directory-history-toggle-history
|
|
||||||
bindkey '^G' per-directory-history-toggle-history
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# implementation details
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
|
||||||
|
|
||||||
function _per-directory-history-change-directory() {
|
|
||||||
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
|
||||||
mkdir -p ${_per_directory_history_directory:h}
|
|
||||||
if [[ $_per_directory_history_is_global == false ]]; then
|
|
||||||
#save to the global history
|
|
||||||
fc -AI $HISTFILE
|
|
||||||
#save history to previous file
|
|
||||||
local prev="$HISTORY_BASE${OLDPWD:A}/history"
|
|
||||||
mkdir -p ${prev:h}
|
|
||||||
fc -AI $prev
|
|
||||||
|
|
||||||
#discard previous directory's history
|
|
||||||
local original_histsize=$HISTSIZE
|
|
||||||
HISTSIZE=0
|
|
||||||
HISTSIZE=$original_histsize
|
|
||||||
|
|
||||||
#read history in new file
|
|
||||||
if [[ -e $_per_directory_history_directory ]]; then
|
|
||||||
fc -R $_per_directory_history_directory
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _per-directory-history-addhistory() {
|
|
||||||
print -sr -- ${1%%$'\n'}
|
|
||||||
fc -p $_per_directory_history_directory
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function _per-directory-history-set-directory-history() {
|
|
||||||
if [[ $_per_directory_history_is_global == true ]]; then
|
|
||||||
fc -AI $HISTFILE
|
|
||||||
local original_histsize=$HISTSIZE
|
|
||||||
HISTSIZE=0
|
|
||||||
HISTSIZE=$original_histsize
|
|
||||||
if [[ -e "$_per_directory_history_directory" ]]; then
|
|
||||||
fc -R "$_per_directory_history_directory"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_per_directory_history_is_global=false
|
|
||||||
}
|
|
||||||
function _per-directory-history-set-global-history() {
|
|
||||||
if [[ $_per_directory_history_is_global == false ]]; then
|
|
||||||
fc -AI $_per_directory_history_directory
|
|
||||||
local original_histsize=$HISTSIZE
|
|
||||||
HISTSIZE=0
|
|
||||||
HISTSIZE=$original_histsize
|
|
||||||
if [[ -e "$HISTFILE" ]]; then
|
|
||||||
fc -R "$HISTFILE"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_per_directory_history_is_global=true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#add functions to the exec list for chpwd and zshaddhistory
|
|
||||||
chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory")
|
|
||||||
zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory")
|
|
||||||
|
|
||||||
#start in directory mode
|
|
||||||
mkdir -p ${_per_directory_history_directory:h}
|
|
||||||
_per_directory_history_is_global=true
|
|
||||||
_per-directory-history-set-directory-history
|
|
||||||
1
plugins/per-directory-history/per-directory-history.plugin.zsh
Symbolic link
1
plugins/per-directory-history/per-directory-history.plugin.zsh
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
per-directory-history.zsh
|
||||||
149
plugins/per-directory-history/per-directory-history.zsh
Normal file
149
plugins/per-directory-history/per-directory-history.zsh
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
#
|
||||||
|
# This is a implementation of per directory history for zsh, some
|
||||||
|
# implementations of which exist in bash[1,2]. It also implements
|
||||||
|
# a per-directory-history-toggle-history function to change from using the
|
||||||
|
# directory history to using the global history. In both cases the history is
|
||||||
|
# always saved to both the global history and the directory history, so the
|
||||||
|
# toggle state will not effect the saved histories. Being able to switch
|
||||||
|
# between global and directory histories on the fly is a novel feature as far
|
||||||
|
# as I am aware.
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Configuration
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# HISTORY_BASE a global variable that defines the base directory in which the
|
||||||
|
# directory histories are stored
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# History
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
||||||
|
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
||||||
|
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
||||||
|
#
|
||||||
|
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||||
|
# [2]: http://dieter.plaetinck.be/per_directory_bash
|
||||||
|
# [3]: http://www.zsh.org/mla/users/1997/msg00226.html
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012 Jim Hester
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
# In no event will the authors be held liable for any damages arising from the
|
||||||
|
# use of this software.
|
||||||
|
#
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
#
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not claim
|
||||||
|
# that you wrote the original software. If you use this software in a product,
|
||||||
|
# an acknowledgment in the product documentation would be appreciated but is
|
||||||
|
# not required.
|
||||||
|
#
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
#
|
||||||
|
# 3. This notice may not be removed or altered from any source distribution..
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# configuration, the base under which the directory histories are stored
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# toggle global/directory history used for searching - ctrl-G by default
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function per-directory-history-toggle-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
|
_per-directory-history-set-directory-history
|
||||||
|
print -n "\nusing local history"
|
||||||
|
else
|
||||||
|
_per-directory-history-set-global-history
|
||||||
|
print -n "\nusing global history"
|
||||||
|
fi
|
||||||
|
zle .push-line
|
||||||
|
zle .accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload per-directory-history-toggle-history
|
||||||
|
zle -N per-directory-history-toggle-history
|
||||||
|
bindkey '^G' per-directory-history-toggle-history
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# implementation details
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
|
||||||
|
function _per-directory-history-change-directory() {
|
||||||
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
|
if [[ $_per_directory_history_is_global == false ]]; then
|
||||||
|
#save to the global history
|
||||||
|
fc -AI $HISTFILE
|
||||||
|
#save history to previous file
|
||||||
|
local prev="$HISTORY_BASE${OLDPWD:A}/history"
|
||||||
|
mkdir -p ${prev:h}
|
||||||
|
fc -AI $prev
|
||||||
|
|
||||||
|
#discard previous directory's history
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
|
||||||
|
#read history in new file
|
||||||
|
if [[ -e $_per_directory_history_directory ]]; then
|
||||||
|
fc -R $_per_directory_history_directory
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _per-directory-history-addhistory() {
|
||||||
|
print -Sr -- ${1%%$'\n'}
|
||||||
|
fc -p $_per_directory_history_directory
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _per-directory-history-set-directory-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
|
fc -AI $HISTFILE
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
if [[ -e "$_per_directory_history_directory" ]]; then
|
||||||
|
fc -R "$_per_directory_history_directory"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_per_directory_history_is_global=false
|
||||||
|
}
|
||||||
|
function _per-directory-history-set-global-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == false ]]; then
|
||||||
|
fc -AI $_per_directory_history_directory
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
if [[ -e "$HISTFILE" ]]; then
|
||||||
|
fc -R "$HISTFILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_per_directory_history_is_global=true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#add functions to the exec list for chpwd and zshaddhistory
|
||||||
|
chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory")
|
||||||
|
zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory")
|
||||||
|
|
||||||
|
#start in directory mode
|
||||||
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
|
_per_directory_history_is_global=true
|
||||||
|
_per-directory-history-set-directory-history
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
zsh_cache=$HOME/.zsh_cache
|
|
||||||
mkdir -p $zsh_cache
|
|
||||||
|
|
||||||
# reload zshrc
|
# reload zshrc
|
||||||
function src()
|
function src()
|
||||||
{
|
{
|
||||||
autoload -U compinit zrecompile
|
autoload -U compinit zrecompile
|
||||||
compinit -d $zsh_cache/zcomp-$HOST
|
compinit -d "$ZSH/cache/zcomp-$HOST"
|
||||||
for f in $HOME/.zshrc $zsh_cache/zcomp-$HOST; do
|
|
||||||
zrecompile -p $f && rm -f $f.zwc.old
|
for f in ~/.zshrc "$ZSH/cache/zcomp-$HOST"; do
|
||||||
|
zrecompile -p $f && command rm -f $f.zwc.old
|
||||||
done
|
done
|
||||||
|
|
||||||
source ~/.zshrc
|
source ~/.zshrc
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,9 @@ prompt_context() {
|
||||||
|
|
||||||
# Git: branch/detached head, dirty status
|
# Git: branch/detached head, dirty status
|
||||||
prompt_git() {
|
prompt_git() {
|
||||||
local ref dirty
|
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
|
||||||
dirty=$(parse_git_dirty)
|
dirty=$(parse_git_dirty)
|
||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
|
||||||
|
|
@ -79,6 +81,14 @@ prompt_git() {
|
||||||
prompt_segment green black
|
prompt_segment green black
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
|
||||||
|
mode=" <B>"
|
||||||
|
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
|
||||||
|
mode=" >M<"
|
||||||
|
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
|
||||||
|
mode=" >R>"
|
||||||
|
fi
|
||||||
|
|
||||||
setopt promptsubst
|
setopt promptsubst
|
||||||
autoload -Uz vcs_info
|
autoload -Uz vcs_info
|
||||||
|
|
||||||
|
|
@ -90,7 +100,7 @@ prompt_git() {
|
||||||
zstyle ':vcs_info:*' formats ' %u%c'
|
zstyle ':vcs_info:*' formats ' %u%c'
|
||||||
zstyle ':vcs_info:*' actionformats ' %u%c'
|
zstyle ':vcs_info:*' actionformats ' %u%c'
|
||||||
vcs_info
|
vcs_info
|
||||||
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }"
|
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ if [ -d "$ZSH" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
|
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
|
||||||
|
hash git >/dev/null 2>&1 && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
|
||||||
echo "git not installed"
|
echo "git not installed"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue