Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  Add proper prompt_opts to smiley prompt
  Revert "Only call reset-prompt when the appropriate zstyle is set"
  Feat (git): add an alias displaying the commits yet to be applied to upstream (sorin-ionescu#1565)
  Allow users to easily define LS_COLORS and LSCOLORS (sorin-ionescu#1546)
  Ignore tmux autostart in vscode terminal
  Replace git with 'command git' (sorin-ionescu#1551)
  • Loading branch information
Jeff Billimek committed Apr 13, 2018
2 parents 1d8f633 + 3001028 commit 3fe35ff
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 73 deletions.
2 changes: 0 additions & 2 deletions modules/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ zstyle ':prezto:module:editor' dot-expansion 'yes'

### PS Context

**NOTE:** *This is deprecated and will be removed in future versions.*

To enable the prompt context to be set, add the following to your
*zpreztorc*.

Expand Down
15 changes: 7 additions & 8 deletions modules/editor/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,20 @@ function editor-info {
}
zle -N editor-info

# Reset the prompt based on the current context and whether the prompt utilizes
# the editor:info zstyle. If the prompt does utilize the editor:info, we must
# reset the prompt, otherwise the change in the prompt will never update. If the
# prompt does not utilize the editor:info, we simply redisplay the command line.
# Reset the prompt based on the current context and
# the ps-context option.
function zle-reset-prompt {
# Explicitly check to see if there is an editor info keymap set that would
# require a reset of the prompt
if zstyle -L ':prezto:module:editor:info*' | grep -v 'completing' > /dev/null 2>&1; then
if zstyle -t ':prezto:module:editor' ps-context; then
# If we aren't within one of the specified contexts, then we want to reset
# the prompt with the appropriate editor_info[keymap] if there is one.
if [[ $CONTEXT != (select|cont) ]]; then
zle reset-prompt
zle -R
fi
else
zle reset-prompt
zle -R
fi
zle -R
}
zle -N zle-reset-prompt

Expand Down
2 changes: 2 additions & 0 deletions modules/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ zstyle ':prezto:module:git:alias' skip 'yes'
- `gcR` removes the *HEAD* commit.
- `gcs` displays various types of objects.
- `gcl` lists lost commits.
- `gcy` displays commits yet to be applied to upstream in the short format.
- `gcY` displays commits yet to be applied to upstream.

### Conflict

Expand Down
2 changes: 2 additions & 0 deletions modules/git/alias.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then
alias gcR='git reset "HEAD^"'
alias gcs='git show'
alias gcl='git-commit-lost'
alias gcy='git cherry -v --abbrev'
alias gcY='git cherry -v'

# Conflict (C)
alias gCl='git --no-pager diff --name-only --diff-filter=U'
Expand Down
8 changes: 4 additions & 4 deletions modules/git/functions/_git-hub-browse
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Sorin Ionescu <[email protected]>
#

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

Expand All @@ -21,15 +21,15 @@ _arguments -C -s -S \

case "$state" in
(remote)
remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2))

_describe -t branch 'remotes' remotes && ret=0
;;
(branch-or-tag)
remote="$words[(($CURRENT - 1))]"

branches_or_tags=($(
git ls-remote --heads --tags "$remote" 2> /dev/null | cut -f2
command git ls-remote --heads --tags "$remote" 2> /dev/null | cut -f2
))

branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
Expand All @@ -39,7 +39,7 @@ case "$state" in
_describe -t tag 'tags' tags && ret=0
;;
(file)
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2> /dev/null)"})
files=(${(0)"$(_call_program files command git ls-files -z --exclude-standard 2> /dev/null)"})
_wanted file expl 'file' _multi_parts - / files && ret=0
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion modules/git/functions/_git-info
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Sorin Ionescu <[email protected]>
#

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

Expand Down
4 changes: 2 additions & 2 deletions modules/git/functions/_git-submodule-move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Sorin Ionescu <[email protected]>
#

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

Expand All @@ -25,7 +25,7 @@ case "$state" in
while IFS=$'\n' read submodule; do
submodules+=("$submodule")
done < <(
git config --file "$(git-root)/.gitmodules" --list \
command git config --file "$(git-root)/.gitmodules" --list \
| grep '.path=' \
| cut -d= -f2-
)
Expand Down
4 changes: 2 additions & 2 deletions modules/git/functions/_git-submodule-remove
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Sorin Ionescu <[email protected]>
#

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

Expand All @@ -18,7 +18,7 @@ local submodule
while IFS=$'\n' read submodule; do
submodules+=("$submodule")
done < <(
git config --file "$(git-root)/.gitmodules" --list \
command git config --file "$(git-root)/.gitmodules" --list \
| grep '.path=' \
| cut -d= -f2-
)
Expand Down
4 changes: 2 additions & 2 deletions modules/git/functions/git-branch-current
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

# function git-branch-current {

if ! git rev-parse 2> /dev/null; then
if ! command git rev-parse 2> /dev/null; then
print "$0: not a repository: $PWD" >&2
return 1
fi

local ref="$(git symbolic-ref HEAD 2> /dev/null)"
local ref="$(command git symbolic-ref HEAD 2> /dev/null)"

if [[ -n "$ref" ]]; then
print "${ref#refs/heads/}"
Expand Down
6 changes: 3 additions & 3 deletions modules/git/functions/git-commit-lost
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

# function git-commit-lost {

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi

git fsck 2> /dev/null \
command git fsck 2> /dev/null \
| grep "^dangling commit" \
| awk '{print $3}' \
| git log \
| command git log \
--date-order \
--no-walk \
--stdin \
Expand Down
2 changes: 1 addition & 1 deletion modules/git/functions/git-dir
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# function git-dir {

local git_dir="${$(git rev-parse --git-dir):A}"
local git_dir="${$(command git rev-parse --git-dir):A}"

if [[ -n "$git_dir" ]]; then
print "$git_dir"
Expand Down
10 changes: 5 additions & 5 deletions modules/git/functions/git-hub-browse
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@

# function git-hub-browse {

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi

local remotes remote references reference file url

remote="${1:-origin}"
remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2))

