From 6563ae107efd04080bb582e350d285d032a81a8b Mon Sep 17 00:00:00 2001 From: Li Junhao Date: Sat, 10 Jan 2026 03:28:19 +0800 Subject: [PATCH 1/4] Introducing x-cmd plugin for ohmyzsh --- plugins/x-cmd/README.md | 36 ++++++++++++++++++++++++++++ plugins/x-cmd/x-cmd.plugin.zsh | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 plugins/x-cmd/README.md create mode 100644 plugins/x-cmd/x-cmd.plugin.zsh diff --git a/plugins/x-cmd/README.md b/plugins/x-cmd/README.md new file mode 100644 index 000000000..9368ec679 --- /dev/null +++ b/plugins/x-cmd/README.md @@ -0,0 +1,36 @@ +# X-CMD + +To start using it, add the `x-cmd` plugin to your `plugins` array in `~/.zshrc`: + +```zsh +plugins=(... x-cmd) +``` + +## Functions + +### `x` + +```zsh +x yq # Using yq command to interract with YML. If yq is not avaiable in the machine. X-CMD will download and directly execute the binary on demand without installation. X-CMD try to avoid influence the environment and folder and always find the solution with least impact. + +x fjo # Posix shell CLI to interactve with forgejo. +x cb # Posix shell CLI to interactve with codeberg. + +x nihao # For more information about using gpt, gemini, etc in terminal. +``` + +### `m` + +m for `machine`. + +In mac, it is [`x mac`](https://x-cmd.com/mod/mac). +In termux, it is [`x termux`](https://x-cmd.com/mod/termux). + +```bash +m ss # Info about systemsetup +m app # List application status +m wifi proxy enable :2023 # Set +``` + + + diff --git a/plugins/x-cmd/x-cmd.plugin.zsh b/plugins/x-cmd/x-cmd.plugin.zsh new file mode 100644 index 000000000..d4a6d84fb --- /dev/null +++ b/plugins/x-cmd/x-cmd.plugin.zsh @@ -0,0 +1,44 @@ + +x(){( + @info(){ + printf "%s\n" "$@" + } + + if [ -e "$HOME/.x-cmd.root/X" ]; then + . "$HOME/.x-cmd.root/X" + return $? + fi + + local cmdstr="" + if command -v curl 2>/dev/null; then + cmdstr='eval "$(curl -s https://get.x-cmd.com)"' + elif command -v wget 2>/dev/null; then + cmdstr='eval "$(wget -O- https://get.x-cmd.com)"' + fi + + @info "X-CMD is not installed. Do you want to install x-cmd ?" + @info "Command using is -> $cmdstr" + + local answer="" + read -q "Please press y for yes, n for no. Ctrl-C will also abort the setup." answer || { + @info "Received intrrupt. Exit with error code 130." + return 130 + } + + case "$answer" in + n|N|no) + @info "Received $answer. Exit the setup immediately." + return 0 + ;; + y|Y|yes) + @info "Received $answer. Setup is going now." + eval "$cmdstr" + return 0 + ;; + *) + @info "Received unknown $answer." + return 1 + ;; + esac +)} + From 1c2479a56349b50ca7bfa403fb43016039d93f2d Mon Sep 17 00:00:00 2001 From: Li Junhao Date: Sat, 10 Jan 2026 03:32:53 +0800 Subject: [PATCH 2/4] Update proxy example --- plugins/x-cmd/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/x-cmd/README.md b/plugins/x-cmd/README.md index 9368ec679..0bd7c11a6 100644 --- a/plugins/x-cmd/README.md +++ b/plugins/x-cmd/README.md @@ -29,7 +29,7 @@ In termux, it is [`x termux`](https://x-cmd.com/mod/termux). ```bash m ss # Info about systemsetup m app # List application status -m wifi proxy enable :2023 # Set +m proxy enable 8090 # Set ``` From 697b9a993000a70323df39df0d46d1112234e1b9 Mon Sep 17 00:00:00 2001 From: curry798 Date: Mon, 19 Jan 2026 15:38:29 +0800 Subject: [PATCH 3/4] Fix: x-cmd unavailable/Resolve x-cmd failure --- plugins/x-cmd/README.md | 3 --- plugins/x-cmd/x-cmd.plugin.zsh | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/x-cmd/README.md b/plugins/x-cmd/README.md index 0bd7c11a6..0d24d329b 100644 --- a/plugins/x-cmd/README.md +++ b/plugins/x-cmd/README.md @@ -31,6 +31,3 @@ m ss # Info about systemsetup m app # List application status m proxy enable 8090 # Set ``` - - - diff --git a/plugins/x-cmd/x-cmd.plugin.zsh b/plugins/x-cmd/x-cmd.plugin.zsh index d4a6d84fb..963a2efe1 100644 --- a/plugins/x-cmd/x-cmd.plugin.zsh +++ b/plugins/x-cmd/x-cmd.plugin.zsh @@ -6,6 +6,7 @@ x(){( if [ -e "$HOME/.x-cmd.root/X" ]; then . "$HOME/.x-cmd.root/X" + ___x_cmd "$@" return $? fi From de26c8cd227442f8e7d2d6e43fca70d481df036f Mon Sep 17 00:00:00 2001 From: curry798 Date: Mon, 19 Jan 2026 16:20:24 +0800 Subject: [PATCH 4/4] feat(x-cmd): Improve silent execution and simplify setup prompt --- plugins/x-cmd/x-cmd.plugin.zsh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/plugins/x-cmd/x-cmd.plugin.zsh b/plugins/x-cmd/x-cmd.plugin.zsh index 963a2efe1..e7160d99f 100644 --- a/plugins/x-cmd/x-cmd.plugin.zsh +++ b/plugins/x-cmd/x-cmd.plugin.zsh @@ -11,9 +11,9 @@ x(){( fi local cmdstr="" - if command -v curl 2>/dev/null; then + if command -v curl >/dev/null 2>&1; then cmdstr='eval "$(curl -s https://get.x-cmd.com)"' - elif command -v wget 2>/dev/null; then + elif command -v wget >/dev/null 2>&1; then cmdstr='eval "$(wget -O- https://get.x-cmd.com)"' fi @@ -21,24 +21,15 @@ x(){( @info "Command using is -> $cmdstr" local answer="" - read -q "Please press y for yes, n for no. Ctrl-C will also abort the setup." answer || { - @info "Received intrrupt. Exit with error code 130." - return 130 - } - + read -q "answer?Please press y for yes. Ctrl-C will also abort the setup. " case "$answer" in - n|N|no) - @info "Received $answer. Exit the setup immediately." - return 0 - ;; y|Y|yes) - @info "Received $answer. Setup is going now." + echo "Setup is going now." eval "$cmdstr" return 0 ;; *) - @info "Received unknown $answer." - return 1 + echo "" ;; esac )}