mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh
This commit is contained in:
commit
a12658aa47
16 changed files with 205 additions and 27 deletions
|
|
@ -26,9 +26,9 @@ cd () {
|
|||
elif [[ "x$*" == "x...." ]]; then
|
||||
cd ../../..
|
||||
elif [[ "x$*" == "x....." ]]; then
|
||||
cd ../../..
|
||||
elif [[ "x$*" == "x......" ]]; then
|
||||
cd ../../../..
|
||||
elif [[ "x$*" == "x......" ]]; then
|
||||
cd ../../../../..
|
||||
else
|
||||
builtin cd "$@"
|
||||
fi
|
||||
|
|
|
|||
13
lib/git.zsh
13
lib/git.zsh
|
|
@ -58,7 +58,7 @@ function git_prompt_long_sha() {
|
|||
|
||||
# Get the status of the working tree
|
||||
git_prompt_status() {
|
||||
INDEX=$(git status --porcelain 2> /dev/null)
|
||||
INDEX=$(git status --porcelain -b 2> /dev/null)
|
||||
STATUS=""
|
||||
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
||||
|
|
@ -80,12 +80,23 @@ git_prompt_status() {
|
|||
fi
|
||||
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
|
||||
fi
|
||||
echo $STATUS
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ function title {
|
|||
fi
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
|
||||
elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
|
||||
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
|
||||
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
print -Pn "\e]2;$2:q\a" #set window name
|
||||
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
|
||||
|
|
|
|||
18
plugins/git-remote-branch/git-remote-branch.plugin.zsh
Normal file
18
plugins/git-remote-branch/git-remote-branch.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
_git_remote_branch() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null)
|
||||
if [[ -n $ref ]]; then
|
||||
if (( CURRENT == 2 )); then
|
||||
# first arg: operation
|
||||
compadd create publish rename delete track
|
||||
elif (( CURRENT == 3 )); then
|
||||
# second arg: remote branch name
|
||||
compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
|
||||
elif (( CURRENT == 4 )); then
|
||||
# third arg: remote name
|
||||
compadd `git remote`
|
||||
fi
|
||||
else;
|
||||
_files
|
||||
fi
|
||||
}
|
||||
compdef _git_remote_branch grb
|
||||
|
|
@ -9,6 +9,7 @@ alias gup='git pull --rebase'
|
|||
compdef _git gup=git-fetch
|
||||
alias gp='git push'
|
||||
compdef _git gp=git-push
|
||||
alias gd='git diff'
|
||||
gdv() { git diff -w "$@" | view - }
|
||||
compdef _git gdv=git-diff
|
||||
alias gc='git commit -v'
|
||||
|
|
@ -24,13 +25,14 @@ alias gba='git branch -a'
|
|||
compdef _git gba=git-branch
|
||||
alias gcount='git shortlog -sn'
|
||||
compdef gcount=git
|
||||
alias gcl='git config --list'
|
||||
alias gcp='git cherry-pick'
|
||||
compdef _git gcp=git-cherry-pick
|
||||
alias glg='git log --stat --max-count=5'
|
||||
compdef _git glg=git-log
|
||||
alias glgg='git log --graph --max-count=5'
|
||||
compdef _git glgg=git-log
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
compdef _git glgga=git-log
|
||||
alias gss='git status -s'
|
||||
compdef _git gss=git-status
|
||||
|
|
@ -42,13 +44,12 @@ alias grh='git reset HEAD'
|
|||
alias grhh='git reset HEAD --hard'
|
||||
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gf='git ls-files | grep'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
|
||||
# Will cd into the top of the current repository
|
||||
# or submodule.
|
||||
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
|
||||
|
||||
|
||||
|
||||
# Git and svn mix
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
compdef git-svn-dcommit-push=git
|
||||
|
|
|
|||
8
plugins/history/history.plugin.zsh
Normal file
8
plugins/history/history.plugin.zsh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
alias h='history'
|
||||
|
||||
function hs
|
||||
{
|
||||
history | grep $*
|
||||
}
|
||||
|
||||
alias hsi='hs -i'
|
||||
|
|
@ -1,20 +1,36 @@
|
|||
# To use: add a .jira-url file in the base of your project
|
||||
# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
|
||||
# .jira-url in the current directory takes precedence
|
||||
#
|
||||
# If you use Rapid Board, set:
|
||||
#JIRA_RAPID_BOARD="yes"
|
||||
# in you .zshrc
|
||||
#
|
||||
# Setup: cd to/my/project
|
||||
# echo "https://name.jira.com" >> .jira-url
|
||||
# Usage: jira # opens a new issue
|
||||
# jira ABC-123 # Opens an existing issue
|
||||
open_jira_issue () {
|
||||
if [ ! -f .jira-url ]; then
|
||||
echo "There is no .jira-url file in the current directory..."
|
||||
return 0;
|
||||
if [ -f .jira-url ]; then
|
||||
jira_url=$(cat .jira-url)
|
||||
elif [ -f ~/.jira-url ]; then
|
||||
jira_url=$(cat ~/.jira-url)
|
||||
elif [[ "x$JIRA_URL" != "x" ]]; then
|
||||
jira_url=$JIRA_URL
|
||||
else
|
||||
jira_url=$(cat .jira-url);
|
||||
if [ -z "$1" ]; then
|
||||
echo "Opening new issue";
|
||||
`open $jira_url/secure/CreateIssue!default.jspa`;
|
||||
echo "JIRA url is not specified anywhere."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Opening new issue"
|
||||
`open $jira_url/secure/CreateIssue!default.jspa`
|
||||
else
|
||||
echo "Opening issue #$1"
|
||||
if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
|
||||
`open $jira_url/issues/$1`
|
||||
else
|
||||
echo "Opening issue #$1";
|
||||
`open $jira_url/browse/$1`;
|
||||
`open $jira_url/browse/$1`
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
# Flag indicating if we've previously jumped to last directory.
|
||||
typeset -g ZSH_LAST_WORKING_DIRECTORY
|
||||
mkdir -p "$ZSH/cache"
|
||||
local cache_file="$ZSH/cache/last-working-dir"
|
||||
|
||||
# Updates the last directory once directory is changed.
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
# FILE: osx.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
|
||||
# VERSION: 1.0.1
|
||||
# VERSION: 1.1.0
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function tab() {
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
|
@ -35,7 +34,7 @@ EOF
|
|||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
write text "${command}; clear;"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
|
|
@ -43,6 +42,64 @@ EOF
|
|||
}
|
||||
}
|
||||
|
||||
function vsplit_tab() {
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm" to activate
|
||||
|
||||
tell application "System Events"
|
||||
tell process "iTerm"
|
||||
tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
keystroke "${command}; clear;"
|
||||
keystroke return
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
function split_tab() {
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm" to activate
|
||||
|
||||
tell application "System Events"
|
||||
tell process "iTerm"
|
||||
tell menu item "Split Horizontally With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
keystroke "${command}; clear;"
|
||||
keystroke return
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
function pfd() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ local _sublime_darwin_subl=/Applications/Sublime\ Text\ 2.app/Contents/SharedSup
|
|||
|
||||
if [[ $('uname') == 'Linux' ]]; then
|
||||
if [ -f '/usr/bin/sublime_text' ]; then
|
||||
alias st='/usr/bin/sublime_text&'
|
||||
st_run() { nohup /usr/bin/sublime_text $@ > /dev/null & }
|
||||
else
|
||||
alias st='/usr/bin/sublime-text&'
|
||||
st_run() { nohup /usr/bin/sublime-text $@ > /dev/null & }
|
||||
fi
|
||||
alias st=st_run
|
||||
elif [[ $('uname') == 'Darwin' ]]; then
|
||||
# Check if Sublime is installed in user's home application directory
|
||||
if [[ -a $HOME/${_sublime_darwin_subl} ]]; then
|
||||
|
|
|
|||
13
plugins/symfony/symfony.plugin.zsh
Normal file
13
plugins/symfony/symfony.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# symfony basic command completion
|
||||
|
||||
_symfony_get_command_list () {
|
||||
./symfony | sed "1,/Available tasks/d" | awk 'BEGIN { cat=null; } /^[A-Za-z]+$/ { cat = $1; } /^ :[a-z]+/ { print cat $1; }'
|
||||
}
|
||||
|
||||
_symfony () {
|
||||
if [ -f symfony ]; then
|
||||
compadd `_symfony_get_command_list`
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _symfony symfony
|
||||
|
|
@ -4,6 +4,33 @@
|
|||
# Taken from:
|
||||
# http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/
|
||||
|
||||
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
|
||||
if [[ $(whence $URLTOOLS_METHOD) = "" ]]; then
|
||||
URLTOOLS_METHOD=""
|
||||
fi
|
||||
|
||||
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
|
||||
if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xnode" ) ]]; then
|
||||
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
|
||||
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
|
||||
elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
|
||||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
|
||||
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
|
||||
elif [[ $(whence ruby) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xruby" ) ]]; then
|
||||
alias urlencode='ruby -r cgi -e "puts CGI.escape(ARGV[0])"'
|
||||
alias urldecode='ruby -r cgi -e "puts CGI.unescape(ARGV[0])"'
|
||||
elif [[ $(whence php) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xphp" ) ]]; then
|
||||
alias urlencode='php -r "echo rawurlencode(\$argv[1]); echo \"\n\";"'
|
||||
alias urldecode='php -r "echo rawurldecode(\$argv[1]); echo \"\\n\";"'
|
||||
elif [[ $(whence perl) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xperl" ) ]]; then
|
||||
if perl -MURI::Encode -e 1&> /dev/null; then
|
||||
alias urlencode='perl -MURI::Encode -ep "uri_encode($ARGV[0]);"'
|
||||
alias urldecode='perl -MURI::Encode -ep "uri_decode($ARGV[0]);"'
|
||||
elif perl -MURI::Escape -e 1 &> /dev/null; then
|
||||
alias urlencode='perl -MURI::Escape -ep "uri_escape($ARGV[0]);"'
|
||||
alias urldecode='perl -MURI::Escape -ep "uri_unescape($ARGV[0]);"'
|
||||
else
|
||||
alias urlencode="perl -e '\$new=\$ARGV[0]; \$new =~ s/([^A-Za-z0-9])/sprintf(\"%%%02X\", ord(\$1))/seg; print \"\$new\n\";'"
|
||||
alias urldecode="perl -e '\$new=\$ARGV[0]; \$new =~ s/\%([A-Fa-f0-9]{2})/pack(\"C\", hex(\$1))/seg; print \"\$new\n\";'"
|
||||
fi
|
||||
fi
|
||||
|
||||
unset URLTOOLS_METHOD
|
||||
|
|
@ -1,8 +1,26 @@
|
|||
function zle-line-init zle-keymap-select {
|
||||
# Ensures that $terminfo values are valid and updates editor information when
|
||||
# the keymap changes.
|
||||
function zle-keymap-select zle-line-init zle-line-finish {
|
||||
# The terminal must be in application mode when ZLE is active for $terminfo
|
||||
# values to be valid.
|
||||
if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then
|
||||
case "$0" in
|
||||
(zle-line-init)
|
||||
# Enable terminal application mode.
|
||||
echoti smkx
|
||||
;;
|
||||
(zle-line-finish)
|
||||
# Disable terminal application mode.
|
||||
echoti rmkx
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
||||
zle -N zle-keymap-select
|
||||
|
||||
bindkey -v
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
wrapsource=`which virtualenvwrapper.sh`
|
||||
wrapsource=`which virtualenvwrapper_lazy.sh`
|
||||
|
||||
if [[ -f "$wrapsource" ]]; then
|
||||
source $wrapsource
|
||||
|
|
@ -36,5 +36,5 @@ if [[ -f "$wrapsource" ]]; then
|
|||
}
|
||||
fi
|
||||
else
|
||||
print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh. Please install with \`pip install virtualenvwrapper\`."
|
||||
print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with \`pip install virtualenvwrapper\`."
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
PROMPT='%{$fg_bold[cyan]%}☁ %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
if [[ -z $ZSH_THEME_CLOUD_PREFIX ]]; then
|
||||
ZSH_THEME_CLOUD_PREFIX='☁'
|
||||
fi
|
||||
|
||||
PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ function ssh_connection() {
|
|||
fi
|
||||
}
|
||||
|
||||
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n%# '
|
||||
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
|
||||
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
|
||||
|
||||
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue