mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-13 03:12:21 +01:00
Merge updates from upstream
This commit is contained in:
commit
f9e68451cf
15 changed files with 80 additions and 46 deletions
|
|
@ -78,7 +78,7 @@ function git_prompt_long_sha() {
|
||||||
git_prompt_status() {
|
git_prompt_status() {
|
||||||
INDEX=$(command git status --porcelain -b 2> /dev/null)
|
INDEX=$(command git status --porcelain -b 2> /dev/null)
|
||||||
STATUS=""
|
STATUS=""
|
||||||
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
|
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
|
||||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
||||||
fi
|
fi
|
||||||
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
||||||
|
|
|
||||||
40
lib/grep.zsh
40
lib/grep.zsh
|
|
@ -1,24 +1,24 @@
|
||||||
#
|
# is x grep argument available?
|
||||||
# Color grep results
|
|
||||||
# Examples: http://rubyurl.com/ZXv
|
|
||||||
#
|
|
||||||
|
|
||||||
GREP_OPTIONS="--color=auto"
|
|
||||||
|
|
||||||
# avoid VCS folders (if the necessary grep flags are available)
|
|
||||||
grep-flag-available() {
|
grep-flag-available() {
|
||||||
echo | grep $1 "" >/dev/null 2>&1
|
echo | grep $1 "" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
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"
|
# color grep results
|
||||||
export GREP_COLOR='1;32'
|
GREP_OPTIONS="--color=auto"
|
||||||
|
|
||||||
|
# ignore VCS folders (if the necessary grep flags are available)
|
||||||
|
VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
|
||||||
|
|
||||||
|
if grep-flag-available --exclude-dir=.cvs; then
|
||||||
|
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
|
||||||
|
elif grep-flag-available --exclude=.cvs; then
|
||||||
|
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# export grep settings
|
||||||
|
alias grep="grep $GREP_OPTIONS"
|
||||||
|
|
||||||
|
# clean up
|
||||||
|
unset GREP_OPTIONS
|
||||||
|
unset VCS_FOLDERS
|
||||||
|
unfunction grep-flag-available
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
## Command history configuration
|
## Command history configuration
|
||||||
if [ -z $HISTFILE ]; then
|
if [ -z "$HISTFILE" ]; then
|
||||||
HISTFILE=$HOME/.zsh_history
|
HISTFILE=$HOME/.zsh_history
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HISTSIZE=10000
|
HISTSIZE=10000
|
||||||
SAVEHIST=10000
|
SAVEHIST=10000
|
||||||
|
|
||||||
|
|
|
||||||
14
oh-my-zsh.sh
14
oh-my-zsh.sh
|
|
@ -8,18 +8,20 @@ fi
|
||||||
# add a function path
|
# add a function path
|
||||||
fpath=($ZSH/functions $ZSH/completions $fpath)
|
fpath=($ZSH/functions $ZSH/completions $fpath)
|
||||||
|
|
||||||
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
|
||||||
# TIP: Add files you don't want in git to .gitignore
|
|
||||||
for config_file ($ZSH/lib/*.zsh); do
|
|
||||||
source $config_file
|
|
||||||
done
|
|
||||||
|
|
||||||
# Set ZSH_CUSTOM to the path where your custom config files
|
# Set ZSH_CUSTOM to the path where your custom config files
|
||||||
# and plugins exists, or else we will use the default custom/
|
# and plugins exists, or else we will use the default custom/
|
||||||
if [[ -z "$ZSH_CUSTOM" ]]; then
|
if [[ -z "$ZSH_CUSTOM" ]]; then
|
||||||
ZSH_CUSTOM="$ZSH/custom"
|
ZSH_CUSTOM="$ZSH/custom"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
||||||
|
# TIP: Add files you don't want in git to .gitignore
|
||||||
|
for config_file ($ZSH/lib/*.zsh); do
|
||||||
|
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
|
||||||
|
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
|
||||||
|
source $config_file
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
is_plugin() {
|
is_plugin() {
|
||||||
local base_dir=$1
|
local base_dir=$1
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@
|
||||||
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
|
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
|
||||||
zle -N insert-cycledleft
|
zle -N insert-cycledleft
|
||||||
bindkey "\e[1;6D" insert-cycledleft
|
bindkey "\e[1;6D" insert-cycledleft
|
||||||
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }"
|
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
|
||||||
zle -N insert-cycledright
|
zle -N insert-cycledright
|
||||||
bindkey "\e[1;6C" insert-cycledright
|
bindkey "\e[1;6C" insert-cycledright
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SU
|
||||||
|
|
||||||
function hg_dirty_choose {
|
function hg_dirty_choose {
|
||||||
if [ $(in_hg) ]; then
|
if [ $(in_hg) ]; then
|
||||||
hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'
|
hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
|
||||||
if [ $pipestatus[-1] -eq 0 ]; then
|
if [ $pipestatus[-1] -eq 0 ]; then
|
||||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||||
echo $1
|
echo $1
|
||||||
|
|
|
||||||
|
|
@ -177,12 +177,43 @@ function itunes() {
|
||||||
vol)
|
vol)
|
||||||
opt="set sound volume to $1" #$1 Due to the shift
|
opt="set sound volume to $1" #$1 Due to the shift
|
||||||
;;
|
;;
|
||||||
|
shuf|shuff|shuffle)
|
||||||
|
# The shuffle property of current playlist can't be changed in iTunes 12,
|
||||||
|
# so this workaround uses AppleScript to simulate user input instead.
|
||||||
|
# Defaults to toggling when no options are given.
|
||||||
|
# The toggle option depends on the shuffle button being visible in the Now playing area.
|
||||||
|
# On and off use the menu bar items.
|
||||||
|
local state=$1
|
||||||
|
|
||||||
|
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
|
||||||
|
then
|
||||||
|
print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
on|off)
|
||||||
|
# Inspired by: http://stackoverflow.com/a/14675583
|
||||||
|
osascript 1>/dev/null 2>&1 <<-EOF
|
||||||
|
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
|
||||||
|
EOF
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
toggle|*)
|
||||||
|
osascript 1>/dev/null 2>&1 <<-EOF
|
||||||
|
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
|
||||||
|
EOF
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
""|-h|--help)
|
""|-h|--help)
|
||||||
echo "Usage: itunes <option>"
|
echo "Usage: itunes <option>"
|
||||||
echo "option:"
|
echo "option:"
|
||||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||||
echo "\tmute|unmute\tcontrol volume set"
|
echo "\tmute|unmute\tcontrol volume set"
|
||||||
echo "\tnext|previous\tplay next or previous track"
|
echo "\tnext|previous\tplay next or previous track"
|
||||||
|
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||||
echo "\tvol\tSet the volume, takes an argument from 0 to 100"
|
echo "\tvol\tSet the volume, takes an argument from 0 to 100"
|
||||||
echo "\thelp\tshow this message and exit"
|
echo "\thelp\tshow this message and exit"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
_phing_does_target_list_need_generating () {
|
_phing_does_target_list_need_generating () {
|
||||||
[ ! -f .phing_targets ] && return 0;
|
[ ! -f .phing_targets ] && return 0;
|
||||||
[ .phing_targets -nt build.xml ] && return 0;
|
[ build.xml -nt .phing_targets ] && return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_phing () {
|
_phing () {
|
||||||
if [ -f build.xml ]; then
|
if [ -f build.xml ]; then
|
||||||
if _phing_does_target_list_need_generating; then
|
if _phing_does_target_list_need_generating; then
|
||||||
phing -l |grep -v ":$" |grep -v "^-*$" > .phing_targets
|
phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets
|
||||||
fi
|
fi
|
||||||
compadd `cat .phing_targets`
|
compadd `cat .phing_targets`
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,11 @@ function svn_current_revision() {
|
||||||
function svn_status_info() {
|
function svn_status_info() {
|
||||||
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
|
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
|
||||||
local svn_status="$(svn status 2> /dev/null)";
|
local svn_status="$(svn status 2> /dev/null)";
|
||||||
if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
|
if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
|
||||||
if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi
|
if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi
|
||||||
if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi
|
if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi
|
||||||
if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi
|
if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi
|
||||||
if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
|
if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
|
||||||
if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
|
if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
|
||||||
echo $svn_status_string
|
echo $svn_status_string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ function svn_get_rev_nr() {
|
||||||
function svn_dirty_choose() {
|
function svn_dirty_choose() {
|
||||||
if in_svn; then
|
if in_svn; then
|
||||||
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
|
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
|
||||||
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
|
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
|
||||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||||
echo $1
|
echo $1
|
||||||
else
|
else
|
||||||
|
|
@ -78,7 +78,7 @@ function svn_dirty() {
|
||||||
function svn_dirty_choose_pwd () {
|
function svn_dirty_choose_pwd () {
|
||||||
if in_svn; then
|
if in_svn; then
|
||||||
root=$PWD
|
root=$PWD
|
||||||
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
|
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
|
||||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||||
echo $1
|
echo $1
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ _symfony_console () {
|
||||||
}
|
}
|
||||||
|
|
||||||
_symfony2_get_command_list () {
|
_symfony2_get_command_list () {
|
||||||
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
|
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
_symfony2 () {
|
_symfony2 () {
|
||||||
|
|
|
||||||
|
|
@ -123,10 +123,10 @@ prompt_hg() {
|
||||||
st=""
|
st=""
|
||||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||||
branch=$(hg id -b 2>/dev/null)
|
branch=$(hg id -b 2>/dev/null)
|
||||||
if `hg st | grep -Eq "^\?"`; then
|
if `hg st | grep -q "^\?"`; then
|
||||||
prompt_segment red black
|
prompt_segment red black
|
||||||
st='±'
|
st='±'
|
||||||
elif `hg st | grep -Eq "^(M|A)"`; then
|
elif `hg st | grep -q "^(M|A)"`; then
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
st='±'
|
st='±'
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ bureau_git_status () {
|
||||||
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
|
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
|
||||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||||
fi
|
fi
|
||||||
if $(echo "$_INDEX" | grep -E '^\?\? ' &> /dev/null); then
|
if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
|
||||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||||
fi
|
fi
|
||||||
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then
|
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ function my_git_prompt() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# is anything staged?
|
# is anything staged?
|
||||||
if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
|
if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
|
||||||
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
|
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# is anything unstaged?
|
# is anything unstaged?
|
||||||
if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then
|
if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
|
||||||
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ function my_git_prompt() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# is anything unmerged?
|
# is anything unmerged?
|
||||||
if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
|
if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
|
||||||
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
function hg_prompt_info {
|
function hg_prompt_info {
|
||||||
hg prompt --angle-brackets "\
|
hg prompt --angle-brackets "\
|
||||||
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}>\
|
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}><:%{$fg[magenta]%}<bookmark>%{$reset_color%}>\
|
||||||
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
|
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
|
||||||
%{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}<
|
%{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}<
|
||||||
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
|
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue