mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-12 15:34:50 +08:00
Compare commits
4 Commits
dc453872b0
...
9a7a607dc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a7a607dc3 | ||
|
|
f84341c574 | ||
|
|
92aed2e936 | ||
|
|
0b8a9d1de2 |
33
lib/git.zsh
33
lib/git.zsh
@ -117,7 +117,7 @@ function _omz_git_prompt_status() {
|
||||
fi
|
||||
|
||||
# For each status prefix, do a regex comparison
|
||||
for status_prefix in ${(k)prefix_constant_map}; do
|
||||
for status_prefix in "${(@k)prefix_constant_map}"; do
|
||||
local status_constant="${prefix_constant_map[$status_prefix]}"
|
||||
local status_regex=$'(^|\n)'"$status_prefix"
|
||||
|
||||
@ -365,3 +365,34 @@ function git_repo_name() {
|
||||
echo ${repo_path:t}
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs 3 stats for git repo
|
||||
# 1) number of files changed,
|
||||
# 2) the total number of lines added
|
||||
# 3) total number of lines removed
|
||||
#
|
||||
# Example
|
||||
# 3f:69+:6-
|
||||
function git_files_changed() {
|
||||
local -i files=0
|
||||
local -i insertions=0
|
||||
local -i deletions=0
|
||||
local raw=$(command git diff --numstat 2>/dev/null) || return 0
|
||||
if [[ -n $raw ]]; then
|
||||
echo $raw | while IFS= read -r line; do
|
||||
local -i d=$line[(w)2]
|
||||
local -i i=$line[(w)1]
|
||||
insertions+=i
|
||||
deletions+=d
|
||||
files+=1
|
||||
done
|
||||
local output="$ZSH_THEME_GIT_FILES_CHANGED_PREFIX${files}f$ZSH_THEME_GIT_FILES_CHANGED_SUFFIX"
|
||||
if (( $insertions > 0 )); then
|
||||
output="$output:$ZSH_THEME_GIT_LINES_ADDED_PREFIX${insertions}+$ZSH_THEME_GIT_LINES_ADDED_SUFFIX"
|
||||
fi
|
||||
if (( $deletions > 0 )); then
|
||||
output="$output:$ZSH_THEME_GIT_LINES_REMOVED_PREFIX${deletions}-$ZSH_THEME_GIT_LINES_REMOVED_SUFFIX"
|
||||
fi
|
||||
echo $output
|
||||
fi
|
||||
}
|
||||
|
||||
@ -77,7 +77,15 @@ EOF
|
||||
(*.lzma) unlzma "$full_path" ;;
|
||||
(*.z) uncompress "$full_path" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
|
||||
(*.rar) unrar x -ad "$full_path" ;;
|
||||
(*.rar)
|
||||
if (( $+commands[unrar] )); then
|
||||
unrar x -ad "$full_path"
|
||||
elif (( $+commands[unar] )); then
|
||||
unar -o . "$full_path"
|
||||
else
|
||||
echo "extract: cannot extract RAR files: install unrar or unar" >&2
|
||||
success=1
|
||||
fi ;;
|
||||
(*.rpm)
|
||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||
(*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user