gitui icon indicating copy to clipboard operation
gitui copied to clipboard

Change editor

Open Talleyrand-34 opened this issue 3 years ago • 9 comments

I want to cheange the text editor.

A option to change the editor, on one hand it could be a conf in .config/gitui/config.toml or add a (hidden) settings tab to modify what it is neccesary for the user.

What is your opinion about this? Do i miss something?

Talleyrand-34 avatar Jan 03 '23 16:01 Talleyrand-34

you can set these env: GIT_EDITOR, VISUAL, EDITOR let me know if that works for you

extrawurst avatar Jan 03 '23 17:01 extrawurst

Great! Set export EDITOR=nvim works for me.

justrico avatar Feb 01 '23 14:02 justrico

(change nano with any other editor you have installed)

If you want to change the default editor for all applications started from the shell (not just gitui) change the EDITOR environment variable

# set EDITOR environment variable for the current shell session and all his children
export EDITOR="nano"

# set EDITOR environment variable for all new shell sessions (this command also automatically detects the shell type currently in use and appends to its respective rc file)
echo EDITOR="nano" >> \~/.$(ps --quick-pid $$ -o comm=)rc

If you instead want to change the default editor only for git and gitui change the GIT_EDITOR environment variable

# set GIT_EDITOR environment variable for the current shell session and all his children
export GIT_EDITOR="nano"

# set GIT_EDITOR environment variable for all new shell sessions (this command also automatically detects the shell type currently in use and appends to its respective rc file)
echo GIT_EDITOR="nano" >> \~/.$(ps --quick-pid $$ -o comm=)rc

A note on echo EDITOR​=​"nano" >> ~/.$(ps --quick-pid $$ -o comm​=​)rc (the same exact thing applies to the GIT_EDITOR variant)

  • echo "test" >> test.txt makes it so the string “test” gets appended to the “test.txt” file
  • echo $$ prints out the current shell PID (it’s contained in the $$ variable)
  • ps --quick-pid $$ lists the name of the process with the specified PID (the current shell process in this example)
  • ps -o comm= lists the current processes by only outputting their process names and no additional information
  • ps --quick-pid $$ -o comm​=​ lists the current shell process name
  • ~/.$(ps --quick-pid $$ -o comm​=​)rc gets evaluated to “~/.” + current shell process name + “rc” For example if the current shell process name is “bash” the evaluated string is “~/.bashrc”, if instead it’s “zsh” it gets evaluated to “~/.zshrc”
  • echo EDITOR​=​"nano" >> ~/.$(ps --quick-pid $$ -o comm​=​)rc writes the string ‘EDITOR=”nano”’ to the “rc” file that corrisponds to the current in use shell name

creeloper27 avatar Mar 16 '23 16:03 creeloper27

failed to launch editor: ┃ │ │ ┃"vi": No such file or directory (os error 2)

mine .bashrc is

~/.bashrc

export EDITOR=nano

Add rbenv

export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"

Add depot_toolsforchromiumdev

export PATH="$PATH:/path/to/depot_tools"

Add NVM

[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm" source /usr/share/nvm/nvm.sh source /usr/share/nvm/bash_completion source /usr/share/nvm/install-nvm-exec

If not running interactively, don't do anything

[[ $- != i ]] && return

alias ls='ls --color=auto'

PS1='[\u@\h \W]$ '

source /usr/share/nvm/init-nvm.sh export LD_LIBRARY_PATH=/usr/local/lib

Created by pipx on 2023-05-04 14:36:15

export PATH="$PATH:/home/ui/.local/bin"

export PATH=$PATH:~/.roswell/bin

overtube avatar May 30 '23 07:05 overtube

so, what I can do for change default editor to NANO? on another tools and another cli projects all works well and nano is default editor. also that error (os error 2) mean maybe No such file or directory;

overtube avatar May 30 '23 07:05 overtube

also ur tool is great, and work fast and perfect

overtube avatar May 30 '23 07:05 overtube

failed to launch editor: ┃ │ │ ┃"vi": No such file or directory (os error 2)

mine .bashrc is

~/.bashrc

export EDITOR=nano

Add rbenv

export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"

Add depot_toolsforchromiumdev

export PATH="$PATH:/path/to/depot_tools"

Add NVM

[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm" source /usr/share/nvm/nvm.sh source /usr/share/nvm/bash_completion source /usr/share/nvm/install-nvm-exec

If not running interactively, don't do anything

[[ $- != i ]] && return

alias ls='ls --color=auto'

PS1='[\u@\h \W]$ '

source /usr/share/nvm/init-nvm.sh export LD_LIBRARY_PATH=/usr/local/lib

Created by pipx on 2023-05-04 14:36:15

export PATH="$PATH:/home/ui/.local/bin"

export PATH=$PATH:~/.roswell/bin

Put you code like this next time

``` CODE ```

so that it renders properly in the comment (see: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting)

On top of my mind if you get that error it could be a few things:

  • did you edit ~/.bashrc (the one in your home) or another .bashrc somewhere else? check by running cat ~/.bashrc if it's the same file you posted before
  • are you using bash or another shell? check by running ps --quick-pid $$ -o comm= if you are running bash or another shell (in case you are running another shell use my updated answer on top to add the line to the correct configuration file
  • check if the EDITOR variable is actually set before running gitui check by running env | grep EDITOR

creeloper27 avatar Jun 03 '23 12:06 creeloper27

Glad Thanks! now all is work, awesome, great!

overtube avatar Jun 08 '23 19:06 overtube

This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 15 '23 06:12 stale[bot]

seems fixed

extrawurst avatar Feb 27 '24 14:02 extrawurst