** * This article is for people who use "Jupyter Notebook". ** **
I've been studying statistics, machine learning, etc. for about a week to challenge Kaggle. In the process, I decided to use Jupyter Notebook, but it is very troublesome to hit Jupyter Notebook at the terminal one by one ...
So I set up an alias (like a shortcut) so that I can start ** Jupyter Notebook with just the command "j" **.
The method introduced this time is to edit the configuration file such as .bashrc
or .bash_profile
.
If you don't know about .bashrc
or .bash_profile
, please refer to here.
- What is .bash_profile -. What is bashrc? - Difference between .bashrc and .bash_profile
Also, this time I will use a text editor called vim
that comes standard with Linux and macOS, but don't worry, there are no particularly difficult operations.
.bashrc
and set an aliasEdit the .bashrc
file in your home directory with vim to set the alias.
It seems that some people do not have the .bashrc
file, but if it does not exist, a new one will be created, so don't worry.
$ vim ~/.bashrc #In your home directory.Open bashrc in vim
After opening the .bashrc
file, press ʻi` to enter insert mode. If you do not do this, you will not be able to enter characters.
Once in insert mode, write the following to set an alias.
ʻAlias
The command name you want to set is not a command name that already exists, such as cd
or ls
.
~/.bashrc
alias j='jupyter notebook' #The "j" part can be set freely
After writing, press ʻescto return to normal mode. Once in normal mode, you can type
: wq and press Enter to save
.bashrc` and exit vim.
If vim doesn't quit normally, please refer to this article.
[vim] Forcibly save read only files with sudo
.bashrc
Write the settings in .bash_profile
so that the .bashrc
edited in 1 will be loaded when the terminal is started.
First, open the .bash_profile
file with vim as in 1.
$ vim ~/.bash_profile #In your home directory.bash_Open your profile in vim.
After opening the .bash_profile
file, put it in insert mode and write:
If you do not set this, the settings written in the .bashrc
file will not be reflected when the terminal is started.
~/.bash_profile
if [ -f ~/.bashrc ]; then #if,~/.If you have a bashrc file
source ~/.bashrc # ~/.Reflect the contents of the bashrc file
fi
After writing, use ʻesc to return to normal mode, save with
: wq`, and exit vim.
If this is left as it is, the settings have not been reflected yet because it was only set to read the .bashrc
file when the terminal was started.
Reboot the terminal or run source ~ / .bash_profile
on the terminal for the settings to take effect.
However, in the latter case, it seems that the contents of the .bashrc
file before the change are retained until the terminal is closed, so I think that you can definitely check the changed contents by restarting the terminal as much as possible.
Finally, make sure you have the settings you want.
You can check the command you set by typing it in the terminal, but here I will check it in a smarter way. You can check the currently set alias by entering the command ʻalias` on the terminal.
$ alias #Check the alias that has been set
If the alias you set earlier is output, it is successful.
You can set an alias with a different command in the same way as this time, so if you are interested, please check it out (^ ^)
- Really correct use of .bashrc and .bash_profile - Alias setting for engineers in the world - [For beginners] How to set aliases
Recommended Posts