Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to specify a default editor for use with `gh` #308

Open
jsjoeio opened this issue Feb 5, 2020 · 11 comments
Open

Document how to specify a default editor for use with `gh` #308

jsjoeio opened this issue Feb 5, 2020 · 11 comments
Labels

Comments

@jsjoeio
Copy link

@jsjoeio jsjoeio commented Feb 5, 2020

Describe the feature or problem you鈥檇 like to solve

I used gh pr create (surprised that it defaulted to open my PR from a fork into the upstream repo - it was awesome馃ぉ) and when I went to edit the PR body, it defaulted to nano but I'd prefer it to use vim.

Proposed solution

  1. When a user first install gh prompt them to choose a default editor:
  • nano
  • vim
  1. Let a user specify editor
gh set-editor vim

How will it benefit CLI and its users?

  • it will support nano and vim users 鉂わ笍

Additional context

N/A

@gchiam

This comment has been minimized.

Copy link

@gchiam gchiam commented Feb 5, 2020

we can set the EDITOR environment variable to vim, see

if e := os.Getenv("EDITOR"); e != "" {
editor = e
}

@vilmibm

This comment has been minimized.

Copy link
Collaborator

@vilmibm vilmibm commented Feb 5, 2020

Currently our hope is users set EDITOR in their environment (I use and <3 vim and that's what I do for pr create); we default to nano in the hope that it would be less surprising for people new to editing on the terminal.

That said, I think this issue highlights that we should be explicitly documenting use of EDITOR and should call it out:

  • in the README or similarly visible place
  • in the help output for gh pr create and gh issue create
@vilmibm vilmibm added the docs label Feb 5, 2020
@vilmibm vilmibm changed the title Add support for vim during `gh pr create` Make it clear how to use vim with gh during command line editing Feb 5, 2020
@ArangoGutierrez

This comment has been minimized.

Copy link

@ArangoGutierrez ArangoGutierrez commented Feb 5, 2020

nano is not default installed in some distros, vi/vim is more a default than vi/vim for developers, we should move nano --> vi/vim

@ArangoGutierrez

This comment has been minimized.

Copy link

@ArangoGutierrez ArangoGutierrez commented Feb 5, 2020

I would like to set EDITOR on my .bashrc but got thinking is way to generic, it may be more app specific something like GH_EDITOR you never know if other app is looking for the same ENV VAR. and is better to track your ENV's (I have way to much now and is hard to know why they are there)

@sarpik

This comment has been minimized.

Copy link

@sarpik sarpik commented Feb 6, 2020

@ArangoGutierrez

nano is not default installed in some distros, vi/vim is more a default than vi/vim for developers, we should move nano --> vi/vim

Yeah that's true & I'm myself a strong vim user, but users might very likely get stuck if they're new to vi/vim, as mentioned be @vilmibm, & I think that the default here is good.

@gabeguz

This comment has been minimized.

Copy link

@gabeguz gabeguz commented Feb 7, 2020

I think it would make most sense to honour GIT_EDITOR since that is likely what people will have set if they are already using vim for editing git commit messages. Using VISUAL and EDITOR can have other non-desired side effects, for example causing bash to work in vi mode instead of emacs mode. What I generally do is look for: GIT_EDITOR then VISUAL then EDITOR in that order, and if none of those are set, use a sane default. https://www.git-scm.com/book/en/v2/Git-Internals-Environment-Variables

@ArangoGutierrez

This comment has been minimized.

Copy link

@ArangoGutierrez ArangoGutierrez commented Feb 7, 2020

++ to @gabeguz idea

@ahmedelgabri

This comment has been minimized.

Copy link
Contributor

@ahmedelgabri ahmedelgabri commented Feb 7, 2020

@billygriffin

This comment has been minimized.

Copy link
Contributor

@billygriffin billygriffin commented Feb 7, 2020

@jsjoeio I'm curious if @ahmedelgabri's fix in #329 properly satisfies your use case, or if you think an explicit way to set the editor in gh would still be an important piece. It strikes me as something that might be useful down the road, but given that you can specify your preferred default in your environment, I'm inclined to think we should wait for more feedback on this before pursuing something with more UX around it and that maybe #329 should close this issue for now. Thoughts?

@jsjoeio

This comment has been minimized.

Copy link
Author

@jsjoeio jsjoeio commented Feb 7, 2020

@billygriffin I think that makes sense. I agree with his point (I've already set that to vim) and I assume most people will too so I think that fulfills my case.

Although, I do believe documentation is super important so it would be a good idea to document how it works (so people don't have to dig through issues/prs/code to see implementation).

Don't know if that should fall under this issue or be a separate issue. Feel free to close this if you think we're good!

@billygriffin billygriffin changed the title Make it clear how to use vim with gh during command line editing Document how to specify a default editor for use with `gh` Feb 7, 2020
@billygriffin

This comment has been minimized.

Copy link
Contributor

@billygriffin billygriffin commented Feb 7, 2020

I like the distinction you drew, thanks @jsjoeio. I updated the title to clarify that this is purely a documentation task. Thanks a bunch for your feedback thus far, it's been really helpful - and thanks @ahmedelgabri for such a quick PR to improve things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can鈥檛 perform that action at this time.