Merge pull request #1 from x-cmd-sourcecode/fea-250109-x-cmd

add x-cmd plugin
This commit is contained in:
curry798 2026-01-19 16:24:50 +08:00 committed by GitHub
commit ff2e2187e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 69 additions and 0 deletions

33
plugins/x-cmd/README.md Normal file
View file

@ -0,0 +1,33 @@
# 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 proxy enable 8090 # Set
```

View file

@ -0,0 +1,36 @@
x(){(
@info(){
printf "%s\n" "$@"
}
if [ -e "$HOME/.x-cmd.root/X" ]; then
. "$HOME/.x-cmd.root/X"
___x_cmd "$@"
return $?
fi
local cmdstr=""
if command -v curl >/dev/null 2>&1; then
cmdstr='eval "$(curl -s https://get.x-cmd.com)"'
elif command -v wget >/dev/null 2>&1; 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 "answer?Please press y for yes. Ctrl-C will also abort the setup. "
case "$answer" in
y|Y|yes)
echo "Setup is going now."
eval "$cmdstr"
return 0
;;
*)
echo ""
;;
esac
)}