1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-02-12 05:49:47 +08:00

Compare commits

..

No commits in common. "7ef3f49f97ff34db3785b1cea444eb4972b1937b" and "31f2025e0fa963788655fe197e0179c47588b175" have entirely different histories.

4 changed files with 30 additions and 45 deletions

View File

@ -1,20 +1,22 @@
## History wrapper
function omz_history {
# parse arguments and remove from $@
local clear list stamp
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp
local clear list
zparseopts -E c=clear l=list
if [[ $# -eq 0 ]]; then
# if no arguments provided, show full history starting from 1
builtin fc $stamp -l 1
builtin fc -l 1
elif [[ -n "$clear" ]]; then
# if -c provided, clobber the history file
echo -n >| "$HISTFILE"
fc -p "$HISTFILE"
echo >&2 History file deleted.
elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
else
# otherwise, run `fc -l` with a custom format
builtin fc $stamp -l "$@"
builtin fc -l "$@"
fi
}

View File

@ -37,7 +37,6 @@ The plugin also supports the following:
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
| `ZSH_TMUX_AUTONAME_SESSION` | Automatically name new sessions based on the basename of `$PWD` (default: `false`) |
| `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) |
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) |

View File

@ -13,8 +13,6 @@ fi
: ${ZSH_TMUX_AUTOCONNECT:=true}
# Automatically close the terminal when tmux exits
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
# Automatically name the new session based on the basename of PWD
: ${ZSH_TMUX_AUTONAME_SESSION:=false}
# Set term to screen or screen-256color based on current terminal support
: ${ZSH_TMUX_DETACHED:=false}
# Set detached mode
@ -104,22 +102,9 @@ function _zsh_tmux_plugin_run() {
local _detached=""
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d"
local session_name
if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then
# Name the session after the basename of the current directory
session_name=${PWD##*/}
# If the current directory is the home directory, name it 'HOME'
[[ "$PWD" == "$HOME" ]] && session_name="HOME"
# If the current directory is the root directory, name it 'ROOT'
[[ "$PWD" == "/" ]] && session_name="ROOT"
else
session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME"
fi
# Try to connect to an existing session.
if [[ -n "$session_name" ]]; then
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t $ZSH_TMUX_DEFAULT_SESSION_NAME
else
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
fi
@ -131,9 +116,8 @@ function _zsh_tmux_plugin_run() {
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
fi
if [[ -n "$session_name" ]]; then
$tmux_cmd new-session -s "$session_name"
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
else
$tmux_cmd new-session
fi

View File

@ -96,7 +96,7 @@ prompt_context() {
# Git: branch/detached head, dirty status
prompt_git() {
(( $+commands[git] )) || return
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
return
fi
local PL_BRANCH_CHAR
@ -106,12 +106,12 @@ prompt_git() {
}
local ref dirty mode repo_path
if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(command git rev-parse --git-dir 2>/dev/null)
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
@ -119,8 +119,8 @@ prompt_git() {
fi
local ahead behind
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
ahead=$(git log --oneline @{upstream}.. 2>/dev/null)
behind=$(git log --oneline ..@{upstream} 2>/dev/null)
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
PL_BRANCH_CHAR=$'\u21c5'
elif [[ -n "$ahead" ]]; then
@ -163,10 +163,10 @@ prompt_bzr() {
done
local bzr_status status_mod status_all revision
if bzr_status=$(command bzr status 2>&1); then
if bzr_status=$(bzr status 2>&1); then
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision ✚"
else
@ -182,13 +182,13 @@ prompt_bzr() {
prompt_hg() {
(( $+commands[hg] )) || return
local rev st branch
if $(command hg id >/dev/null 2>&1); then
if $(command hg prompt >/dev/null 2>&1); then
if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(command hg prompt "{status|modified}") ]]; then
elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_segment yellow black
st='±'
@ -196,15 +196,15 @@ prompt_hg() {
# if working copy is clean
prompt_segment green $CURRENT_FG
fi
echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
else
st=""
rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(command hg id -b 2>/dev/null)
if command hg st | command grep -q "^\?"; then
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
prompt_segment red black
st='±'
elif command hg st | command grep -q "^[MA]"; then
elif `hg st | grep -q "^[MA]"`; then
prompt_segment yellow black
st='±'
else