Skip to content

Instantly share code, notes, and snippets.

@theTonyHo
Last active October 8, 2019 04:20
Show Gist options
  • Save theTonyHo/301bf78b5d62885474e7ee1ad19524d7 to your computer and use it in GitHub Desktop.
Save theTonyHo/301bf78b5d62885474e7ee1ad19524d7 to your computer and use it in GitHub Desktop.
Install custom.css to Jupyter Notebook
/* Hide relevant elements */
#header, #menubar-container, div.input, div.run_this_cell, div.prompt {
display: none;
}
/* Output to expand to 100% if div.run_this_cell is hidden */
div.output_subarea {
max-width: 100%;
}
Display the source blob
Display the rendered blob
Raw
import os
import shutil
import jupyter_core
filename = 'custom.css'
file = os.path.join(os.path.abspath('.'), filename)
if os.path.isfile(file) :
targetFile = os.path.join(jupyter_core.paths.jupyter_config_dir() + "/custom", filename)
# print("remove(\"{}\")".format(targetFile))
# print("move(\"{}\", \"{}\")".format(file, targetFile))
if os.path.isfile(targetFile):
rc = os.remove(targetFile)
if not os.path.isdir(os.path.dirname(targetFile)):
# Creating directory if not already exists
os.makedirs(os.path.dirname(targetFile), mode=0o777, exist_ok=True)
rc = shutil.copy2(file, targetFile)
if rc:
print("Successfully copied {} -> {}".format(file, targetFile))
print(os.path.isfile('/home/jovyan/.jupyter/custom/custom.css'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment