This commit is contained in:
Nha.HV 2015-12-16 16:04:04 +07:00
commit 1e2f02c645
36 changed files with 253 additions and 168 deletions

View File

@ -8,6 +8,7 @@ alias -g ....='../../..'
alias -g .....='../../../..'
alias -g ......='../../../../..'
alias -- -='cd -'
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'

View File

@ -1,5 +1,6 @@
# get the name of the branch we are on
# Outputs current branch info in prompt format
function git_prompt_info() {
local ref
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
@ -7,9 +8,8 @@ function git_prompt_info() {
fi
}
# Checks if working tree is dirty
parse_git_dirty() {
function parse_git_dirty() {
local STATUS=''
local FLAGS
FLAGS=('--porcelain')
@ -29,32 +29,26 @@ parse_git_dirty() {
fi
}
# get the difference between the local and remote branches
git_remote_status() {
# Gets the difference between the local and remote branches
function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed
remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
if [[ -n ${remote} ]]; then
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [ $ahead -eq 0 ] && [ $behind -eq 0 ]
then
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
then
if [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
elif [ $behind -gt 0 ] && [ $ahead -eq 0 ]
then
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
then
elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
fi
if [ $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]
then
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
fi
@ -62,31 +56,47 @@ git_remote_status() {
fi
}
# Outputs the name of the current branch
# Usage example: git pull origin $(git_current_branch)
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
# it's not a symbolic ref, but in a Git repo.
function git_current_branch() {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}
# Gets the number of commits ahead from remote
function git_commits_ahead() {
if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
local COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
}
# Outputs if current branch is ahead of remote
function git_prompt_ahead() {
if [[ -n "$(command git rev-list origin/$(current_branch)..HEAD 2> /dev/null)" ]]; then
if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}
# Outputs if current branch is behind remote
function git_prompt_behind() {
if [[ -n "$(command git rev-list HEAD..origin/$(current_branch) 2> /dev/null)" ]]; then
if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
}
# Outputs if current branch exists on remote or not
function git_prompt_remote() {
if [[ -n "$(command git show-ref origin/$(current_branch) 2> /dev/null)" ]]; then
if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
@ -95,16 +105,17 @@ function git_prompt_remote() {
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
local SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
local SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
# Get the status of the working tree
git_prompt_status() {
function git_prompt_status() {
local INDEX STATUS
INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
@ -150,9 +161,9 @@ git_prompt_status() {
echo $STATUS
}
#compare the provided version of git to the version installed and on path
#prints 1 if input version <= installed version
#prints -1 otherwise
# Compares the provided version of git to the version installed and on path
# Outputs -1, 0, or 1 if the installed version is less than, equal to, or
# greater than the input version, respectively.
function git_compare_version() {
local INPUT_GIT_VERSION=$1;
local INSTALLED_GIT_VERSION
@ -173,7 +184,7 @@ function git_compare_version() {
echo 0
}
#this is unlikely to change so make it all statically assigned
# This is unlikely to change so make it all statically assigned
POST_1_7_2_GIT=$(git_compare_version "1.7.2")
#clean up the namespace slightly by removing the checker function
# Clean up the namespace slightly by removing the checker function
unset -f git_compare_version

View File

@ -27,11 +27,17 @@ if [[ "${terminfo[knp]}" != "" ]]; then
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
fi
# start typing + [Up-Arrow] - fuzzy find history forward
if [[ "${terminfo[kcuu1]}" != "" ]]; then
bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
# start typing + [Down-Arrow] - fuzzy find history backward
if [[ "${terminfo[kcud1]}" != "" ]]; then
bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
fi
if [[ "${terminfo[khome]}" != "" ]]; then

View File

@ -3,7 +3,7 @@
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
typeset -Ag FX FG BG
typeset -AHg FX FG BG
FX=(
reset "%{%}"
@ -25,13 +25,13 @@ ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab o
# Show all 256 colors with color number
function spectrum_ls() {
for code in {000..255}; do
print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f"
print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}
# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
for code in {000..255}; do
print -P -- "$BG[$code]$code: $ZSH_SPECTRUM_TEXT %{$reset_color%}"
print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}

View File

@ -28,6 +28,14 @@ function title {
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" # set window name
print -Pn "\e]1;$1:q\a" # set tab name
else
# Try to use terminfo to set the title
# If the feature is available set title
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
echoti tsl
print -Pn "$1"
echoti fsl
fi
fi
;;
esac

View File

@ -2,7 +2,7 @@
# Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
# Look for yaourt, and add some useful functions if we have it.
if [[ -x `command -v yaourt` ]]; then
if (( $+commands[yaourt] )); then
upgrade () {
yaourt -Syu
}
@ -21,11 +21,11 @@ if [[ -x `command -v yaourt` ]]; then
alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
# Additional yaourt alias examples
if [[ -x `command -v abs` && -x `command -v aur` ]]; then
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
elif [[ -x `command -v abs` ]]; then
elif (( $+commands[abs] )); then
alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
elif [[ -x `command -v aur` ]]; then
elif (( $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
else
alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories
@ -49,11 +49,11 @@ alias pacreps='pacman -Ss' # Search for package(s) in the repositori
alias pacloc='pacman -Qi' # Display information about a given package in the local database
alias paclocs='pacman -Qs' # Search for package(s) in the local database
# Additional pacman alias examples
if [[ -x `command -v abs` && -x `command -v aur` ]]; then
if (( $+commands[abs] && $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
elif [[ -x `command -v abs` ]]; then
elif (( $+commands[abs] )); then
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
elif [[ -x `command -v aur` ]]; then
elif (( $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
else
alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories

33
plugins/branch/README.md Normal file
View File

@ -0,0 +1,33 @@
# Branch
Displays the current Git or Mercurial branch fast.
## Speed test
### Mercurial
```shell
$ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total
```
### Branch plugin
```shell
$ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total
```
## Usage
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
adding `$(branch_prompt_info)` in your prompt like this:
```diff
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
```
## Maintainer
Victor Torres (<vpaivatorres@gmail.com>)

View File

@ -0,0 +1,26 @@
# Branch: displays the current Git or Mercurial branch fast.
# Victor Torres <vpaivatorres@gmail.com>
# Oct 2, 2015
function branch_prompt_info() {
# Defines path as current directory
local current_dir=$PWD
# While current path is not root path
while [[ $current_dir != '/' ]]
do
# Git repository
if [[ -d "${current_dir}/.git" ]]
then
echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
return;
fi
# Mercurial repository
if [[ -d "${current_dir}/.hg" ]]
then
echo '☿' $(<"$current_dir/.hg/branch")
return;
fi
# Defines path as parent directory and keeps looking for :)
current_dir="${current_dir:h}"
done
}

View File

@ -1,18 +1,18 @@
if [ "$OSTYPE[0,7]" = "solaris" ]
if [[ "$OSTYPE" = solaris* ]]
then
if [ ! -x ${HOME}/bin/nroff ]
if [[ ! -x "$HOME/bin/nroff" ]]
then
mkdir -p ${HOME}/bin
cat > ${HOME}/bin/nroff <<EOF
mkdir -p "$HOME/bin"
cat > "$HOME/bin/nroff" <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\${_NROFF_U} "\$@"
exec /usr/bin/nroff -u\$_NROFF_U "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x ${HOME}/bin/nroff
chmod +x "$HOME/bin/nroff"
fi
fi
@ -25,8 +25,8 @@ man() {
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER=/usr/bin/less \
PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \
PATH=${HOME}/bin:${PATH} \
PATH="$HOME/bin:$PATH" \
man "$@"
}

View File

@ -52,7 +52,7 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo
# depends on the SUFFIX :)
if [ ${ZSH_VERSION//\./} -ge 420 ]; then
if is-at-least 4.2.0; then
# open browser on urls
_browser_fts=(htm html de org net com at cx nl se dk dk php)
for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done

View File

@ -7,11 +7,11 @@
# Composer basic command completion
_composer_get_command_list () {
$_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
$_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_composer_get_required_list () {
$_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
$_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
}
_composer () {

View File

@ -6,14 +6,16 @@ Ember CLI (http://www.ember-cli.com/)
### List of Aliases
alias es='ember serve'
alias ea='ember addon'
alias eb='ember build'
alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
alias ei='ember install'
alias et='ember test'
alias eu='ember update'
alias ev='ember version'
Alias | Ember-CLI command
----- | -----------------
**es** | *ember serve*
**ea** | *ember addon*
**eb** | *ember build*
**ed** | *ember destroy*
**eg** | *ember generate*
**eh** | *ember help*
**ein** | *ember init*
**ei** | *ember install*
**et** | *ember test*
**eu** | *ember update*
**ev** | *ember version*

View File

@ -52,7 +52,7 @@ function extract() {
(*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw) unzip "$1" -d $extract_dir ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;;
(*.7z) 7za x "$1" ;;
(*.deb)

View File

@ -4,7 +4,7 @@
#
# Completion script for git-extras (http://github.com/tj/git-extras).
#
# This depends on and reueses some of the internals of the _git completion
# This depends on and reuses some of the internals of the _git completion
# function that ships with zsh itself. It will not work with the _git that ships
# with git.
#

View File

@ -6,7 +6,7 @@
# To achieve git-flow completion nirvana:
#
# 0. Update your zsh's git-completion module to the newest version.
# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD
# From here. https://raw.githubusercontent.com/zsh-users/zsh/master/Completion/Unix/Command/_git
#
# 1. Install this file. Either:
#

View File

@ -6,19 +6,12 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
# Functions
#
# The current branch name
# Usage example: git pull origin $(current_branch)
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
# it's not a symbolic ref, but in a Git repo.
# The name of the current branch
# Back-compatibility wrapper for when this function was defined here in
# the plugin, before being pulled in to core lib/git.zsh as git_current_branch()
# to fix the core -> git plugin dependency.
function current_branch() {
local ref
ref=$($_omz_git_git_cmd symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$($_omz_git_git_cmd rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
git_current_branch
}
# The list of remotes
function current_repository() {
@ -99,7 +92,7 @@ alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
ggf() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}"
}
compdef _git ggf=git-checkout
@ -107,23 +100,23 @@ ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git pull origin "${b:=$1}"
fi
}
compdef _git ggl=git-checkout
alias ggpull='git pull origin $(current_branch)'
alias ggpull='git pull origin $(git_current_branch)'
compdef _git ggpull=git-checkout
ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git push origin "${b:=$1}"
fi
}
compdef _git ggp=git-checkout
alias ggpush='git push origin $(current_branch)'
alias ggpush='git push origin $(git_current_branch)'
compdef _git ggpush=git-checkout
ggpnp() {
if [[ "$#" == 0 ]]; then
@ -133,9 +126,9 @@ ggl "${*}" && ggp "${*}"
fi
}
compdef _git ggpnp=git-checkout
alias ggsup='git branch --set-upstream-to=origin/$(current_branch)'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
ggu() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}"
}
compdef _git ggu=git-checkout

View File

@ -20,7 +20,7 @@
# in the current directory.
#
function $$gulp_completion {
compls="$(grep -Eo "gulp.task\((['\"](([a-zA-Z0-9]|-)*)['\"],)" gulpfile.js 2>/dev/null | grep -Eo "['\"](([a-zA-Z0-9]|-)*)['\"]" | sed s/"['\"]"//g | sort)"
compls=$(gulp --tasks-simple 2>/dev/null)
completions=(${=compls})
compadd -- $completions

View File

@ -13,11 +13,14 @@ fi
# Bind terminal-specific up and down keys
# Bind in both emacs and vi modes so it works in both, and is not
# sensitive to whether this is loaded before or after the vi-mode plugin
if [[ -n "$terminfo[kcuu1]" ]]; then
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey -M emacs "$terminfo[kcuu1]" history-substring-search-up
bindkey -M viins "$terminfo[kcuu1]" history-substring-search-up
fi
if [[ -n "$terminfo[kcud1]" ]]; then
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey -M emacs "$terminfo[kcud1]" history-substring-search-down
bindkey -M viins "$terminfo[kcud1]" history-substring-search-down
fi

View File

@ -76,10 +76,12 @@ cat >> $plugin_basename.plugin.zsh <<EOF
# Bind terminal-specific up and down keys
if [[ -n "\$terminfo[kcuu1]" ]]; then
bindkey "\$terminfo[kcuu1]" history-substring-search-up
bindkey -M emacs "\$terminfo[kcuu1]" history-substring-search-up
bindkey -M viins "\$terminfo[kcuu1]" history-substring-search-up
fi
if [[ -n "\$terminfo[kcud1]" ]]; then
bindkey "\$terminfo[kcud1]" history-substring-search-down
bindkey -M emacs "\$terminfo[kcud1]" history-substring-search-down
bindkey -M viins "\$terminfo[kcud1]" history-substring-search-down
fi
EOF

View File

@ -14,8 +14,7 @@ alias hgo='hg outgoing'
alias hgp='hg push'
alias hgs='hg status'
alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '
# this is the 'git commit --amend' equivalent
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
alias hgca='hg commit --amend'
# list unresolved files (since hg does not list unmerged files in the status command)
alias hgun='hg resolve --list'

View File

@ -61,6 +61,7 @@ alias rr='rake routes'
alias rrg='rake routes | grep'
alias rt='rake test'
alias rmd='rake middleware'
alias rsts='rake stats'
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'

View File

@ -13,6 +13,7 @@ function web_search() {
yandex "https://yandex.ru/yandsearch?text="
github "https://github.com/search?q="
baidu "https://www.baidu.com/s?wd="
ecosia "https://www.ecosia.org/search?q="
)
# check whether the search engine is supported
@ -43,6 +44,7 @@ alias ddg='web_search duckduckgo'
alias yandex='web_search yandex'
alias github='web_search github'
alias baidu='web_search baidu'
alias ecosia='web_search ecosia'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'

View File

@ -105,8 +105,7 @@ colorize output of the tools, via their config files (check out e.g. n-cd.conf,
it uses this).
## Performance
ZNT are fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to
be released).
ZNT are fastest with Zsh before 5.0.6 and starting from 5.2
vim:filetype=conf

View File

@ -116,15 +116,15 @@ _nlist_setup_user_vars() {
fi
}
_nlist_coloring_list_into_col_list() {
_nlist_colorify_disp_list() {
local col=$'\x1b[00;34m' reset=$'\x1b[0m'
[ -n "$NLIST_COLORING_COLOR" ] && col="$NLIST_COLORING_COLOR"
[ -n "$NLIST_COLORING_END_COLOR" ] && reset="$NLIST_COLORING_END_COLOR"
if [ "$NLIST_COLORING_MATCH_MULTIPLE" -eq 1 ]; then
col_list=( "${(@)list//(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
disp_list=( "${(@)disp_list//(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
else
col_list=( "${(@)list/(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
disp_list=( "${(@)disp_list/(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
fi
}
@ -154,7 +154,7 @@ integer inner_width=term_width-3
integer page_height=inner_height
integer page_width=inner_width
typeset -a list col_list disp_list
typeset -a list disp_list
integer last_element=$#
local action
local final_key
@ -224,19 +224,17 @@ zcurses timeout main -1
key=""
keypad=""
list=( "$@" )
last_element="$#list"
# This loop makes script faster on some Zsh's (e.g. 5.0.8)
repeat 1; do
list=( "$@" )
done
integer is_colored=0
if [[ -z "$NLIST_SEARCH_BUFFER" && -n "$NLIST_COLORING_PATTERN" ]]; then
is_colored=1
_nlist_coloring_list_into_col_list
fi
last_element="$#list"
while (( 1 )); do
# Do searching (filtering with string)
if [ -n "$NLIST_SEARCH_BUFFER" ]; then
# Compute new list, col_list ?
# Compute new list?
if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
prev_search_buffer="$NLIST_SEARCH_BUFFER"
prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
@ -245,7 +243,9 @@ while (( 1 )); do
# Take all elements, including duplicates and non-selectables
typeset +U list
repeat 1; do
list=( "$@" )
done
# Remove non-selectable elements
[ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
@ -290,7 +290,7 @@ while (( 1 )); do
disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
fi
# We have display list, lets replace newlines with "\n" when needed (1/3)
# We have display list, lets replace newlines with "\n" when needed (1/2)
[ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
fi
@ -302,7 +302,7 @@ while (( 1 )); do
# There is no search, but there was in previous loop
# OR
# Uniq mode was entered or left out
# -> compute new list (maybe also col_list)
# -> compute new list
if [[ -n "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
prev_search_buffer=""
prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
@ -311,7 +311,9 @@ while (( 1 )); do
# Take all elements, including duplicates and non-selectables
typeset +U list
repeat 1; do
list=( "$@" )
done
# Remove non-selectable elements only when in uniq mode
[ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] &&
@ -322,13 +324,6 @@ while (( 1 )); do
# Remove duplicates when in uniq mode
[ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && typeset -U list
# Apply coloring pattern (when not with search query)
is_colored=0
if [ -n "$NLIST_COLORING_PATTERN" ]; then
is_colored=1
_nlist_coloring_list_into_col_list
fi
last_element="$#list"
# Called after processing list
_nlist_verify_vars
@ -340,23 +335,15 @@ while (( 1 )); do
integer end_idx=$(( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN + page_height - 1 ))
[ "$end_idx" -gt "$last_element" ] && end_idx=last_element
if [ "$is_colored" -eq 0 ]; then
if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
# We have display list, lets replace newlines with "\n" when needed (2/3)
[ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
fi
else
if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
[ -n "$NLIST_COLORING_PATTERN" ] && _nlist_colorify_disp_list
# We have display list, lets replace newlines with "\n" when needed (3/3)
# We have display list, lets replace newlines with "\n" when needed (2/2)
[ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
fi
fi
# Output the list
n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \
@ -380,6 +367,11 @@ while (( 1 )); do
fi
zcurses border main
local top_msg="${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL, $USER"
zcurses move main 0 $(( term_width / 2 - $#top_msg / 2 ))
zcurses string main $top_msg
zcurses refresh main inner
zcurses move main $(( term_height - 1 - 1 )) $(( status_msg_strlen + 2 ))

View File

@ -32,7 +32,11 @@ if [ -t 0 ]; then
return 1
fi
# This loop makes script faster on some Zsh's (e.g. 5.0.8)
repeat 1; do
list=( `"$@"` )
done
# TODO: $? doesn't reach user
[ "$?" -eq 127 ] && return $?
else
@ -42,7 +46,10 @@ else
return 1
fi
# This loop makes script faster on some Zsh's (e.g. 5.0.8)
repeat 1; do
list=( "${(@f)"$(<&0)"}" )
done
if [[ ! -c /dev/tty ]]; then
exec <&2

View File

@ -43,7 +43,8 @@ CURRENT_BG='NONE'
# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
# what font the user is viewing this source code in. Do not replace the
# escape sequence with a single literal character.
SEGMENT_SEPARATOR=$'\ue0b0' # 
# Do not change this! Do not make it '\u2b80'; that is the old, wrong code point.
SEGMENT_SEPARATOR=$'\ue0b0'
}
# Begin a segment

View File

@ -14,9 +14,9 @@ ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local cb=$(current_branch)
local cb=$(git_current_branch)
if [ -n "$cb" ]; then
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}

View File

@ -1,12 +1,12 @@
# ZSH Theme emulating the Fish shell's default prompt.
_fishy_collapsed_wd() {
echo $(pwd | perl -pe "
echo $(pwd | perl -pe '
BEGIN {
binmode STDIN, ':encoding(UTF-8)';
binmode STDOUT, ':encoding(UTF-8)';
}; s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g
")
binmode STDIN, ":encoding(UTF-8)";
binmode STDOUT, ":encoding(UTF-8)";
}; s|^$ENV{HOME}|~|g; s|/([^/.])[^/]*(?=/)|/$1|g; s|/\.([^/])[^/]*(?=/)|/.$1|g
')
}
local user_color='green'; [ $UID -eq 0 ] && user_color='red'

View File

@ -4,7 +4,7 @@ PROMPT='
%{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%}
%{$fg[green]%}➞ %{$reset_color%'
RPROMPT='$(git_prompt_info) $(rvm)'
RPROMPT='$(git_prompt_info) ${rvm}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"

View File

@ -1,3 +1,5 @@
# Depends on the git plugin for work_in_progress()
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
@ -5,9 +7,9 @@ ZSH_THEME_GIT_PROMPT_CLEAN=""
#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local cb=$(current_branch)
local cb=$(git_current_branch)
if [ -n "$cb" ]; then
echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}

View File

@ -9,7 +9,7 @@ function josh_prompt {
(( spare_width = ${COLUMNS} ))
prompt=" "
branch=$(current_branch)
branch=$(git_current_branch)
ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
path_size=${#PWD}
branch_size=${#branch}
@ -31,7 +31,7 @@ function josh_prompt {
prompt=" $prompt"
done
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(current_branch)"
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_current_branch)"
echo $prompt
}

View File

@ -1,5 +1,3 @@
# Needs Git plugin for current_branch method
# Color shortcuts
RED=$fg[red]
YELLOW=$fg[yellow]
@ -40,4 +38,4 @@ ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$WHITE%}]"
PROMPT='
%{$GREEN_BOLD%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$RESET_COLOR%}
%{$BLUE%}>%{$RESET_COLOR%} '
RPROMPT='%{$GREEN_BOLD%}$(current_branch)$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}'
RPROMPT='%{$GREEN_BOLD%}$(git_current_branch)$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}'

View File

@ -5,7 +5,7 @@ function my_git_prompt() {
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
@ -37,7 +37,7 @@ function my_git_prompt() {
}
function my_current_branch() {
echo $(current_branch || echo "(no branch)")
echo $(git_current_branch || echo "(no branch)")
}
function ssh_connection() {

View File

@ -28,7 +28,7 @@ git_dirty() {
}
git_prompt() {
local cb=$(current_branch)
local cb=$(git_current_branch)
if [ -n "$cb" ]; then
local repo_path=$(git_repo_path)
echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"

View File

@ -1,6 +1,5 @@
# Sunrise theme for oh-my-zsh
# Intended to be used with Solarized: http://ethanschoonover.com/solarized
# (Needs Git plugin for current_branch method)
# Color shortcuts
R=$fg_no_bold[red]

View File

@ -20,7 +20,7 @@ else
NORMAL=""
fi
printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh"
printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
cd "$ZSH"
if git pull --rebase --stat origin master
then