{"id":15287836,"url":"https://github.com/fhofherr/hazcld","last_synced_at":"2026-04-14T15:33:02.684Z","repository":{"id":139501250,"uuid":"336812809","full_name":"fhofherr/hazcld","owner":"fhofherr","description":"Check if a process has a certain child","archived":false,"fork":false,"pushed_at":"2021-02-07T15:15:28.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-16T03:17:09.837Z","etag":null,"topics":["golang","linux","neovim","tmux","vim"],"latest_commit_sha":null,"homepage":"","language":"Go","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/fhofherr.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":"2021-02-07T14:55:53.000Z","updated_at":"2024-06-19T09:08:15.263Z","dependencies_parsed_at":"2024-06-19T09:24:16.541Z","dependency_job_id":null,"html_url":"https://github.com/fhofherr/hazcld","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/fhofherr%2Fhazcld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fhofherr%2Fhazcld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fhofherr%2Fhazcld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fhofherr%2Fhazcld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fhofherr","download_url":"https://codeload.github.com/fhofherr/hazcld/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200706,"owners_count":20576674,"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":["golang","linux","neovim","tmux","vim"],"created_at":"2024-09-30T15:38:38.256Z","updated_at":"2026-04-14T15:32:57.650Z","avatar_url":"https://github.com/fhofherr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hazcld - Check if a process has a certain child\n\n`hazcld` is a Linux utility that given a process ID checks if the\ncorresponding process has a child process with the name matching the\npassed regex.\n\nSome tools require this information to determine how to process user\ninteraction.\n[`vim-tmux-navigator`](https://github.com/christoomey/vim-tmux-navigator)\nuses the\n[following](https://github.com/christoomey/vim-tmux-navigator/blob/6a1e58c3ca3bc7acca36c90521b3dfae83b2a602/vim-tmux-navigator.tmux#L5)\nto determine if a tmux pane runs `vim`:\n\n    is_vim=\"ps -o state= -o comm= -t '#{pane_tty}' \\\n        | grep -iqE '^[^TXZ ]+ +(\\\\S+\\\\/)?g?(view|n?vim?x?)(diff)?$'\"\n\nThis however breaks if the pane executes `vim` inside a `poetry shell\nsession`.\n\nThe following shell script would to the trick, but is rather slow:\n\n```bash\n#!/usr/bin/env bash\n\nPATTERN=\"[[:space:]]*g?(view|n?vim?x?)(diff)?\"\n\nfunction find_vim() {\n    local pid\n\n    pid=\"$1\"\n\n    while [[ -n \"$pid\" ]]; do\n        read -r pid cmd \u003c\u003c\u003c\"$(command ps --ppid \"$pid\" -o pid= -o comm=)\"\n        if [[ \"$cmd\" =~ $PATTERN ]]; then\n            return 0\n        fi\n    done\n\n    return 1\n}\n\nfind_vim \"$1\"\n```\n\nThis is an attempt to generalize the above script and make it faster by\nreducing the amount of calls to `ps`.\n\nA short try with the initial draft version looks promising. Please note\nthat this was not a properly planned benchmark. It mainly served to play\naround a little with\n[`hyperfine`](https://github.com/sharkdp/hyperfine):\n\n| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |\n|:---|---:|---:|---:|---:|\n| `./scripts/tmux-pane-runs-vim 2210` | 22.6 ± 1.2 | 21.1 | 26.9 | 5.18 ± 0.76 |\n| `./bin/hazcld '\\s*g?(view\\|n?vim?x?)(diff)?' 2210` | 4.4 ± 0.6 | 3.6 | 6.6 | 1.00 |\n\nAbove table shows the output of\n\n    hyperfine --export-markdown results.md \\\n              --warmup 10 \\\n              \"./scripts/tmux-pane-runs-vim 2210\" \\\n              \"./bin/hazcld '\\s*g?(view|n?vim?x?)(diff)?' 2210\"\n\n## Installation\n\nThe package can be installed using `go get`:\n\n    go get github.com/fhofherr/hazcld\n\n## Usage\n\nCall `hazcld` using a [Go regular\nexpression](https://pkg.go.dev/regexp/syntax) matching the command the\nchild process you are interested in is executing and the process ID of a\nparent process.\n\n    hazcld '\\s*g?(view|n?vim?x?)(diff)?' 2210\n\n### Tmux\n\nThis repository contains a `hazcld_vim.tmux` script which can be used as\na [TPM](https://github.com/tmux-plugins/tpm) tmux plugin.\n\nAdd the following line to your `tmux.conf` and install the\n`christoomey/vim-tmux-navigator` vim plugin.\n\n    set -g @plugin 'fhofherr/hazcld'\n\n## License\n\nCopyright © 2021 Ferdinand Hofherr\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffhofherr%2Fhazcld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffhofherr%2Fhazcld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffhofherr%2Fhazcld/lists"}