How to instantly launch Jupyter Notebook from the terminal

Introduction

** * 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" **.

Prerequisite knowledge

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.

Setting method

1. Edit .bashrc and set an alias

Edit 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

2. Set to read .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.

3. Check if the settings are complete

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 (^ ^)

reference

- Really correct use of .bashrc and .bash_profile - Alias setting for engineers in the world - [For beginners] How to set aliases

Recommended Posts

How to instantly launch Jupyter Notebook from the terminal
How to measure line speed from the terminal
How to use Jupyter Notebook
How to launch Explorer from WSL
How to see the contents of the Jupyter notebook ipynb file
How to execute commands in jupyter notebook
How to use jupyter notebook with ABCI
How to operate Linux from the console
Jupyter Notebook Basics of how to use
How to access the Datastore from the outside
How to use Jupyter notebook [Super Basic]
How to specify the launch browser for JupyterLab 3.0.0
How to debug with Jupyter or iPython Notebook
How to operate Linux from the outside Procedure
How to Git from GCP's Jupyter Lab to GSR
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
How to make the font width of jupyter notebook put in pyenv equal width
[Python] How to remove duplicate values from the list
Next to Excel, for the time being, jupyter notebook
How to post a ticket from the Shogun API
How to view progress bar on Jupyter Notebook to see progress
[IPython] How to Share IPython Notebook
How to use the generator
How to change Jupyter layout
How to hack a terminal
Launch the IPython notebook server
How to use the decorator
How to increase the axis
How to start the program
How to launch AWS Batch from a python client app
How to do the initial setup from Django project creation
How to hit NAPALM from the Web (NetDevOpsSec reality solution)
The usual way to add a Kernel with Jupyter Notebook
Connect the Jupyter Notebook kernel to Spyder with Jupytext enabled
How to import NoteBook as a module in Jupyter (IPython)
How to deal with the phenomenon that Python (Jupyter notebook) executed on WSL becomes Aborted
A simple way to launch Jupyter Notebook / Lab and set a password
How to calculate the autocorrelation coefficient
How to batch start a python program created with Jupyter notebook
How to use the zip function
How to use SWIG from waf
How to resolve ModuleNotFoundError: No module named XXX in Jupyter Notebook
How to get followers and followers from python using the Mastodon API
How to touch Jupyter Notebook without polluting the environment other than Pythonista, or how to touch Ruby with Jupyter Notebook without polluting the environment other than Rubyist
How to read the SNLI dataset
How to get the Python version
Simply view the Jupyter notebook file
How to use jupyter notebook without polluting your environment with Docker
[Python] How to import the library
How to extract the desired character string from a line 4 commands
How to use Jupyter on the front end of supercomputer ITO
Terminal association from the server side to Amazon SNS (python + boto3)
Launch jupyter notebook (+ take security measures)
How to resolve the error from toimage (from PIL.Image import fromarray as toimage)
Easy to use Jupyter notebook (Python3.5)
How to overwrite the output to the console
How to access wikipedia from python
How to convert from .mgz to .nii.gz
How to use the ConfigParser module
From the introduction of GoogleCloudPlatform Natural Language API to how to use it
How to check local GAE from iPhone browser in the same LAN