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

Compare commits

..

5 Commits

Author SHA1 Message Date
sattisumasri
6768906d07
chore: change headings in README to Title Case (#11956)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
2023-10-11 20:57:01 +02:00
Marc Cornellà
408330e131
ci: remove redundant macos runner for CI tests
Currently the macOS runner is not needed, as we are only checking
zsh syntax. We can reactivate it in the future if needed.
2023-10-11 20:44:46 +02:00
Marc Cornellà
53cb50acb5
refactor(systemadmin): use ss instead of netstat when available (#11957) 2023-10-11 20:43:55 +02:00
Marc Cornellà
fedef5dbd5
fix(xcode): open Xcode in current Desk if already open in another (#10384)
Fixes #10384
2023-10-11 19:23:44 +02:00
Lukas Elmer
da3b8fcb6a
fix(yarn): output completion entries in UTF-8 (#11955) 2023-10-11 18:06:22 +02:00
5 changed files with 111 additions and 89 deletions

View File

@ -20,16 +20,12 @@ permissions:
jobs:
tests:
name: Run tests
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up git repository
uses: actions/checkout@v3
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Check syntax
run: |

View File

@ -23,32 +23,33 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
<summary>Table of Contents</summary>
- [Getting Started](#getting-started)
- [Operating System Compatibility](#operating-system-compatibility)
- [Prerequisites](#prerequisites)
- [Basic Installation](#basic-installation)
- [Manual inspection](#manual-inspection)
- [Manual Inspection](#manual-inspection)
- [Using Oh My Zsh](#using-oh-my-zsh)
- [Plugins](#plugins)
- [Enabling Plugins](#enabling-plugins)
- [Using Plugins](#using-plugins)
- [Themes](#themes)
- [Selecting a Theme](#selecting-a-theme)
- [Selecting A Theme](#selecting-a-theme)
- [FAQ](#faq)
- [Advanced Topics](#advanced-topics)
- [Advanced Installation](#advanced-installation)
- [Custom Directory](#custom-directory)
- [Unattended install](#unattended-install)
- [Installing from a forked repository](#installing-from-a-forked-repository)
- [Unattended Install](#unattended-install)
- [Installing From A Forked Repository](#installing-from-a-forked-repository)
- [Manual Installation](#manual-installation)
- [Installation Problems](#installation-problems)
- [Custom Plugins and Themes](#custom-plugins-and-themes)
- [Enable GNU ls in macOS and freeBSD systems](#enable-gnu-ls)
- [Skip aliases](#skip-aliases)
- [Custom Plugins And Themes](#custom-plugins-and-themes)
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
- [Skip Aliases](#skip-aliases)
- [Getting Updates](#getting-updates)
- [Updates verbosity](#updates-verbosity)
- [Updates Verbosity](#updates-verbosity)
- [Manual Updates](#manual-updates)
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
- [How do I contribute to Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
- [Do NOT send us themes](#do-not-send-us-themes)
- [How Do I Contribute To Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
- [Do Not Send Us Themes](#do-not-send-us-themes)
- [Contributors](#contributors)
- [Follow Us](#follow-us)
- [Merchandise](#merchandise)
@ -61,15 +62,15 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
### Operating System Compatibility
| O/S | Status |
| :---------------- | :------: |
| Android | ✅ |
| FreeBSD | ✅ |
| LCARS | 🛸 |
| Linux | ✅ |
| MacOS | ✅ |
| OS/2 Warp | ❌ |
| Windows (WSL2) | ✅ |
| O/S | Status |
| :------------- | :-----: |
| Android | |
| freeBSD | ✅ |
| LCARS | 🛸 |
| Linux | |
| macOS | ✅ |
| OS/2 Warp | |
| Windows (WSL2) | |
### Prerequisites
@ -90,7 +91,7 @@ Oh My Zsh is installed by running one of the following commands in your terminal
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
#### Manual inspection
#### Manual Inspection
It's a good idea to inspect the install script from projects you don't yet know. You can do
that by downloading the install script first, looking through it so everything looks normal,
@ -139,7 +140,7 @@ Each built-in plugin includes a **README**, documenting it. This README should s
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
#### Selecting a Theme
#### Selecting A Theme
_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right one (for him)._
@ -210,7 +211,7 @@ like this:
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
```
#### Unattended install
#### Unattended Install
If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
flag to the `install.sh` script. This will have the effect of not trying to change
@ -220,7 +221,7 @@ the default shell, and it also won't run `zsh` when the installation has finishe
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
```
#### Installing from a forked repository
#### Installing From A Forked Repository
The install script also accepts these variables to allow installation of a different repository:
@ -245,19 +246,19 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
#### Manual Installation
##### 1. Clone the repository <!-- omit in toc -->
##### 1. Clone The Repository <!-- omit in toc -->
```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
##### 2. _Optionally_, backup your existing `~/.zshrc` file <!-- omit in toc -->
##### 2. _Optionally_, Backup Your Existing `~/.zshrc` File <!-- omit in toc -->
```sh
cp ~/.zshrc ~/.zshrc.orig
```
##### 3. Create a new zsh configuration file <!-- omit in toc -->
##### 3. Create A New Zsh Configuration File <!-- omit in toc -->
You can create a new zsh config file by copying the template that we have included for you.
@ -265,7 +266,7 @@ You can create a new zsh config file by copying the template that we have includ
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
```
##### 4. Change your default shell <!-- omit in toc -->
##### 4. Change Your Default Shell <!-- omit in toc -->
```sh
chsh -s $(which zsh)
@ -273,7 +274,7 @@ chsh -s $(which zsh)
You must log out from your user session and log back in to see this change.
##### 5. Initialize your new zsh configuration <!-- omit in toc -->
##### 5. Initialize Your New Zsh Configuration <!-- omit in toc -->
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
@ -284,7 +285,7 @@ If you have any hiccups installing, here are a few common fixes.
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
- If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
### Custom Plugins and Themes
### Custom Plugins And Themes
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
@ -292,7 +293,7 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
### Enable GNU ls in macOS and freeBSD systems
### Enable GNU ls In macOS And freeBSD Systems
<a name="enable-gnu-ls"></a>
@ -306,7 +307,7 @@ zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
_Note: this is not compatible with `DISABLE_LS_COLORS=true`_
### Skip aliases
### Skip Aliases
<a name="remove-directories-aliases"></a>
@ -389,7 +390,7 @@ zstyle ':omz:update' frequency 7
zstyle ':omz:update' frequency 0
```
### Updates verbosity
### Updates Verbosity
You can also limit the update verbosity with the following settings:
@ -417,7 +418,7 @@ Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy b
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
## How do I contribute to Oh My Zsh?
## How Do I Contribute To Oh My Zsh?
Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
@ -427,7 +428,7 @@ We also need people to test out pull requests. So take a look through [the open
See [Contributing](CONTRIBUTING.md) for more details.
### Do NOT send us themes
### Do Not Send Us Themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.

View File

@ -13,11 +13,11 @@
# ------------------------------------------------------------------------------
function retlog() {
if [[ -z $1 ]];then
echo '/var/log/nginx/access.log'
else
echo $1
fi
if [[ -z $1 ]];then
echo '/var/log/nginx/access.log'
else
echo $1
fi
}
alias ping='ping -c 5'
@ -28,142 +28,160 @@ alias mkdir='mkdir -pv'
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10'
# get top process eating cpu if not work try execute : 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 -n 10'
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 -n 10'
# top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
function ip() {
if [ -t 1 ]; then
command ip -color "$@"
else
command ip "$@"
fi
if [ -t 1 ]; then
command ip -color "$@"
else
command ip "$@"
fi
}
# directory LS
function dls() {
print -l *(/)
print -l *(/)
}
function psgrep() {
ps aux | grep "${1:-.}" | grep -v grep
ps aux | grep "${1:-.}" | grep -v grep
}
# Kills any process that matches a regexp passed to it
function killit() {
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
}
# list contents of directories in a tree-like format
if ! (( $+commands[tree] )); then
function tree() {
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
}
function tree() {
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
}
fi
# Sort connection state
function sortcons() {
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
{
LANG= ss -nat | awk 'NR > 1 {print $1}' \
|| LANG= netstat -nat | awk 'NR > 2 {print $6}'
} | sort | uniq -c | sort -rn
}
# View all 80 Port Connections
function con80() {
netstat -nat|grep -i ":80"|wc -l
{
LANG= ss -nat || LANG= netstat -nat
} | grep -E ":80[^0-9]" | wc -l
}
# On the connected IP sorted by the number of connections
function sortconip() {
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
{
LANG= ss -ntu | awk 'NR > 1 {print $6}' \
|| LANG= netstat -ntu | awk 'NR > 2 {print $5}'
} | cut -d: -f1 | sort | uniq -c | sort -n
}
# top20 of Find the number of requests on 80 port
function req20() {
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
{
LANG= ss -tn | awk '$4 ~ /:80$/ {print $5}' \
|| LANG= netstat -tn | awk '$4 ~ /:80$/ {print $5}'
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
}
# top20 of Using tcpdump port 80 access to view
function http20() {
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
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
function timewait20() {
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
{
LANG= ss -nat | awk 'NR > 1 && /TIME-WAIT/ {print $5}' \
|| LANG= netstat -nat | awk 'NR > 2 && /TIME_WAIT/ {print $5}'
} | sort | uniq -c | sort -rn | head -n 20
}
# top20 of Find SYN connection
function syn20() {
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
{
LANG= ss -an | awk '/SYN/ {print $5}' \
|| LANG= netstat -an | awk '/SYN/ {print $5}'
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
}
# Printing process according to the port number
function port_pro() {
netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/' \
|| LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
}
# top10 of gain access to the ip address
function accessip10() {
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
}
# top20 of Most Visited file or page
function visitpage20() {
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 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
function consume100() {
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
# if django website or other website make by no suffix language
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
# if django website or other website make by no suffix language
# awk '{print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
}
# Website traffic statistics (G)
function webtraffic() {
awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
}
# Statistical connections 404
function c404() {
awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort
awk '($9 ~ /404/)' "$(retlog)" | awk '{print $9,$7}' | sort
}
# Statistical http status.
function httpstatus() {
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
}
# Delete 0 byte file
function d0() {
find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
}
# gather external ip address
function geteip() {
curl -s -S -4 https://icanhazip.com
curl -s -S -4 https://icanhazip.com
# handle case when there is no IPv6 external IP, which shows error
# curl: (7) Couldn't connect to server
curl -s -S -6 https://icanhazip.com 2>/dev/null
local ret=$?
(( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f"
return $ret
# handle case when there is no IPv6 external IP, which shows error
# curl: (7) Couldn't connect to server
curl -s -S -6 https://icanhazip.com 2>/dev/null
local ret=$?
(( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f"
return $ret
}
# determine local IP address(es)
function getip() {
if (( ${+commands[ip]} )); then
ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
else
ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
fi
if (( ${+commands[ip]} )); then
ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
else
ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
fi
}
# Clear zombie processes
function clrz() {
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
}
# Second concurrent
function conssec() {
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)" | sort -k 2 -nr | head -n10
}

View File

@ -17,6 +17,13 @@ function xc {
local active_path
active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
echo "Found ${xcode_files[1]}. Opening with ${active_path}"
# If Xcode is already opened in another Desk, we need this double call
# with -g to open the project window in the current Desk and focus it.
# See https://github.com/ohmyzsh/ohmyzsh/issues/10384
if command pgrep -q "^Xcode"; then
open -g -a "$active_path" "${xcode_files[1]}"
fi
open -a "$active_path" "${xcode_files[1]}"
}

View File

@ -144,7 +144,7 @@ _yarn_scripts() {
fi
if [[ -n $packageJson ]]; then
scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E 'binmode(STDOUT, ":encoding(UTF-8)"); %r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
fi
commands=('env' $scripts $binaries)