{"action":"created","issue":{"url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/2453","repository_url":"https://api.github.com/repos/qutebrowser/qutebrowser","labels_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/2453/labels{/name}","comments_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/2453/comments","events_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/2453/events","html_url":"https://github.com/qutebrowser/qutebrowser/issues/2453","id":214629512,"number":2453,"title":"Edit command using ${editor}","user":{"login":"brianbuccola","id":1738710,"avatar_url":"https://avatars2.githubusercontent.com/u/1738710?v=3","gravatar_id":"","url":"https://api.github.com/users/brianbuccola","html_url":"https://github.com/brianbuccola","followers_url":"https://api.github.com/users/brianbuccola/followers","following_url":"https://api.github.com/users/brianbuccola/following{/other_user}","gists_url":"https://api.github.com/users/brianbuccola/gists{/gist_id}","starred_url":"https://api.github.com/users/brianbuccola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianbuccola/subscriptions","organizations_url":"https://api.github.com/users/brianbuccola/orgs","repos_url":"https://api.github.com/users/brianbuccola/repos","events_url":"https://api.github.com/users/brianbuccola/events{/privacy}","received_events_url":"https://api.github.com/users/brianbuccola/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-16T08:28:14Z","updated_at":"2017-03-16T13:19:15Z","closed_at":null,"body":"**Feature request:** Provide a way to edit the current command using one's `${editor}`, similar to:\r\n\r\n- vim: `c_^F` / `q:`\r\n- bash: `edit-and-execute-command`\r\n- zsh: `edit-command-line`\r\n\r\nQutebrowser already has `edit-url`, which launches `${editor}` to edit a url (default: current url), so this would be similar to that. Call it `edit-command`, for instance.\r\n\r\n**Example 1:**\r\n\r\n- `: <execute some really long command>`\r\n- Get error (e.g. for a `:bind` or `:set`), or realize I used the wrong search engine or forgot some option or whatever.\r\n- `:<C-p>` (go back to previous command)\r\n- `<C-f>` (open command in editor, where `<C-f>` is bound to `edit-command`)\r\n- fix command, save, quit, and execute command\r\n\r\nIn this example, `edit-command` is called in command mode, just like `c_^F` in vim.\r\n\r\n**Example 2:**\r\n\r\n- I have a url in my clipboard, which I want to open in a new tab, but I need to edit the url before opening it.\r\n- `q:` (open editor, where `q:` is bound to `edit-command2`; see below)\r\n- Type `open -t `, paste my url, edit it however I want, save, quit, and execute command\r\n\r\nIn this example, `edit-command2` is called in normal mode, just like `q:` in vim.\r\n\r\nI wrote `edit-command2` to make it clear that it's slightly different from `edit-command`, in the sense that `edit-command` is invoked in command mode, while `edit-command2` is invoked in normal mode (just like `edit-url` currently).\r\n\r\nAlso, I'd be happy even if there were *only* the command-mode version, because example 2 could just as well go like this:\r\n\r\n- `:open -t <paste url>` (but don't execute)\r\n- `<C-f>` (i.e. `<edit-command>`)\r\n- edit the url, save, quit, and execute command\r\n\r\n**Rationale:** The point is that editing a command in vim (or whatever) would be way easier/faster than ctrl-arrowing across words or trying to remember emacs-style shortcuts like `<C-a>` and so on."},"comment":{"url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/comments/287053982","html_url":"https://github.com/qutebrowser/qutebrowser/issues/2453#issuecomment-287053982","issue_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/2453","id":287053982,"user":{"login":"brianbuccola","id":1738710,"avatar_url":"https://avatars2.githubusercontent.com/u/1738710?v=3","gravatar_id":"","url":"https://api.github.com/users/brianbuccola","html_url":"https://github.com/brianbuccola","followers_url":"https://api.github.com/users/brianbuccola/followers","following_url":"https://api.github.com/users/brianbuccola/following{/other_user}","gists_url":"https://api.github.com/users/brianbuccola/gists{/gist_id}","starred_url":"https://api.github.com/users/brianbuccola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianbuccola/subscriptions","organizations_url":"https://api.github.com/users/brianbuccola/orgs","repos_url":"https://api.github.com/users/brianbuccola/repos","events_url":"https://api.github.com/users/brianbuccola/events{/privacy}","received_events_url":"https://api.github.com/users/brianbuccola/received_events","type":"User","site_admin":false},"created_at":"2017-03-16T13:19:15Z","updated_at":"2017-03-16T13:19:15Z","body":"@pkill-nine Here's a slight improvement that puts the command prefix, e.g. `:`, into a variable, then `echo`-es it back. This way, the userscript works not only with regular commands (prefixed by `:`), but also searches, prefixed by `/` or `?`:\r\n\r\n```bash\r\n#!/bin/bash\r\n#\r\n# Edit command-line text. See #2453\r\n# <https://github.com/qutebrowser/qutebrowser/issues/2453>.\r\n# Adapted from @pkill-nine's userscript.\r\n\r\ntrap cleanup EXIT\r\n\r\ncleanup() {\r\n    rm \"$qb_cmd\"\r\n}\r\n\r\nqb_cmd=$(mktemp --tmpdir qutebrowser_XXXXXXXX)\r\ncmd_prefix=$(echo \"$QUTE_COMMANDLINE_TEXT\" | head -c1)\r\necho \"$QUTE_COMMANDLINE_TEXT\" | cut -c 2- > \"$qb_cmd\"\r\nurxvt -e vim -n \"$qb_cmd\"\r\n\r\necho set-cmd-text \"$cmd_prefix$(head -n1 \"$qb_cmd\")\" >> \"$QUTE_FIFO\"\r\n```"}}
{"actor":{"display_login":"brianbuccola"}}