SET$EDITOR: Difference between revisions

From CompleteNoobs
Jump to navigation Jump to search
(forgot about bash)
 
Line 2: Line 2:
==Set $EDITOR==
==Set $EDITOR==


In Linux and other Unix-like operating systems, the '''EDITOR''' environment variable specifies the default text editor for command-line operations.
In FreeBSD and other Unix-like operating systems, the '''EDITOR''' environment variable specifies the default text editor for command-line operations.


To set '''EDITOR''' to the '''nano''' text editor, use:
To set '''EDITOR''' to the '''nano''' text editor, use:
Line 18: Line 18:
* For Zsh: '''~/.zshrc'''
* For Zsh: '''~/.zshrc'''


=== Checking, Setting, and Unsetting $EDITOR ===
=== '''SH SHELL''' Checking, Setting, and Unsetting $EDITOR ===
- Check if '''EDITOR''' is already set:
- Check if '''EDITOR''' is already set:
   <code>echo $EDITOR</code>
   <code>echo $EDITOR</code>
Line 27: Line 27:
- Unset the variable:
- Unset the variable:
   <code>unset EDITOR</code>
   <code>unset EDITOR</code>
Once set, you can use:
<code>$EDITOR /home/$USER/somefile.txt</code>
to open files with your chosen editor, in this case, nano.
=== '''BASH SHELL''' Checking, Setting, and Unsetting $EDITOR ===
- Check if '''EDITOR''' is already set:
  <code>echo $EDITOR</code>
- Set the environment variable:
  <code>export EDITOR=nano</code>
- Unset the variable:
  <code>export EDITOR=</code>
* will export/set EDITOR to empty string


Once set, you can use:
Once set, you can use:
<code>$EDITOR /home/$USER/somefile.txt</code>
<code>$EDITOR /home/$USER/somefile.txt</code>
to open files with your chosen editor, in this case, nano.
to open files with your chosen editor, in this case, nano.

Latest revision as of 22:08, 16 February 2025

Set $EDITOR

In FreeBSD and other Unix-like operating systems, the EDITOR environment variable specifies the default text editor for command-line operations.

To set EDITOR to the nano text editor, use: set EDITOR=nano This ensures that commands or programs needing a text editor, like git commit, will use nano by default.

Nano is appreciated for its simplicity and user-friendly interface, making it ideal for beginners.

Setting EDITOR to nano can be beneficial for:

  • Users preferring nano over other editors like vi or emacs.
  • Those new to Linux.

To make this setting persistent across sessions, add the command to your shell startup file:

  • For Bash: ~/.bashrc
  • For Zsh: ~/.zshrc

SH SHELL Checking, Setting, and Unsetting $EDITOR

- Check if EDITOR is already set:

 echo $EDITOR

- Set the environment variable:

 set EDITOR=nano

- Unset the variable:

 unset EDITOR

Once set, you can use: $EDITOR /home/$USER/somefile.txt to open files with your chosen editor, in this case, nano.

BASH SHELL Checking, Setting, and Unsetting $EDITOR

- Check if EDITOR is already set:

 echo $EDITOR

- Set the environment variable:

 export EDITOR=nano

- Unset the variable:

 export EDITOR=
  • will export/set EDITOR to empty string

Once set, you can use: $EDITOR /home/$USER/somefile.txt to open files with your chosen editor, in this case, nano.