Unverified Commit 18ee5dff authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into clipboard

parents d81cd753 368198b7
...@@ -33,6 +33,7 @@ alias zunner='zeus runner' ...@@ -33,6 +33,7 @@ alias zunner='zeus runner'
# Cucumber # Cucumber
alias zcu='zeus cucumber' alias zcu='zeus cucumber'
alias zucumber='zeus cucumber' alias zucumber='zeus cucumber'
alias zwip='zeus cucumber --profile wip'
# Rspec # Rspec
alias zspec='zeus rspec' alias zspec='zeus rspec'
......
# zsh-interactive-cd
This plugin adds a fish-like interactive tab completion for the `cd` command.
To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
```zsh
plugins=(... zsh-interactive-cd)
```
![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
## Usage
Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
## Requirements
This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
its [installation instructions](https://github.com/junegunn/fzf#installation).
## Author
[Henry Chang](https://github.com/changyuheng)
# Copyright (c) 2017 Henry Chang
__zic_fzf_prog() {
[ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
&& echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
}
__zic_matched_subdir_list() {
local dir length seg starts_with_dir
if [[ "$1" == */ ]]; then
dir="$1"
if [[ "$dir" != / ]]; then
dir="${dir: : -1}"
fi
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
| cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
if [[ "${line[1]}" == "." ]]; then
continue
fi
echo "$line"
done
else
dir=$(dirname -- "$1")
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
seg=$(basename -- "$1")
starts_with_dir=$( \
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == "$seg"* ]]; then
echo "$line"
fi
done
)
if [ -n "$starts_with_dir" ]; then
echo "$starts_with_dir"
else
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == *"$seg"* ]]; then
echo "$line"
fi
done
fi
fi
}
_zic_list_generator() {
__zic_matched_subdir_list "${(Q)@[-1]}" | sort
}
_zic_complete() {
setopt localoptions nonomatch
local l matches fzf tokens base
l=$(_zic_list_generator $@)
if [ -z "$l" ]; then
zle ${__zic_default_completion:-expand-or-complete}
return
fi
fzf=$(__zic_fzf_prog)
if [ $(echo $l | wc -l) -eq 1 ]; then
matches=${(q)l}
else
matches=$(echo $l \
| FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
--reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
--bind 'shift-tab:up,tab:down'" ${=fzf} \
| while read -r item; do
echo -n "${(q)item} "
done)
fi
matches=${matches% }
if [ -n "$matches" ]; then
tokens=(${(z)LBUFFER})
base="${(Q)@[-1]}"
if [[ "$base" != */ ]]; then
if [[ "$base" == */* ]]; then
base="$(dirname -- "$base")"
if [[ ${base[-1]} != / ]]; then
base="$base/"
fi
else
base=""
fi
fi
LBUFFER="${tokens[1]} "
if [ -n "$base" ]; then
base="${(q)base}"
if [ "${tokens[2][1]}" = "~" ]; then
base="${base/#$HOME/~}"
fi
LBUFFER="${LBUFFER}${base}"
fi
LBUFFER="${LBUFFER}${matches}/"
fi
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
}
zic-completion() {
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
local tokens cmd
tokens=(${(z)LBUFFER})
cmd=${tokens[1]}
if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
zle ${__zic_default_completion:-expand-or-complete}
elif [ "$cmd" = cd ]; then
_zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
else
zle ${__zic_default_completion:-expand-or-complete}
fi
}
[ -z "$__zic_default_completion" ] && {
binding=$(bindkey '^I')
# $binding[(s: :w)2]
# The command substitution and following word splitting to determine the
# default zle widget for ^I formerly only works if the IFS parameter contains
# a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
# of IFS.
[[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
unset binding
}
zle -N zic-completion
bindkey -M emacs '^I' zic-completion
bindkey -M viins '^I' zic-completion
...@@ -7,7 +7,7 @@ export ZSH=$HOME/.oh-my-zsh ...@@ -7,7 +7,7 @@ export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will # Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case, # load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME # to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell" ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random # Set list of themes to pick from when loading at random
......
...@@ -2,32 +2,41 @@ ...@@ -2,32 +2,41 @@
# Repo: https://github.com/andyfleming/oh-my-zsh # Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme # Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
# primary prompt # settings
PROMPT='$FG[237]------------------------------------------------------------%{$reset_color%} typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
$FG[032]%~\ typeset +H my_gray="$FG[237]"
$(git_prompt_info) \ typeset +H my_orange="$FG[214]"
$FG[105]%(!.#.»)%{$reset_color%} '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='${return_code}'
# separator dashes size
function afmagic_dashes {
[[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \
&& echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \
|| echo $COLUMNS
}
# color vars # primary prompt
eval my_gray='$FG[237]' PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%}
eval my_orange='$FG[214]' $FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
PS2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='${return_code}'
# right prompt # right prompt
if type "virtualenv_prompt_info" > /dev/null (( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
then RPS1+=' $my_gray%n@%m%{$reset_color%}%'
RPROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%'
else
RPROMPT='$my_gray%n@%m%{$reset_color%}%'
fi
# git settings # git settings
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]" ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# hg settings
ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_HG_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# virtualenv settings
ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
...@@ -140,24 +140,30 @@ prompt_git() { ...@@ -140,24 +140,30 @@ prompt_git() {
} }
prompt_bzr() { prompt_bzr() {
(( $+commands[bzr] )) || return (( $+commands[bzr] )) || return
if (bzr status >/dev/null 2>&1); then
status_mod=`bzr status | head -n1 | grep "modified" | wc -m` # Test if bzr repository in directory hierarchy
status_all=`bzr status | head -n1 | wc -m` local dir="$PWD"
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` while [[ ! -d "$dir/.bzr" ]]; do
if [[ $status_mod -gt 0 ]] ; then [[ "$dir" = "/" ]] && return
prompt_segment yellow black dir="${dir:h}"
echo -n "bzr@"$revision "✚ " done
else
if [[ $status_all -gt 0 ]] ; then local bzr_status status_mod status_all revision
prompt_segment yellow black if bzr_status=$(bzr status 2>&1); then
echo -n "bzr@"$revision status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
else status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
prompt_segment green black revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
echo -n "bzr@"$revision if [[ $status_mod -gt 0 ]] ; then
fi prompt_segment yellow black "bzr@$revision ✚"
fi else
if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision"
else
prompt_segment green black "bzr@$revision"
fi
fi fi
fi
} }
prompt_hg() { prompt_hg() {
......
# AVIT ZSH Theme # AVIT ZSH Theme
PROMPT=' # settings
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} '
local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
function _current_dir() { RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
local _max_pwd_length="65"
if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
else
echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
fi
}
function _user_host() { function _user_host() {
local me
if [[ -n $SSH_CONNECTION ]]; then if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m" me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then elif [[ $LOGNAME != $USER ]]; then
...@@ -32,61 +25,41 @@ function _user_host() { ...@@ -32,61 +25,41 @@ function _user_host() {
fi fi
} }
function _vi_status() {
if {echo $fpath | grep -q "plugins/vi-mode"}; then
echo "$(vi_mode_prompt_info)"
fi
}
function _ruby_version() {
if {echo $fpath | grep -q "plugins/rvm"}; then
echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
elif {echo $fpath | grep -q "plugins/rbenv"}; then
echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
fi
}
# Determine the time since last commit. If branch is clean, # Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time. # use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() { function _git_time_since_commit() {
# Only proceed if there is actually a commit. local last_commit now seconds_since_last_commit
local minutes hours days years commit_age
# Only proceed if there is actually a commit.
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
now=$(date +%s) now=$(date +%s)
seconds_since_last_commit=$((now-last_commit)) seconds_since_last_commit=$((now-last_commit))
# Totals # Totals
minutes=$((seconds_since_last_commit / 60)) minutes=$((seconds_since_last_commit / 60))
hours=$((seconds_since_last_commit/3600)) hours=$((minutes / 60))
days=$((hours / 24))
# Sub-hours and sub-minutes years=$((days / 365))
days=$((seconds_since_last_commit / 86400))
sub_hours=$((hours % 24)) if [[ $years -gt 0 ]]; then
sub_minutes=$((minutes % 60)) commit_age="${years}y$((days % 365 ))d"
elif [[ $days -gt 0 ]]; then
if [ $hours -ge 24 ]; then commit_age="${days}d$((hours % 24))h"
commit_age="${days}d" elif [[ $hours -gt 0 ]]; then
elif [ $minutes -gt 60 ]; then commit_age+="${hours}h$(( minutes % 60 ))m"
commit_age="${sub_hours}h${sub_minutes}m"
else else
commit_age="${minutes}m" commit_age="${minutes}m"
fi fi
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
echo "$color$commit_age%{$reset_color%}"
fi fi
} }
if [[ $USER == "root" ]]; then
CARETCOLOR="red"
else
CARETCOLOR="white"
fi
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}" MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
# Git prompt settings
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ " ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
...@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ " ...@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ " ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ " ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
# Ruby prompt settings
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
# Colors vary depending on time lapsed. # Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
......
...@@ -16,7 +16,7 @@ local venv_prompt='$(virtualenv_prompt_info)' ...@@ -16,7 +16,7 @@ local venv_prompt='$(virtualenv_prompt_info)'
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
PROMPT="╭─${venv_prompt}${user_host}${current_dir}${rvm_ruby}${git_branch} PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${git_branch}${venv_prompt}
╰─%B${user_symbol}%b " ╰─%B${user_symbol}%b "
RPROMPT="%B${return_code}%b" RPROMPT="%B${return_code}%b"
......
# neuralsanwich.zsh-theme if ! hg prompt 2>/dev/null; then
function hg_prompt_info { }
if [ "x$OH_MY_ZSH_HG" = "x" ]; then else
OH_MY_ZSH_HG="hg" function hg_prompt_info {
fi hg prompt --angle-brackets "\
function hg_prompt_info {
$OH_MY_ZSH_HG prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\ < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\ < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}< %{$fg[green]%}<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
} }
fi
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
...@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?" ...@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}" RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}'
RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
# Add battery status if the battery plugin is enabled
if (( $+functions[battery_pct_prompt] )); then
RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
fi
# Evan describes this sexy prompt as: "a skinny, topless prompt" # Evan's minimal prompt
PROMPT='%m :: %2~ %B»%b ' PROMPT='%m :: %2~ %B»%b '
\ No newline at end of file
# ZSH Theme - Preview: https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#gallifrey # ZSH Theme - Preview: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#gallifrey
return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
host_color="%(!.%{$fg[red]%}.%{$fg[green]%})" host_color="%(!.%{$fg[red]%}.%{$fg[green]%})"
......
# (( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { }
# Kiwi ZSH Theme
#
PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt) PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt)
└> % %{$reset_color%}' └> % %{$reset_color%}'
......
PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}' PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
ZSH_THEME_HG_PROMPT_PREFIX="λ %{$fg[blue]%}hg %{$fg[red]%}"
ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
...@@ -28,7 +28,8 @@ prompt_setup_pygmalion(){ ...@@ -28,7 +28,8 @@ prompt_setup_pygmalion(){
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
precmd_functions+=(prompt_pygmalion_precmd) autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
} }
prompt_pygmalion_precmd(){ prompt_pygmalion_precmd(){
...@@ -46,5 +47,3 @@ prompt_pygmalion_precmd(){ ...@@ -46,5 +47,3 @@ prompt_pygmalion_precmd(){
} }
prompt_setup_pygmalion prompt_setup_pygmalion
...@@ -12,7 +12,8 @@ prompt_setup_pygmalion(){ ...@@ -12,7 +12,8 @@ prompt_setup_pygmalion(){
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
precmd_functions+=(prompt_pygmalion_precmd) autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
} }
prompt_pygmalion_precmd(){ prompt_pygmalion_precmd(){
...@@ -30,5 +31,3 @@ prompt_pygmalion_precmd(){ ...@@ -30,5 +31,3 @@ prompt_pygmalion_precmd(){
} }
prompt_setup_pygmalion prompt_setup_pygmalion
# Make themes a unique array
typeset -Ua themes
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
# Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
themes=($ZSH_THEME_RANDOM_CANDIDATES)
else
# Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
themes=(
"$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
"$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
"$ZSH"/themes/*.zsh-theme(N:t:r)
)
# Remove blacklisted themes from the list
for theme in ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
themes=("${(@)themes:#$theme}")
done
fi
# Choose a theme out of the pool of candidates
N=${#themes[@]}
(( N = (RANDOM%N) + 1 ))
RANDOM_THEME="${themes[$N]}"
unset N themes theme
# Source theme
if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
else
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
return 1
fi
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
......
# Sunrise theme for oh-my-zsh # Sunrise theme for oh-my-zsh
# Intended to be used with Solarized: http://ethanschoonover.com/solarized # Intended to be used with Solarized: https://ethanschoonover.com/solarized
# Color shortcuts # Color shortcuts
R=$fg_no_bold[red] R=$fg_no_bold[red]
......
#!/bin/sh #!/bin/sh
# #
# This script should be run via curl: # This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or wget: # or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# #
# As an alternative, you can first download the install script and run it afterwards: # As an alternative, you can first download the install script and run it afterwards:
# wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh # wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
# sh install.sh # sh install.sh
# #
# You can tweak the install behavior by setting variables when running the script. For # You can tweak the install behavior by setting variables when running the script. For
...@@ -15,17 +15,19 @@ ...@@ -15,17 +15,19 @@
# #
# Respects the following environment variables: # Respects the following environment variables:
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh) # ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# REPO - name of the GitHub repo to install from (default: robbyrussell/oh-my-zsh) # REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS) # REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
# BRANCH - branch to check out immediately after install (default: master) # BRANCH - branch to check out immediately after install (default: master)
# #
# Other options: # Other options:
# CHSH - 'no' means the installer will not change the default shell (default: yes) # CHSH - 'no' means the installer will not change the default shell (default: yes)
# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) # RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)
# #
# You can also pass some arguments to the install script to set some these options: # You can also pass some arguments to the install script to set some these options:
# --skip-chsh: has the same behavior as setting CHSH to 'no' # --skip-chsh: has the same behavior as setting CHSH to 'no'
# --unattended: sets both CHSH and RUNZSH to 'no' # --unattended: sets both CHSH and RUNZSH to 'no'
# --keep-zshrc: sets KEEP_ZSHRC to 'yes'
# For example: # For example:
# sh install.sh --unattended # sh install.sh --unattended
# #
...@@ -33,13 +35,14 @@ set -e ...@@ -33,13 +35,14 @@ set -e
# Default settings # Default settings
ZSH=${ZSH:-~/.oh-my-zsh} ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-robbyrussell/oh-my-zsh} REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git} REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master} BRANCH=${BRANCH:-master}
# Other options # Other options
CHSH=${CHSH:-yes} CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes} RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no}
command_exists() { command_exists() {
...@@ -90,7 +93,11 @@ setup_ohmyzsh() { ...@@ -90,7 +93,11 @@ setup_ohmyzsh() {
exit 1 exit 1
fi fi
git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { git clone -c core.eol=lf -c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
error "git clone of oh-my-zsh repo failed" error "git clone of oh-my-zsh repo failed"
exit 1 exit 1
} }
...@@ -107,6 +114,11 @@ setup_zshrc() { ...@@ -107,6 +114,11 @@ setup_zshrc() {
# Must use this exact name so uninstall.sh can find it # Must use this exact name so uninstall.sh can find it
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
# Skip this if the user doesn't want to replace an existing .zshrc
if [ $KEEP_ZSHRC = yes ]; then
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
return
fi
if [ -e "$OLD_ZSHRC" ]; then if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then if [ -e "$OLD_OLD_ZSHRC" ]; then
...@@ -125,10 +137,9 @@ setup_zshrc() { ...@@ -125,10 +137,9 @@ setup_zshrc() {
echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
cp "$ZSH/templates/zshrc.zsh-template" ~/.zshrc
sed "/^export ZSH=/ c\\ sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\" export ZSH=\"$ZSH\"
" ~/.zshrc > ~/.zshrc-omztemp " "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc mv -f ~/.zshrc-omztemp ~/.zshrc
echo echo
...@@ -165,29 +176,37 @@ setup_shell() { ...@@ -165,29 +176,37 @@ setup_shell() {
*) echo "Invalid choice. Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;;
esac esac
# Test for the right location of the "shells" file # Check if we're running on Termux
if [ -f /etc/shells ]; then case "$PREFIX" in
shells_file=/etc/shells *com.termux*) termux=true; zsh=zsh ;;
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS *) termux=false ;;
shells_file=/usr/share/defaults/etc/shells esac
else
error "could not find /etc/shells file. Change your default shell manually."
return
fi
# Get the path to the right zsh binary if [ "$termux" != true ]; then
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file # Test for the right location of the "shells" file
# 2. If that fails, get a zsh path from the shells file, then check it actually exists if [ -f /etc/shells ]; then
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then shells_file=/etc/shells
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
error "no zsh binary found or not present in '$shells_file'" shells_file=/usr/share/defaults/etc/shells
error "change your default shell manually." else
error "could not find /etc/shells file. Change your default shell manually."
return return
fi fi
# Get the path to the right zsh binary
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
error "no zsh binary found or not present in '$shells_file'"
error "change your default shell manually."
return
fi
fi
fi fi
# We're going to change the default shell, so back up the current one # We're going to change the default shell, so back up the current one
if [ -n $SHELL ]; then if [ -n "$SHELL" ]; then
echo $SHELL > ~/.shell.pre-oh-my-zsh echo $SHELL > ~/.shell.pre-oh-my-zsh
else else
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
...@@ -216,6 +235,7 @@ main() { ...@@ -216,6 +235,7 @@ main() {
case $1 in case $1 in
--unattended) RUNZSH=no; CHSH=no ;; --unattended) RUNZSH=no; CHSH=no ;;
--skip-chsh) CHSH=no ;; --skip-chsh) CHSH=no ;;
--keep-zshrc) KEEP_ZSHRC=yes ;;
esac esac
shift shift
done done
......
...@@ -25,18 +25,14 @@ if [ -e "$ZSHRC_ORIG" ]; then ...@@ -25,18 +25,14 @@ if [ -e "$ZSHRC_ORIG" ]; then
echo "Your original zsh config was restored." echo "Your original zsh config was restored."
fi fi
if hash chsh >/dev/null 2>&1; then if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
if [ -f ~/.shell.pre-oh-my-zsh ]; then old_shell=$(cat ~/.shell.pre-oh-my-zsh)
old_shell=$(cat ~/.shell.pre-oh-my-zsh)
else
old_shell=/bin/bash
fi
echo "Switching your shell back to '$old_shell':" echo "Switching your shell back to '$old_shell':"
if chsh -s "$old_shell"; then if chsh -s "$old_shell"; then
rm -f ~/.shell.pre-oh-my-zsh rm -f ~/.shell.pre-oh-my-zsh
else else
echo "Could not change default shell. Change it manually by running chsh" echo "Could not change default shell. Change it manually by running chsh"
echo "or editing the /etc/passwd file." echo "or editing the /etc/passwd file."
fi fi
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment