Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Nov 9, 2021
2 parents 0bde740 + 5c2440c commit f41c710
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 68 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ plugins=(
git
bundler
dotenv
osx
macos
rake
rbenv
ruby
Expand Down
6 changes: 3 additions & 3 deletions lib/cli.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ function _omz::plugin::load {
fi

# Check if it has completion to reload compinit
if [[ -f "$base/_$plugin" ]]; then
has_completion=1
fi
local -a comp_files
comp_files=($base/_*(N))
has_completion=$(( $#comp_files > 0 ))

# Load the plugin
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion lib/diagnostics.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function _omz_diag_dump_os_specific_version() {
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
;;
cygwin)
command systeminfo | command head -4 | command tail -2
command systeminfo | command head -n 4 | command tail -n 2
;;
esac

Expand Down
2 changes: 1 addition & 1 deletion lib/directories.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function d () {
if [[ -n $1 ]]; then
dirs "$@"
else
dirs -v | head -10
dirs -v | head -n 10
fi
}
compdef _dirs d
Expand Down
4 changes: 2 additions & 2 deletions lib/functions.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function zsh_stats() {
fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
| grep -v "./" | sort -nr | head -n 20 | column -c3 -s " " -t | nl
}

function uninstall_oh_my_zsh() {
Expand Down Expand Up @@ -45,7 +45,7 @@ function takeurl() {
data="$(mktemp)"
curl -L "$1" > "$data"
tar xf "$data"
thedir="$(tar tf "$data" | head -1)"
thedir="$(tar tf "$data" | head -n 1)"
rm "$data"
cd "$thedir"
}
Expand Down
2 changes: 1 addition & 1 deletion lib/git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function parse_git_dirty() {
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1)
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
fi
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions plugins/osx/README.md → plugins/macos/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# OSX plugin
# MacOS plugin

This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX).

To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`:
To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:

```zsh
plugins=(... osx)
plugins=(... macos)
```

Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
Expand All @@ -31,7 +31,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
| `music` | Control Apple Music. Use `music -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
| `rmdsstore` | Remove .DS_Store files recursively in a directory |
| `btrestart` | Restart the Bluetooth daemon |
| `freespace` | Erases purgeable disk space with 0s on the selected disk |

Expand Down
File renamed without changes.
14 changes: 10 additions & 4 deletions plugins/osx/osx.plugin.zsh → plugins/macos/macos.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Check if 'osx' is still in the plugins list and prompt to change to 'macos'
if [[ -n "${plugins[(r)osx]}" ]]; then
print ${(%):-"%F{yellow}The \`osx\` plugin is deprecated and has been renamed to \`macos\`."}
print ${(%):-"Please update your .zshrc to use the \`%Bmacos%b\` plugin instead.%f"}
fi

# Open the current directory in a Finder window
alias ofd='open_command $PWD'

Expand All @@ -11,7 +17,7 @@ function btrestart() {
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
}

function _omz_osx_get_frontmost_app() {
function _omz_macos_get_frontmost_app() {
osascript 2>/dev/null <<EOF
tell application "System Events"
name of first item of (every process whose frontmost is true)
Expand All @@ -24,7 +30,7 @@ function tab() {
local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"

local the_app=$(_omz_osx_get_frontmost_app)
local the_app=$(_omz_macos_get_frontmost_app)

if [[ "$the_app" == 'Terminal' ]]; then
# Discarding stdout to quash "tab N of window id XXX" output
Expand Down Expand Up @@ -77,7 +83,7 @@ function vsplit_tab() {
local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"

local the_app=$(_omz_osx_get_frontmost_app)
local the_app=$(_omz_macos_get_frontmost_app)

if [[ "$the_app" == 'iTerm' ]]; then
osascript <<EOF
Expand Down Expand Up @@ -125,7 +131,7 @@ function split_tab() {
local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"

local the_app=$(_omz_osx_get_frontmost_app)
local the_app=$(_omz_macos_get_frontmost_app)

if [[ "$the_app" == 'iTerm' ]]; then
osascript 2>/dev/null <<EOF
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/macos/osx.plugin.zsh
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/osx
23 changes: 13 additions & 10 deletions plugins/percol/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
## percol
# percol

Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh)
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and
the [jump plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump), optionally.

### Requirements
To use it, add `percol` to the plugins array in your zshrc:

```shell
pip install percol
```zsh
plugins=(... percol)
```

And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
## Requirements

### Usage
- `percol`: install with `pip install percol`.

For default
- (_Optional_) [`jump`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump) plugin: needs to be
enabled before the `percol` plugin.

- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol.
## Usage

- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol.
- <kbd>CTRL-R</kbd> (bound to `percol_select_history`): you can use it to grep your history with percol.

- <kbd>CTRL-B</kbd> (bound to `percol_select_marks`): you can use it to grep your jump bookmarks with percol.
41 changes: 22 additions & 19 deletions plugins/percol/percol.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
if which percol &> /dev/null; then
function percol_select_history() {
local tac
which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="tac" || { tac="tail -r" } }
BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER")
CURSOR=$#BUFFER
zle -R -c
}
(( ${+commands[percol]} )) || return

zle -N percol_select_history
bindkey '^R' percol_select_history
function percol_select_history() {
# print history in reverse order (from -1 (latest) to 1 (oldest))
BUFFER=$(fc -l -n -1 1 | percol --query "$LBUFFER")
CURSOR=$#BUFFER
zle -R -c
}
zle -N percol_select_history
bindkey -M emacs '^R' percol_select_history
bindkey -M viins '^R' percol_select_history
bindkey -M vicmd '^R' percol_select_history

if which marks &> /dev/null; then
function percol_select_marks() {
BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}')
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N percol_select_marks
bindkey '^B' percol_select_marks
fi
if (( ${+functions[marks]} )); then
function percol_select_marks() {
# parse directory from marks output (markname -> path) and quote if necessary
BUFFER=${(q)"$(marks | percol --query "$LBUFFER")"##*-> }
CURSOR=$#BUFFER
zle -R -c
}
zle -N percol_select_marks
bindkey -M emacs '^B' percol_select_marks
bindkey -M viins '^B' percol_select_marks
bindkey -M vicmd '^B' percol_select_marks
fi
2 changes: 1 addition & 1 deletion plugins/scd/scd
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fi
# Determine the last recorded directory
if [[ -s ${SCD_HISTFILE} ]]; then
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
last_directory=${"$(tail -n 1 ${SCD_HISTFILE})"#*;}
fi
# The "record" function adds its arguments to the directory index.
Expand Down
4 changes: 2 additions & 2 deletions plugins/systemadmin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ plugins=(... systemadmin)
| path | `print -l $path` | Displays PATH with each entry on a separate line |
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -n 10` | Display the top 10 processes using the most memory |
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -n 10` | Display the top 10 processes using the most CPU |
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |

## Functions
Expand Down
12 changes: 6 additions & 6 deletions plugins/systemadmin/systemadmin.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ alias path='print -l $path'
alias mkdir='mkdir -pv'
# get top process eating memory
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -10'
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10'
# get top process eating cpu if not work try excute : export LC_ALL='C'
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -n 10'
# top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'

Expand Down Expand Up @@ -74,7 +74,7 @@ req20() {

# top20 of Using tcpdump port 80 access to view
http20() {
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -n 20
}

# top20 of Find time_wait connection
Expand All @@ -99,14 +99,14 @@ accessip10() {

# top20 of Most Visited file or page
visitpage20() {
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -20
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 20
}

# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
consume100() {
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
# if django website or other webiste make by no suffix language
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
}

# Website traffic statistics (G)
Expand Down
1 change: 1 addition & 0 deletions plugins/tmux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ The plugin also supports the following:
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
6 changes: 5 additions & 1 deletion plugins/tmux/tmux.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ function _zsh_tmux_plugin_run() {
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
fi
$tmux_cmd new-session
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
else
$tmux_cmd new-session
fi
fi

if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions themes/emotty.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ root_prompt="$emoji[skull]"
warn_prompt="$emoji[collision_symbol]"

vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
vcs_staged_glyph="%{$emoji[high_voltage_sign] %2G%}"
vcs_branch_glyph=$(print -P $'\Ue0a0') #
vcs_action_glyph=$(print -P $'\U276f') #
vcs_staged_glyph="%{$emoji[high_voltage_sign]%2G%}"
vcs_branch_glyph=$'\Ue0a0' #
vcs_action_glyph=$'\U276f' #

red="$FG[001]"
yellow="$FG[003]"
Expand Down
4 changes: 2 additions & 2 deletions themes/refined.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ autoload -Uz vcs_info
zstyle ':vcs_info:*' enable hg bzr git
zstyle ':vcs_info:*:*' unstagedstr '!'
zstyle ':vcs_info:*:*' stagedstr '+'
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%%u%c"
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%u%c (%a)"
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%%u%c"
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%u%c (%a)"
zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""

# Fastest possible way to check if repo is dirty
Expand Down
25 changes: 19 additions & 6 deletions tools/check_for_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,27 @@ function is_update_available() {
[[ "$repo" = ohmyzsh/ohmyzsh ]] || return 0
local api_url="https://api.github.com/repos/${repo}/commits/${branch}"

# Get local and remote HEADs and compare them. If we can't get either assume there are updates
local local_head remote_head
# Get local HEAD. If this fails assume there are updates
local local_head
local_head=$(git -C "$ZSH" rev-parse $branch 2>/dev/null) || return 0

remote_head=$(curl -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null) \
|| remote_head=$(wget -O- --header='Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null) \
|| remote_head=$(HTTP_ACCEPT='Accept: application/vnd.github.v3.sha' fetch -o - $api_url 2>/dev/null) \
|| return 0
# Get remote HEAD. If we can't get it assume there are updates unless there is no connection:
# - curl: 6 (could not resolve) or 7 (could not connect)
# - wget: 4 (network unreachable)
# - fetch: 1 (no route to host)
local remote_head ret
remote_head=$(
curl -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null || {
[[ $? -eq 6 || $? -eq 7 ]] && exit 1
} || wget -O- --header='Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null || {
[[ $? -eq 4 ]] && exit 1
} || HTTP_ACCEPT='Accept: application/vnd.github.v3.sha' fetch -o - $api_url 2>/dev/null || {
[[ $? -eq 1 ]] && exit 1
} || exit 0
)

# If can't fetch remote HEAD, return exit code
ret=$?; [[ -n "$remote_head" ]] || return $ret

# Compare local and remote HEADs
[[ "$local_head" != "$remote_head" ]]
Expand Down
2 changes: 1 addition & 1 deletion tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ EOF
# 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=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -n 1) || [ ! -f "$zsh" ]; then
fmt_error "no zsh binary found or not present in '$shells_file'"
fmt_error "change your default shell manually."
return
Expand Down

0 comments on commit f41c710

Please sign in to comment.