├── MANIFEST.in ├── img └── colabshell.PNG ├── CHANGELOG.md ├── setup.py ├── html ├── colab-shell.html ├── jquery.terminal.min.css └── jquery.terminal.min.js ├── google_colab_shell └── __init__.py ├── .gitignore ├── Google_Colab_Shell.ipynb ├── README.md └── LICENSE /MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include *.txt *.py *.md -------------------------------------------------------------------------------- /img/colabshell.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singhsidhukuldeep/Google-Colab-Shell/HEAD/img/colabshell.PNG -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGE LOG 2 | ============================== 3 | 4 | 0.2 (31/12/2021) 5 | ------------------------ 6 | - Fixed documentation 7 | 8 | 0.1 (31/12/2021) 9 | ------------------------ 10 | - Released first version(stable) of colab-shell. -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env python3 2 | # coding:utf-8 3 | """ 4 | Name : setup.py 5 | Author : Kuldeep Singh Sidhu 6 | GitHub : https://github.com/singhsidhukuldeep 7 | Description: Used to setup and publish 8 | """ 9 | 10 | from setuptools import setup, find_packages 11 | 12 | classifiers = [ 13 | "Development Status :: 5 - Production/Stable", 14 | "Intended Audience :: Education", 15 | "Programming Language :: Python :: 3", 16 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 17 | "Programming Language :: Python", 18 | ] 19 | 20 | setup( 21 | name="google-colab-shell", 22 | version="0.2", 23 | description="An efficent python package to launch terminal in Google Colab", 24 | long_description=open("README.md").read() 25 | + "\n\n" 26 | + open("CHANGELOG.md").read() 27 | + "\n\nRead more at https://github.com/singhsidhukuldeep/Google-Colab-Shell", 28 | long_description_content_type="text/markdown", 29 | url="https://github.com/singhsidhukuldeep/Google-Colab-Shell", 30 | author="Kuldeep Singh Sidhu", 31 | author_email="singhsidhukuldeep@gmail.com", 32 | classifiers=classifiers, 33 | keywords="Google Colab Shell Terminal", 34 | packages=find_packages(), 35 | install_requires=[], 36 | zip_safe=False, 37 | ) -------------------------------------------------------------------------------- /html/colab-shell.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 32 | -------------------------------------------------------------------------------- /google_colab_shell/__init__.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env python3 2 | # coding:utf-8 3 | """ 4 | Name : __init__.py 5 | Author : Kuldeep Singh Sidhu 6 | GitHub : https://github.com/singhsidhukuldeep 7 | Description: 8 | """ 9 | 10 | from IPython.display import JSON, HTML, IFrame 11 | from google.colab import output 12 | from subprocess import getoutput 13 | import os 14 | import urllib.request 15 | 16 | html_code_url = "https://raw.githubusercontent.com/singhsidhukuldeep/Google-Colab-Shell/master/html/colab-shell.html" 17 | 18 | 19 | def _run_once(f): 20 | def wrapper(*args, **kwargs): 21 | if not wrapper.has_run: 22 | wrapper.has_run = True 23 | return f(*args, **kwargs) 24 | 25 | wrapper.has_run = False 26 | return wrapper 27 | 28 | 29 | @_run_once 30 | def __get_html_code(html_code_url=html_code_url): 31 | fp = urllib.request.urlopen(html_code_url) 32 | mybytes = fp.read() 33 | 34 | html_code = mybytes.decode("utf8") 35 | fp.close() 36 | return html_code 37 | 38 | 39 | def __shell(command): 40 | if command.startswith("cd"): 41 | path = command.strip().split(maxsplit=1)[1] 42 | os.chdir(path) 43 | return JSON([""]) 44 | return JSON([getoutput(command)]) 45 | 46 | 47 | output.register_callback("shell", __shell) 48 | 49 | 50 | def getshell(height=400, html_code=__get_html_code()): 51 | """ 52 | Displays a terminal for Google Colab. <3 Google 53 | 54 | Make sure this is the last command in the cell. 55 | 56 | Parameters 57 | ---------- 58 | height : int, default 400 59 | height of the rendered terminal 60 | 61 | Returns 62 | ------- 63 | IPython.display.HTML 64 | Displays the terminal 65 | 66 | Examples 67 | -------- 68 | >>> getshell() 69 | 70 | >>> getshell(height=400) 71 | """ 72 | 73 | html_code = html_code.replace("$$height$$", str(height)) 74 | return HTML(html_code) 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /Google_Colab_Shell.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Google-Colab-Shell", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyN8nPg8PHEe4kRz3hmCwjDj", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | }, 18 | "accelerator": "GPU" 19 | }, 20 | "cells": [ 21 | { 22 | "cell_type": "markdown", 23 | "metadata": { 24 | "id": "view-in-github", 25 | "colab_type": "text" 26 | }, 27 | "source": [ 28 | "
4 |
5 |
6 |
7 |
8 |
11 | Free Terminals for everyone
Displays a terminal for Google Colab
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
73 | You can give me a small 🤓 dopmaine 🤝 support by ⭐STARRING⭐ this project
74 |
75 |
76 |