Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
98c2658e3c | |||
c32d2ef655 | |||
bcf3570f66 | |||
25b0d0d25e | |||
50fd9c7a9d | |||
c62213c8ff | |||
434c8f43dc |
10
Makefile
10
Makefile
@ -1,13 +1,15 @@
|
|||||||
PT_VERSION ?= 0.0.1
|
|
||||||
|
|
||||||
all: prod
|
all: prod
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
v -o pt src/
|
v -o pt src/
|
||||||
|
|
||||||
prod:
|
prod:
|
||||||
v -prod -cc gcc -cflags -static -o pt src/ \
|
v -prod -skip-unused -cc gcc -cflags '-static -s' -o pt src/ \
|
||||||
-d pt_version=$(PT_VERSION) \
|
-d pt_version=$$(git describe --tags) \
|
||||||
-d pt_piddir=pt \
|
-d pt_piddir=pt \
|
||||||
-d pt_max_recursion_depth=10 \
|
-d pt_max_recursion_depth=10 \
|
||||||
-d pt_default_config_file=~/.ptrc
|
-d pt_default_config_file=~/.ptrc
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -Dm0755 pt $$HOME/.local/bin/pt
|
||||||
|
install -Dm0644 completion.bash $${XDG_DATA_HOME:-$$HOME/.local/share}/bash-completion/completions/pt
|
||||||
|
49
README.md
49
README.md
@ -17,15 +17,21 @@ Run and manage background processes without daemon or root privileges. `pt` is a
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
### Prebuilt binary
|
||||||
|
|
||||||
|
Look for statically linked binaries on the [releases page](https://github.com/gechandesu/pt/releases).
|
||||||
|
|
||||||
|
### Build from source
|
||||||
|
|
||||||
First install [V compiler](https://github.com/vlang/v).
|
First install [V compiler](https://github.com/vlang/v).
|
||||||
|
|
||||||
Clone this repo and do:
|
Then do:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
git clone https://github.com/gechandesu/pt.git
|
||||||
cd pt
|
cd pt
|
||||||
make
|
make
|
||||||
install -Dm0755 pt $HOME/.local/bin/pt
|
make install
|
||||||
install -Dm0644 completion.bash ${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions/pt
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Next step is configuration.
|
Next step is configuration.
|
||||||
@ -35,3 +41,40 @@ Next step is configuration.
|
|||||||
Default configuration file is `~/.ptrc`. This is [TOML](https://toml.io) format file.
|
Default configuration file is `~/.ptrc`. This is [TOML](https://toml.io) format file.
|
||||||
|
|
||||||
See full configuration example with comments in [ptrc.toml](ptrc.toml).
|
See full configuration example with comments in [ptrc.toml](ptrc.toml).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For example run SOCKS5 proxy over SSH. For this example to work, your computer must have ~/.ssh/config configured and the remote server must also have your SSH key. The ~/.ptrc content:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# vim: ft=toml
|
||||||
|
[entry.ssh-tunnel]
|
||||||
|
description = 'SSH tunnel to %server%'
|
||||||
|
labels = ['ssh', 'pl']
|
||||||
|
exec = [
|
||||||
|
'/usr/bin/ssh',
|
||||||
|
'-NT',
|
||||||
|
'-oServerAliveInterval=60',
|
||||||
|
'-oExitOnForwardFailure=yes',
|
||||||
|
'-D',
|
||||||
|
'127.0.0.1:1080',
|
||||||
|
'192.168.0.1', # server address or hostname here
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Start process:
|
||||||
|
```
|
||||||
|
$ pt start ssh-tunnel
|
||||||
|
```
|
||||||
|
|
||||||
|
Show running processes:
|
||||||
|
```
|
||||||
|
$ pt ps
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop `ssh-tunnel`:
|
||||||
|
```
|
||||||
|
$ pt stop ssh-tunnel
|
||||||
|
# OR send signal explicitly
|
||||||
|
$ pt signal TERM ssh-tunnel
|
||||||
|
```
|
||||||
|
@ -11,13 +11,13 @@ _pt_completions()
|
|||||||
;;
|
;;
|
||||||
-l|-label)
|
-l|-label)
|
||||||
if [[ ${COMP_WORDS[*]} =~ start ]]; then
|
if [[ ${COMP_WORDS[*]} =~ start ]]; then
|
||||||
COMPREPLY+=($(compgen -W "$(./pt labels)" -- "$cur"))
|
COMPREPLY+=($(compgen -W "$(pt labels)" -- "$cur"))
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local words=($(./pt ls -o brief) start stop signal)
|
local words=($(pt ls -o brief) start stop signal)
|
||||||
if [[ ${words[*]} =~ $prev ]]; then
|
if [[ ${words[*]} =~ $prev ]]; then
|
||||||
COMPREPLY+=($(compgen -W "$(./pt ls -o brief)" -- "$cur"))
|
COMPREPLY+=($(compgen -W "$(pt ls -o brief)" -- "$cur"))
|
||||||
fi
|
fi
|
||||||
local commands='start stop ls ps help version signal labels'
|
local commands='start stop ls ps help version signal labels'
|
||||||
local invoked=()
|
local invoked=()
|
||||||
|
2
src/em.v
2
src/em.v
@ -19,7 +19,7 @@ fn (em EntryManager) labels() []string {
|
|||||||
for _, val in em.config.entries {
|
for _, val in em.config.entries {
|
||||||
labels << val.labels
|
labels << val.labels
|
||||||
}
|
}
|
||||||
return arrays.uniq(labels)
|
return arrays.uniq(labels.sorted())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (em EntryManager) by_labels(labels []string) []Entry {
|
fn (em EntryManager) by_labels(labels []string) []Entry {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user