mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-13 03:12:21 +01:00
Merge branch 'master' into title-disable-check
Conflicts: lib/termsupport.zsh Picks up the chpwd hook change.
This commit is contained in:
commit
ca02d06e37
8 changed files with 134 additions and 49 deletions
|
|
@ -17,7 +17,7 @@ function title {
|
||||||
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
|
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
|
||||||
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||||
print -Pn "\e]2;$2:q\a" #set window name
|
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)
|
print -Pn "\e]1;$1:q\a" #set icon (=tab) name
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,5 +49,18 @@ function omz_termsupport_preexec {
|
||||||
title '$CMD' '%100>...>$LINE%<<'
|
title '$CMD' '%100>...>$LINE%<<'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Appears each time pwd is changed
|
||||||
|
function omz_termsupport_chpwd {
|
||||||
|
#Notify Terminal.app of current directory using undocumented OSC sequence
|
||||||
|
#found in OS X 10.10's /etc/bashrc
|
||||||
|
if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
|
||||||
|
local PWD_URL="file://$HOSTNAME${PWD// /%20}"
|
||||||
|
printf '\e]7;%s\a' "$PWD_URL"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#Fire it once so the pwd is set properly upon shell startup
|
||||||
|
omz_termsupport_chpwd
|
||||||
|
|
||||||
precmd_functions+=(omz_termsupport_precmd)
|
precmd_functions+=(omz_termsupport_precmd)
|
||||||
preexec_functions+=(omz_termsupport_preexec)
|
preexec_functions+=(omz_termsupport_preexec)
|
||||||
|
chpwd_functions+=(omz_termsupport_chpwd)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ _homebrew-installed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_chruby-from-homebrew-installed() {
|
_chruby-from-homebrew-installed() {
|
||||||
brew --prefix chruby &> /dev/null
|
[ -r $(brew --prefix chruby)] &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
_ruby-build_installed() {
|
_ruby-build_installed() {
|
||||||
|
|
@ -45,11 +45,11 @@ _source_from_omz_settings() {
|
||||||
zstyle -s :omz:plugins:chruby path _chruby_path
|
zstyle -s :omz:plugins:chruby path _chruby_path
|
||||||
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
||||||
|
|
||||||
if _chruby_path && [[ -r _chruby_path ]]; then
|
if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then
|
||||||
source ${_chruby_path}
|
source ${_chruby_path}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _chruby_auto && [[ -r _chruby_auto ]]; then
|
if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then
|
||||||
source ${_chruby_auto}
|
source ${_chruby_auto}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
alias ta='tmux attach -t'
|
alias ta='tmux attach -t'
|
||||||
alias ts='tmux new-session -s'
|
alias ts='tmux new-session -s'
|
||||||
alias tl='tmux list-sessions'
|
alias tl='tmux list-sessions'
|
||||||
|
alias tksv='tmux kill-server'
|
||||||
|
alias tkss='tmux kill-session -t'
|
||||||
|
|
||||||
# Only run if tmux is actually installed
|
# Only run if tmux is actually installed
|
||||||
if which tmux &> /dev/null
|
if which tmux &> /dev/null
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,63 @@
|
||||||
virtualenvwrapper='virtualenvwrapper.sh'
|
virtualenvwrapper='virtualenvwrapper.sh'
|
||||||
if (( $+commands[$virtualenvwrapper] )); then
|
if (( $+commands[$virtualenvwrapper] )); then
|
||||||
|
|
||||||
source ${${virtualenvwrapper}:c}
|
source ${${virtualenvwrapper}:c}
|
||||||
|
|
||||||
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
if [[ "$WORKON_HOME" == "" ]]; then
|
||||||
# Automatically activate Git projects's virtual environments based on the
|
echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work"
|
||||||
# directory name of the project. Virtual environment name can be overridden
|
else
|
||||||
# by placing a .venv file in the project root with a virtualenv name in it
|
|
||||||
function workon_cwd {
|
|
||||||
if [ ! $WORKON_CWD ]; then
|
|
||||||
WORKON_CWD=1
|
|
||||||
# Check if this is a Git repo
|
|
||||||
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
|
|
||||||
if (( $? != 0 )); then
|
|
||||||
PROJECT_ROOT="."
|
|
||||||
fi
|
|
||||||
# Check for virtualenv name override
|
|
||||||
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
|
||||||
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
|
|
||||||
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
|
|
||||||
ENV_NAME="$PROJECT_ROOT/.venv"
|
|
||||||
elif [[ "$PROJECT_ROOT" != "." ]]; then
|
|
||||||
ENV_NAME=`basename "$PROJECT_ROOT"`
|
|
||||||
else
|
|
||||||
ENV_NAME=""
|
|
||||||
fi
|
|
||||||
if [[ "$ENV_NAME" != "" ]]; then
|
|
||||||
# Activate the environment only if it is not already active
|
|
||||||
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
|
||||||
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
|
|
||||||
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
|
|
||||||
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
|
|
||||||
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [ $CD_VIRTUAL_ENV ]; then
|
|
||||||
# We've just left the repo, deactivate the environment
|
|
||||||
# Note: this only happens if the virtualenv was activated automatically
|
|
||||||
deactivate && unset CD_VIRTUAL_ENV
|
|
||||||
fi
|
|
||||||
unset PROJECT_ROOT
|
|
||||||
unset WORKON_CWD
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Append workon_cwd to the chpwd_functions array, so it will be called on cd
|
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
||||||
# http://zsh.sourceforge.net/Doc/Release/Functions.html
|
# Automatically activate Git projects's virtual environments based on the
|
||||||
# TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4
|
# directory name of the project. Virtual environment name can be overridden
|
||||||
if (( ${+chpwd_functions} )); then
|
# by placing a .venv file in the project root with a virtualenv name in it
|
||||||
if (( $chpwd_functions[(I)workon_cwd] == 0 )); then
|
function workon_cwd {
|
||||||
set -A chpwd_functions $chpwd_functions workon_cwd
|
if [ ! $WORKON_CWD ]; then
|
||||||
|
WORKON_CWD=1
|
||||||
|
# Check if this is a Git repo
|
||||||
|
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
PROJECT_ROOT="."
|
||||||
|
fi
|
||||||
|
# Check for virtualenv name override
|
||||||
|
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
||||||
|
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
|
||||||
|
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
|
||||||
|
ENV_NAME="$PROJECT_ROOT/.venv"
|
||||||
|
elif [[ "$PROJECT_ROOT" != "." ]]; then
|
||||||
|
ENV_NAME=`basename "$PROJECT_ROOT"`
|
||||||
|
else
|
||||||
|
ENV_NAME=""
|
||||||
|
fi
|
||||||
|
if [[ "$ENV_NAME" != "" ]]; then
|
||||||
|
# Activate the environment only if it is not already active
|
||||||
|
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
||||||
|
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
|
||||||
|
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||||
|
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
|
||||||
|
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [ $CD_VIRTUAL_ENV ]; then
|
||||||
|
# We've just left the repo, deactivate the environment
|
||||||
|
# Note: this only happens if the virtualenv was activated automatically
|
||||||
|
deactivate && unset CD_VIRTUAL_ENV
|
||||||
|
fi
|
||||||
|
unset PROJECT_ROOT
|
||||||
|
unset WORKON_CWD
|
||||||
fi
|
fi
|
||||||
else
|
}
|
||||||
|
|
||||||
|
# Append workon_cwd to the chpwd_functions array, so it will be called on cd
|
||||||
|
# http://zsh.sourceforge.net/Doc/Release/Functions.html
|
||||||
|
# TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4
|
||||||
|
if (( ${+chpwd_functions} )); then
|
||||||
|
if (( $chpwd_functions[(I)workon_cwd] == 0 )); then
|
||||||
|
set -A chpwd_functions $chpwd_functions workon_cwd
|
||||||
|
fi
|
||||||
|
else
|
||||||
set -A chpwd_functions workon_cwd
|
set -A chpwd_functions workon_cwd
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ function web_search() {
|
||||||
done
|
done
|
||||||
|
|
||||||
url="${url%?}" # remove the last '+'
|
url="${url%?}" # remove the last '+'
|
||||||
nohup $open_cmd "$url"
|
nohup $open_cmd "$url" >/dev/null 2&>1
|
||||||
rm nohup.out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
7
plugins/yii2/README.md
Normal file
7
plugins/yii2/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Yii2 autocomplete plugin
|
||||||
|
|
||||||
|
* Adds autocomplete commands and subcommands for yii.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
Autocomplete works from directory where your `yii` file contains.
|
||||||
29
plugins/yii2/yii2.plugin.zsh
Normal file
29
plugins/yii2/yii2.plugin.zsh
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Yii2 command completion
|
||||||
|
|
||||||
|
_yii2_format_command () {
|
||||||
|
awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
_yii2 () {
|
||||||
|
if [ -f ./yii ]; then
|
||||||
|
_arguments \
|
||||||
|
'1: :->command'\
|
||||||
|
'*: :->params'
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
command)
|
||||||
|
|
||||||
|
local -a commands
|
||||||
|
local -a name
|
||||||
|
|
||||||
|
if [[ $words[2] == *\/ ]]; then
|
||||||
|
name=$words[2]
|
||||||
|
fi
|
||||||
|
|
||||||
|
commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"})
|
||||||
|
compadd -Q -S '' -a -- commands
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _yii2 yii
|
||||||
29
themes/mira.zsh-theme
Normal file
29
themes/mira.zsh-theme
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Based on bira zsh theme with nvm, rvm and jenv support
|
||||||
|
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||||
|
|
||||||
|
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
|
||||||
|
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
|
||||||
|
|
||||||
|
local rvm_ruby=''
|
||||||
|
if which rvm-prompt &> /dev/null; then
|
||||||
|
rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
|
||||||
|
else
|
||||||
|
if which rbenv &> /dev/null; then
|
||||||
|
rvm_ruby='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local nvm_node=''
|
||||||
|
nvm_node='%{$fg[green]%}‹node-$(nvm_prompt_info)›%{$reset_color%}'
|
||||||
|
|
||||||
|
local jenv_java=''
|
||||||
|
jenv_java='%{$fg[blue]%}‹$(jenv_prompt_info)›%{$reset_color%}'
|
||||||
|
|
||||||
|
local git_branch='$(git_prompt_info)%{$reset_color%}'
|
||||||
|
|
||||||
|
PROMPT="╭─${user_host} ${current_dir} ${nvm_node} ${rvm_ruby} ${jenv_java} ${git_branch}
|
||||||
|
╰─%B$%b "
|
||||||
|
RPS1="${return_code}"
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}("
|
||||||
|
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue