Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zsh script #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
database.db
zshrc.sh

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,7 @@ docker run -d -e SECRET_TOKEN=azerty -p 5000:5000 xgaia/command-streamer

### zsh

create a `zshrc.sh` file with the following content

```zsh
app_url=http://localhost:5000
secret_token=azerty
function post_command () {
curl -s -X POST ${app_url}/command -H 'token: '${secret_token}'' -H 'Content-Type: application/json' -d '{"command":"'${1}'"}' > /dev/null
}
function reset () {
curl -s ${app_url}/reset -H 'token: '${secret_token}'' > /dev/null
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec post_command
```

source the file
source cmd_zsh.sh

```zsh
source zshrc.sh
Expand Down
10 changes: 10 additions & 0 deletions cmd_zsh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
app_url=http://localhost:5000
secret_token=azerty
function post_command () {
curl -s -X POST ${app_url}/command -H 'token: '${secret_token}'' -H 'Content-Type: application/json' -d '{"command":"'${1}'"}' > /dev/null
}
function reset () {
curl -s ${app_url}/reset -H 'token: '${secret_token}'' > /dev/null
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec post_command