
Bash 是一个很方便的脚本语言,但是当我们要写复杂的脚本时,考虑到心智负担和可维护性等,我们通常会考虑其他语言,比如 Python 。jb 是一个 Javascript 和 bash 的结合体,bun port of zx 。jb 只是一个独立的二进制文件,所以只需要放到 PATH 里即可,当然用 nami 也可以安装。
https://github.com/txthinking/jb
创建一个 script.js
#!/usr/bin/env jb $`ls -l` var output = $1`whoami` $(`echo ${output}`) chmod +x ./script.js ./script.js jb ./script.js 也可以执行远程脚本
jb https://www.txthinking.com/script.js #!/usr/bin/env jb // 检查 joker ,没有就安装 if(!which('joker')){ cp('https://github.com/txthinking/joker/releases/latest/download/joker_linux_amd64', '/usr/bin/joker') } // 检查 brook ,没有就安装 if(!which('brook')){ cp('https://github.com/txthinking/brook/releases/latest/download/brook_linux_amd64', '/usr/bin/brook') } echo(` 1. 运行 brook server 2. 运行 brook wsserver `) var answer = question(`选择要运行的编号:`) var sub = '' if(answer == 1){ sub = 'server' } if(answer == 2){ sub = 'wsserver' } var port = question(`输入监听的端口:`) var pass = question(`输入一个密码:`) $(`joker brook ${sub} --listen :${port} --password ${pass}`) 1 xiaokongwu 2023-06-08 16:19:24 +08:00 兄弟你这工具名有点秀,以后就是:"你在写什么 jb ?" |
2 penzi 2023-06-08 17:55:33 +08:00 via Android 呃呃,为什么不用 Python 。会写 bash 的人都会写 Python |
3 colom 2023-06-08 19:45:55 +08:00 "你的 jb 不行啊" |
4 cx2ex 2023-06-08 21:49:52 +08:00 via iPhone 装个 jb |
5 Vb374IX98qjj2SgJ 2023-06-09 00:09:39 +08:00 逆天的名字 |
![]() | 6 Al0rid4l 2023-06-09 03:58:02 +08:00 感觉和 https://github.com/google/zx 类似 |
7 tairan2006 2023-06-09 09:40:02 +08:00 其实可以用 python 写完让 gpt 翻译成 bash |
9 julyclyde 2023-06-09 12:46:36 +08:00 啥叫 nami 呀 |
10 thisismr2 OP PRO @Al0rid4l 之前一直在用 zx ,jb 是 zx 的 port 。 好处是不用安装 node 栈,jb 就是一个独立的二进制文件,放到 path 里就可以了 还有就是 zx 需要 await $`ls -l`, jb 不需要 await ,直接 $`ls -l` |
11 thisismr2 OP PRO @julyclyde 一个方便安装命令的工具,比如 ``` bash <(curl https://bash.ooo/nami.sh) ``` ``` nami install joker ``` 安装运行 brook nami install brook joker brook wsserver -l :20000 -p world 安装运行 shadowsocks nami install shadowsocks joker ssserver -m aes-256-gcm -k hello -s 10.138.1.6:30000 -U --udp-timeout 60 --tcp-no-delay 查看 joker list |