if (( $remotes[(i)$remote] == $#remotes + 1 )); then
print "$0: remote not found: $remote" >&2
return 1
fi

url=$(
git config --get "remote.${remote}.url" \
command git config --get "remote.${remote}.url" \
| sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
)

reference="${${2:-$(git-branch-current)}:-HEAD}"
references=(
HEAD
${$(git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/}
${$(command git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/}
)

if (( $references[(i)$reference] == $#references + 1 )); then
Expand All @@ -39,7 +39,7 @@ if (( $references[(i)$reference] == $#references + 1 )); then
fi

if [[ "$reference" == 'HEAD' ]]; then
reference="$(git rev-parse HEAD 2> /dev/null)"
reference="$(command git rev-parse HEAD 2> /dev/null)"
fi

file="$3"
Expand Down
28 changes: 14 additions & 14 deletions modules/git/functions/git-info
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,23 @@ function git-info {
typeset -gA git_info

# Return if not inside a Git repository work tree.
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

if (( $# > 0 )); then
if [[ "$1" == [Oo][Nn] ]]; then
git config --bool prompt.showinfo true
command git config --bool prompt.showinfo true
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
git config --bool prompt.showinfo false
command git config --bool prompt.showinfo false
else
print "usage: $0 [ on | off ]" >&2
fi
return 0
fi

# Return if git-info is disabled.
if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then
if ! is-true "${$(command git config --bool prompt.showinfo):-true}"; then
return 1
fi

Expand All @@ -204,7 +204,7 @@ function git-info {
# Format commit.
zstyle -s ':prezto:module:git:info:commit' format 'commit_format'
if [[ -n "$commit_format" ]]; then
commit="$(git rev-parse HEAD 2> /dev/null)"
commit="$(command git rev-parse HEAD 2> /dev/null)"
if [[ -n "$commit" ]]; then
zformat -f commit_formatted "$commit_format" "c:$commit"
fi
Expand All @@ -213,7 +213,7 @@ function git-info {
# Format stashed.
zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format'
if [[ -n "$stashed_format" && -f "$(git-dir)/refs/stash" ]]; then
stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')"
stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')"
if [[ -n "$stashed" ]]; then
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
fi
Expand All @@ -229,7 +229,7 @@ function git-info {
fi

# Get the branch.
branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}"
branch="${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}"

# Format branch.
zstyle -s ':prezto:module:git:info:branch' format 'branch_format'
Expand All @@ -240,7 +240,7 @@ function git-info {
# Format position.
zstyle -s ':prezto:module:git:info:position' format 'position_format'
if [[ -z "$branch" && -n "$position_format" ]]; then
position="$(git describe --contains --all HEAD 2> /dev/null)"
position="$(command git describe --contains --all HEAD 2> /dev/null)"
if [[ -n "$position" ]]; then
zformat -f position_formatted "$position_format" "p:$position"
fi
Expand All @@ -250,7 +250,7 @@ function git-info {
zstyle -s ':prezto:module:git:info:remote' format 'remote_format'
if [[ -n "$branch" && -n "$remote_format" ]]; then
# Gets the remote name.
remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
if [[ -n "$remote" ]]; then
zformat -f remote_formatted "$remote_format" "R:$remote"
Expand All @@ -261,7 +261,7 @@ function git-info {
zstyle -s ':prezto:module:git:info:behind' format 'behind_format'
if [[ -n "$branch" && ( -n "$ahead_format" || -n "$behind_format" ) ]]; then
# Gets the commit difference counts between local and remote.
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}'

# Get ahead and behind counts.
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
Expand Down Expand Up @@ -290,7 +290,7 @@ function git-info {
if [[ -n "$indexed_format" ]]; then
((
indexed+=$(
git diff-index \
command git diff-index \
--no-ext-diff \
--name-only \
--cached \
Expand All @@ -310,7 +310,7 @@ function git-info {
if [[ -n "$unindexed_format" ]]; then
((
unindexed+=$(
git diff-files \
command git diff-files \
--no-ext-diff \
--name-only \
--ignore-submodules=${ignore_submodules:-none} \
Expand All @@ -328,7 +328,7 @@ function git-info {
if [[ -n "$untracked_format" ]]; then
((
untracked+=$(
git ls-files \
command git ls-files \
--other \
--exclude-standard \
2> /dev/null \
Expand All @@ -343,7 +343,7 @@ function git-info {
(( dirty = indexed + unindexed + untracked ))
else
# Use porcelain status for easy parsing.
status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}"
status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}"

# Get current status.
while IFS=$'\n' read line; do
Expand Down
2 changes: 1 addition & 1 deletion modules/git/functions/git-root
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# function git-root {

local root="$(git rev-parse --show-toplevel 2> /dev/null)"
local root="$(command git rev-parse --show-toplevel 2> /dev/null)"

if [[ -n "$root" ]]; then
print "$root"
Expand Down
6 changes: 3 additions & 3 deletions modules/git/functions/git-stash-clear-interactive
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

# function git-stash-clear-interactive {

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi

local stashed

if [[ -f "$(git-dir)/refs/stash" ]]; then
stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')"
stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')"
if (( $stashed > 0 )); then
if read -q "?Clear $stashed stashed state(s) [y/N]? "; then
git stash clear
command git stash clear
fi
fi
fi
Expand Down
6 changes: 3 additions & 3 deletions modules/git/functions/git-stash-dropped
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

# function git-stash-dropped {

if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi

git fsck --unreachable 2> /dev/null \
command git fsck --unreachable 2> /dev/null \
| grep 'commit' \
| awk '{print $3}' \
| git log \
| command git log \
--pretty=format:${_git_log_oneline_format} \
--extended-regexp \
--grep="${1:-(WIP )?[Oo]n [^:]+:}" \
Expand Down
Loading

0 comments on commit 3fe35ff

Please sign in to comment.