{"id":19084050,"url":"https://github.com/xpmo/zsh-toggle-command-prefix","last_synced_at":"2025-07-03T21:33:45.698Z","repository":{"id":130353828,"uuid":"236634004","full_name":"xPMo/zsh-toggle-command-prefix","owner":"xPMo","description":"Zsh widget to toggle a prefix on a command","archived":false,"fork":false,"pushed_at":"2023-02-28T21:46:16.000Z","size":29,"stargazers_count":20,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-19T03:03:12.162Z","etag":null,"topics":["sudo","zsh-plugin","zsh-widget"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/xPMo.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}},"created_at":"2020-01-28T01:26:43.000Z","updated_at":"2024-05-26T21:15:55.000Z","dependencies_parsed_at":"2023-07-04T20:46:18.354Z","dependency_job_id":null,"html_url":"https://github.com/xPMo/zsh-toggle-command-prefix","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xPMo%2Fzsh-toggle-command-prefix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xPMo%2Fzsh-toggle-command-prefix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xPMo%2Fzsh-toggle-command-prefix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xPMo%2Fzsh-toggle-command-prefix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xPMo","download_url":"https://codeload.github.com/xPMo/zsh-toggle-command-prefix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223780069,"owners_count":17201287,"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":["sudo","zsh-plugin","zsh-widget"],"created_at":"2024-11-09T02:49:56.593Z","updated_at":"2024-11-09T02:49:56.676Z","avatar_url":"https://github.com/xPMo.png","language":"Shell","readme":"# Toggle Command Prefix\n\n_A Zsh widget to toggle a prefix on a command_\n\nBy default, this will set \"Alt+s\" to toggle `sudo ` on a command.\n\nIn its current state, it uses `split-shell-arguments`\nto divide up the buffer, and looks for newlines,\n`;`/`\u0026\u0026`/`||`/`|`,\nfollowed optionally by `if`/`else`/`while`/etc.\n\nThis method should avoid any false positives,\nbut it will also ignore `$(command substitutions)`.\n\nThis project also makes use of all `sudo` flags\nknown by the completion function `_sudo`\nand deletes them and their arguments if found as well.\nFor example,\n`sudo -uuser -g group --shell foo bar` will be replaced by\n`foo bar`, since `-u` and `-g` take arguments,\nwhile `--shell` does not.\n\n## Default widgets:\n\n|Widget | Binding | Prefix Inserted | Prefix Matched |\n| --- | --- | --- | --- |\n| `toggle-sudo` | Alt-s | `sudo ` | `sudo` followed by any number of supported flags known by `_sudo` completion |\n| `toggle-noglob` | Alt-g | `noglob ` | `noglob` |\n| `toggle-nocorrect` | _(not bound)_| `nocorrect ` | `nocorrect` |\n| `toggle-command` | Alt-Shift-c | `command ` | `command` |\n\n## Examples:\n\nLaunch a command with `i3-msg` instead of in the current session.\n\n```zsh\n.toggle-i3exec(){\n\t.toggle-command-prefix 'i3-msg -- exec -- ' 'i3-msg' '(--|exec)'\n}\nzle -N .toggle-i3exec\nbindkey '^[i' .toggle-i3exec\n```\n\nLaunch a command with `nice`\n\n```zsh\n.toggle-nice(){\n\t.toggle-command-prefix 'nice -n10 ' 'nice' '(-n?|--adjustment=)*' '(-n|--adjustment)'\n}\nzle -N .toggle-nice\nbindkey '^[n' .toggle-nice\n```\n\n## Configuration\n\nToggle-command-prefix uses `zstyle` settings to control certain behavior.\n\n### CUTBUFFER\n\nIf a command is found and removed, the following lookup is done:\n\n```zsh\nzstyle -t :zle:toggle-command-prefix:${removed_text} copy\n```\n\nIf the lookup returns true,\nthen the remove text is also yanked into the cut buffer for later pasting.\n\nYou can use this like so:\n\n```zsh\n# copy by default\nzstyle ':zle:toggle-command-prefix:*' copy true\n# don't copy sudo by itself\nzstyle ':zle:toggle-command-prefix:sudo ' copy false\n# copy sudo followed by any number of other matched flags\nzstyle ':zle:toggle-command-prefix:sudo -*' copy true\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpmo%2Fzsh-toggle-command-prefix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpmo%2Fzsh-toggle-command-prefix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpmo%2Fzsh-toggle-command-prefix/lists"}