Skip to content

Latest commit

 

History

History
80 lines (51 loc) · 2.31 KB

cllqr2gnc00x1fxnv67ka69h8.md

File metadata and controls

80 lines (51 loc) · 2.31 KB
title seoTitle seoDescription datePublished cuid slug cover
Efficient Way to Invoke All Editors in Git Bash on Windows
Invoke all Editors in Git Bash on Windows
How to efficiently invoke all Editors in Git Bash on Windows
Fri Dec 30 2022 17:29:33 GMT+0000 (Coordinated Universal Time)
cllqr2gnc00x1fxnv67ka69h8
efficient-way-to-invoke-all-editors-in-git-bash-on-windows

Just kidding, it works on all OS as well. Just configure the correct directory upon setting this method.

Vim comes as a package when installing Git even though you choose another text editor during installation.

You invoke vim as vi <filename> in Git Bash CLI.

Short and sweet. What about the other editors?

  1. For GNU nano: nano <filename>

  2. For Notepad: notepad <filename>

  3. For Notepad++: start notepad++ <filename>

  4. For <your favorite editor>: start <your favourite editor> <filename>

Isn't very efficient it seems. You can however change the main editor via git config. But only one main editor is allowed at once.

Worry not, here's an efficient way around it to use all editors in Git Bash:

Add Permanent Alias in Git Bash

Run Git Bash as administrator.

Open aliases.sh

$ cd /etc/profile.d
$ vi aliases.sh

Add alias in aliases.sh. For example, we add npp as an alias for Notepad++:

# --show-control-chars: help showing Korean or accented characters
alias ls='ls -F --color=auto --show-control-chars'
alias ll='ls -l'
alias npp='/c/Program\ Files/Notepad++/notepad++.exe'

p/s: Use \ to escape spaces in the directory.

Add as many other editors as you like in the aliases.sh file. Just follow the format:

alias <YourAlias>='/YourProgramDirectory/YourEditor.exe'

Save the settings, close Git Bash and reopen it to activate the new configuration. Voila!

If it does not activate by chances in the future, source it and it will be activated again:

$ cd /etc/profile.d
$ source aliases.sh

As a bonus, this method also works to add any Linux commands as aliases too. For example, instead of clear, you can alias it as cls.

cls=`clear`

That's it folks, Happy days!

So what is your favorite editor? Comment down below.

Cheers!