mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-12 15:34:50 +08:00
Compare commits
6 Commits
83aa984d1a
...
17428f3c9a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17428f3c9a | ||
|
|
561e7169ac | ||
|
|
3c5bbcf5b9 | ||
|
|
bc67a55fe8 | ||
|
|
9dffb3191d | ||
|
|
05cae34676 |
@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
|
|||||||
zle -N expand-or-complete-with-dots
|
zle -N expand-or-complete-with-dots
|
||||||
bindkey "^I" expand-or-complete-with-dots
|
bindkey "^I" expand-or-complete-with-dots
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# automatically load bash completion functions
|
||||||
|
autoload -Uz bashcompinit && bashcompinit
|
||||||
|
|||||||
@ -17,3 +17,15 @@ plugins=(... jump)
|
|||||||
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
|
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
|
||||||
| `unmark <mark-name>` | Remove the given mark |
|
| `unmark <mark-name>` | Remove the given mark |
|
||||||
| `marks` | List the existing marks and the directories they point to |
|
| `marks` | List the existing marks and the directories they point to |
|
||||||
|
|
||||||
|
## Key bindings
|
||||||
|
|
||||||
|
Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark.
|
||||||
|
For example, with a mark named `mymark` pointing to `/path/to/my/mark`:
|
||||||
|
```zsh
|
||||||
|
$ cp /tmp/file mymark<C-g>
|
||||||
|
```
|
||||||
|
will become:
|
||||||
|
```zsh
|
||||||
|
$ cp /tmp/file /path/to/my/mark
|
||||||
|
```
|
||||||
|
|||||||
@ -9,33 +9,34 @@
|
|||||||
export MARKPATH=$HOME/.marks
|
export MARKPATH=$HOME/.marks
|
||||||
|
|
||||||
jump() {
|
jump() {
|
||||||
cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
|
builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
mark() {
|
mark() {
|
||||||
if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
|
if [[ $# -eq 0 || "$1" = "." ]]; then
|
||||||
MARK=$(basename "$PWD")
|
MARK=${PWD:t}
|
||||||
else
|
else
|
||||||
MARK="$1"
|
MARK="$1"
|
||||||
fi
|
fi
|
||||||
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
|
if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
|
||||||
mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK"
|
command mkdir -p "$MARKPATH"
|
||||||
|
command ln -sfn "$PWD" "$MARKPATH/$MARK"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
unmark() {
|
unmark() {
|
||||||
rm -i "$MARKPATH/$1"
|
LANG= command rm -i "$MARKPATH/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
marks() {
|
marks() {
|
||||||
local max=0
|
local link max=0
|
||||||
for link in $MARKPATH/*(@); do
|
for link in $MARKPATH/{,.}*(@N); do
|
||||||
if [[ ${#link:t} -gt $max ]]; then
|
if [[ ${#link:t} -gt $max ]]; then
|
||||||
max=${#link:t}
|
max=${#link:t}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
local printf_markname_template="$(printf -- "%%%us " "$max")"
|
local printf_markname_template="$(printf -- "%%%us " "$max")"
|
||||||
for link in $MARKPATH/*(@); do
|
for link in $MARKPATH/{,.}*(@N); do
|
||||||
local markname="$fg[cyan]${link:t}$reset_color"
|
local markname="$fg[cyan]${link:t}$reset_color"
|
||||||
local markpath="$fg[blue]$(readlink $link)$reset_color"
|
local markpath="$fg[blue]$(readlink $link)$reset_color"
|
||||||
printf -- "$printf_markname_template" "$markname"
|
printf -- "$printf_markname_template" "$markname"
|
||||||
@ -44,21 +45,15 @@ marks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_completemarks() {
|
_completemarks() {
|
||||||
if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
|
reply=("${MARKPATH}"/{,.}*(@N:t))
|
||||||
reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
|
|
||||||
else
|
|
||||||
if readlink -e "${MARKPATH}"/* &>/dev/null; then
|
|
||||||
reply=($(ls "${MARKPATH}"))
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
compctl -K _completemarks jump
|
compctl -K _completemarks jump
|
||||||
compctl -K _completemarks unmark
|
compctl -K _completemarks unmark
|
||||||
|
|
||||||
_mark_expansion() {
|
_mark_expansion() {
|
||||||
setopt extendedglob
|
setopt localoptions extendedglob
|
||||||
autoload -U modify-current-argument
|
autoload -U modify-current-argument
|
||||||
modify-current-argument '$(readlink "$MARKPATH/$ARG")'
|
modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
|
||||||
}
|
}
|
||||||
zle -N _mark_expansion
|
zle -N _mark_expansion
|
||||||
bindkey "^g" _mark_expansion
|
bindkey "^g" _mark_expansion
|
||||||
|
|||||||
@ -69,8 +69,8 @@ __box_list ()
|
|||||||
|
|
||||||
__vm_list ()
|
__vm_list ()
|
||||||
{
|
{
|
||||||
_wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
|
_wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
|
||||||
_wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
|
_wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null)
|
||||||
}
|
}
|
||||||
|
|
||||||
__vagrant-box ()
|
__vagrant-box ()
|
||||||
|
|||||||
@ -1,16 +1,14 @@
|
|||||||
# 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]%}?"
|
|||||||
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
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
#
|
(( $+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%}'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user