{"id":18573332,"url":"https://github.com/huawenyu/vimux-script","last_synced_at":"2025-05-15T23:13:34.164Z","repository":{"id":79661014,"uuid":"48389330","full_name":"huawenyu/vimux-script","owner":"huawenyu","description":"Vim+Tmux+vimux-script: like tcl.expect, but using vimux-script as programmed dialogue with interactive tmux. Base on benmills/vimux.","archived":false,"fork":false,"pushed_at":"2021-10-28T07:38:55.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T23:13:29.955Z","etag":null,"topics":["gdb","tmux","vim"],"latest_commit_sha":null,"homepage":"","language":"Vim script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huawenyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-21T19:11:03.000Z","updated_at":"2021-10-28T07:38:58.000Z","dependencies_parsed_at":"2023-05-14T07:30:15.781Z","dependency_job_id":null,"html_url":"https://github.com/huawenyu/vimux-script","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huawenyu%2Fvimux-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huawenyu%2Fvimux-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huawenyu%2Fvimux-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huawenyu%2Fvimux-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huawenyu","download_url":"https://codeload.github.com/huawenyu/vimux-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436950,"owners_count":22070949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gdb","tmux","vim"],"created_at":"2024-11-06T23:08:59.872Z","updated_at":"2025-05-15T23:13:34.138Z","avatar_url":"https://github.com/huawenyu.png","language":"Vim script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vimux-script\n\nVim + Tmux + the-plug: use vim as tmux controller, and vimux-script language interact with tmux from vim.\nThis plugin is base on [vimux](https://github.com/benmills/vimux), a plugin that lets you send input to tmux.\n\nThe vim plug is to make auto interact with terminal through tmux.\n\n## Quickstart\n\nPut the cursor in the region of script, which begin-with `{{{#` and end-with `}}}` like the sample,\nthen `:call vimuxscript#CallRegion(1)`.\nFor example, simulate top:\n\n```sh\ntop {{{1\n    ## Put cursor in this region, then :call vimuxscript#CallRegion(1)\n    ##\n    ## comment by beginwith two '##'\n    ## Inner command begeinwith '@'\n    ## @attach  Interact with tmux current window pane 2, like: @attach [\u003cwindow\u003e.]pane\n    ##          2.3    the tmux window-2, pane-3\n    @attach 2\n\n\t@vimbegin\n\tlet num = 1\n\twhile num \u003c= 20\n\t\tlet num += 1\n\t\tcall VimSend('top -bn1 | head')\n        sleep 1\n        redraw\n\tendwhile\n\t@vimend\n}}}\n```\n\n```sh\ngetstatus {{{1\n    @attach 2\n    telnet 10.1.1.125\n\n    ## user:admin, and password is empty\n    admin\n    \u003cEnter\u003e\n\n    ## the embedded box's command\n    ## ls -lart\n    get system status\n}}}\n```\n\n## Install\n\n- Install this vim plug\n```vim\n    \" With **[vim-plug](https://github.com/junegunn/vim-plug)**, add to your `.vimrc`:\n    Plug 'huawenyu/vimux-script'\n```\n- Only worker under tmux (version \u003e 1.5)\n  \u003e Auto send the script text to tmux another pane`\n\n## Usage\n\nThe more example is available [online](https://raw.github.com/huawenyu/vimux-script/master/example.txt).\n### Prerequirement\nFirstly, we should use tmux to get 4 panes in current terminal screen. So we have pane number 1,2,3,4,  \nIf together with the windows number, we have pane like: 1.1, 1.2, 1.3, 1.4\n\n### Execute The Selected Lines\n\n1. use vim open a text file\n2. attach current vim to another tmux's pane by the pane's number\n```\n       :VimuxAttach \u003ctab\u003e\n```\n\n### Sample to decode gdb call backtrace\n\nWe have a calltrace file `calltrace.txt` and the bin file `a.out`, and want to send gdb to decode the the backtrace automatically.\n\n1. Open tmux window, then create two panes:\n- the 1st pane: vim calltrace.txt\n- the 2nd pane: gdb a.out\n\n2. Using @begin, @end to define the script region\nSetting it in the default `scriptinit` group, like:\n```python\nscriptinit {{{1\n@begin Call Trace:\n@end Detaching from target\n}}}\n```\n\n3. Change `[\u003c00007f2f035a89d7\u003e]` to `l *0x00007f2f035a89d7`\nAdd a match-then-do-macro to change the script text line to the default `scriptinit` group:\n\n```python\nscriptinit {{{1\n@match \"^[\" =\u003e \"0xx$xx0il *0x\"\n}}}\n```\n\n4. Finally our text script like this:\n\n    $ cat ./calltrace.txt\n\n```python\nscriptinit {{{1\n@begin Call Trace:\n@end Detaching from target\n@begin_cmd #----------------------------------\n@begin_cmd \u003cEnter\u003e\n@begin_cmd set listsize 3\n@end_cmd   #==================================\n@end_cmd \u003cEnter\u003e\n@match \"^[\" =\u003e \"0xx$xx0il *0x\"\n}}}\n\nAttaching to the target process...\nWaiting for target process to stop...\nTarget process attached\nRegister dump:\nPid: 6432\nrip: 0033:[\u003c00007f2f035a89d7\u003e]\nrsp: 002b:00007fffece6d468  eflags: 00000246\nrax: 0000000000000000 rbx: 0000000000001000 rcx: ffffffffffffffff\nrdx: 0000000000000ff4 rsi: 0000000000001000 rdi: 00007f2e8a506000\nrbp: 00007fffece6d490 r08: 00007f2f05370e30 r09: 0000000000000000\nr10: 00007fffece6d4ac r11: 0000000000000246 r12: 00007f2e8a506000\nr13: 0000000000000000 r14: 0000000000000000 r15: 00007f2e8b675688\nCall Trace:\n[\u003c00007f2f035a89d7\u003e]\n[\u003c00000000017da808\u003e]\n[\u003c00000000018f1194\u003e]\n[\u003c00000000018fbf36\u003e]\n[\u003c00000000018f5ccc\u003e]\n[\u003c000000000175114f\u003e]\n[\u003c00000000018f5e3a\u003e]\n[\u003c00000000018f8369\u003e]\n[\u003c000000000188022a\u003e]\n[\u003c000000000190d6a6\u003e]\n[\u003c0000000000448b18\u003e]\n[\u003c000000000044f4f1\u003e]\n[\u003c00007f2f034d9eaa\u003e]\n[\u003c0000000000444e5a\u003e]\nDetaching from target...\nTarget detached\n```\n\n5. Put our cursor beteween the `Call Trace` and `Detaching from target`,\n   then `:call vimuxscript#CallRegion(1)`\n\n\n### Execute Group By Name\n\n1. use vim open a script like this which must begin-with `{{{#` and end-with `}}}`:\n```\nscriptinit {{{1\n\t@vim let w:pane_log = '1.4'\n\t@vim let w:pane_box = '1.3'\n\t@vim let w:pane_gdb = '1.4'\n}}}\n\nreadcrash {{{1\n\t@label check_crash_again\n\n\t@attach $\u003cw:pane_box\u003e\n\tdiagnose ourapp  3130\n\n\t@attach $\u003cw:pane_gdb\u003e\n\tcurl -4 -x 10.1.100.150:8080 www.tired.com\n\n\t@attach $\u003cw:pane_log\u003e\n\tdiagnose crash get\n\n\t@goto check_crash_again\n}}}\n```\n2. In vim, put our cusor on `decode_debug_acsm_crash` which is the script group's name\n3. Then :call vimuxscript#ExecuteGroup()\n4. If the script have variable like `$\u003cw:pane_box\u003e`, it will auto search the `scriptinit` group.\n\n### vim Shortkeys\n```\n  vmap \u003csilent\u003e \u003cleader\u003eee  :\u003cc-u\u003ecall vimuxscript#ExecuteSelection(1)\u003cCR\u003e\n  nmap \u003csilent\u003e \u003cleader\u003eee  :\u003cc-u\u003ecall vimuxscript#ExecuteSelection(0)\u003cCR\u003e\n  nmap \u003csilent\u003e \u003cleader\u003eeg  :\u003cc-u\u003ecall vimuxscript#ExecuteGroup()\u003cCR\u003e\n```\n\n## Debug\nlet let g:decho_enable = 1\n\n## Todo lists\n\n- [x] Attach tmux.windows mode\n- [x] Auto 'scriptinit' per script files\n- [ ] Add \u003cfile\u003e\n- [ ] Script: decode crash log\n- [ ] AsyncCommand Implement\n  - [ ] grep\n  - [ ] make\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuawenyu%2Fvimux-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuawenyu%2Fvimux-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuawenyu%2Fvimux-script/lists"}