mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Introducing x-cmd plugin for ohmyzsh
This commit is contained in:
parent
871d4b9816
commit
6563ae107e
2 changed files with 80 additions and 0 deletions
44
plugins/x-cmd/x-cmd.plugin.zsh
Normal file
44
plugins/x-cmd/x-cmd.plugin.zsh
Normal file
|
|
@ -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
|
||||
)}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue