|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Tutorial: jupyterlab-quickopen\n", |
| 8 | + "\n", |
| 9 | + "This notebook is a short, hands-on tutorial about using the JupyterLab quick open extension.\n", |
| 10 | + "\n", |
| 11 | + "First, assign a hotkey to the extension so you don't have to click the little magnifying glass in the sidebar every time you want to search.\n", |
| 12 | + "\n", |
| 13 | + "1. Click the *Settings* menu then → *Advanced Settings Editor*.\n", |
| 14 | + "2. Select *Keyboard Shortcuts* in the dialog that opens.\n", |
| 15 | + "3. Add the following to the JSON in the right panel to assign `Ctrl-Cmd-P` as the hotkey on Mac and `Ctrl-Alt-P` on Windows/Linux.\n", |
| 16 | + "\n", |
| 17 | + "```\n", |
| 18 | + "{\n", |
| 19 | + " \"quickopen:activate\": {\n", |
| 20 | + " \"command\": \"quickopen:activate\",\n", |
| 21 | + " \"keys\": [\n", |
| 22 | + " \"Ctrl Accel P\"\n", |
| 23 | + " ],\n", |
| 24 | + " \"selector\": \"body\",\n", |
| 25 | + " \"title\": \"Activate Quick Open\",\n", |
| 26 | + " \"category\": \"Main Area\"\n", |
| 27 | + " }\n", |
| 28 | + "}\n", |
| 29 | + "```\n", |
| 30 | + "\n", |
| 31 | + "4. Hit the same button in the top-right." |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "markdown", |
| 36 | + "metadata": {}, |
| 37 | + "source": [ |
| 38 | + "Now, try to find and open the `LICENSE` file included in this repo. \n", |
| 39 | + "\n", |
| 40 | + "1. Press the hotkey you just assigned and the quick open sidebar panel should appear. \n", |
| 41 | + "2. Type *lic* and the panel should show only those paths in your notebook directory containing the letters \"l\", \"i\", and \"c\", in that order.\n", |
| 42 | + "3. Use the arrow keys to select the `LICENSE` file (it's probably already selected).\n", |
| 43 | + "4. Press *Enter* to open it." |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "cell_type": "markdown", |
| 48 | + "metadata": {}, |
| 49 | + "source": [ |
| 50 | + "Run the code below to generate a thousand more files in the notebook tree." |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": 23, |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "import os\n", |
| 60 | + "import random\n", |
| 61 | + "\n", |
| 62 | + "# Get a thousand words\n", |
| 63 | + "with open('/usr/share/dict/words') as fh:\n", |
| 64 | + " words = fh.readlines()\n", |
| 65 | + "words = random.choices([w.strip() for w in words if \"'\" not in w], k=1000)\n", |
| 66 | + "\n", |
| 67 | + "# Make filenames from those words\n", |
| 68 | + "os.makedirs('data', exist_ok=True)\n", |
| 69 | + "for w in words:\n", |
| 70 | + " with open(f'data/{w}.txt', 'w') as fh:\n", |
| 71 | + " fh.write(w)" |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "markdown", |
| 76 | + "metadata": {}, |
| 77 | + "source": [ |
| 78 | + "Use the quick open sidebar to find these five generated files. " |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "code", |
| 83 | + "execution_count": 24, |
| 84 | + "metadata": {}, |
| 85 | + "outputs": [ |
| 86 | + { |
| 87 | + "data": { |
| 88 | + "text/plain": [ |
| 89 | + "['scammers', 'trendy', 'search', 'dismiss', 'nuptial']" |
| 90 | + ] |
| 91 | + }, |
| 92 | + "execution_count": 24, |
| 93 | + "metadata": {}, |
| 94 | + "output_type": "execute_result" |
| 95 | + } |
| 96 | + ], |
| 97 | + "source": [ |
| 98 | + "words[:5]" |
| 99 | + ] |
| 100 | + } |
| 101 | + ], |
| 102 | + "metadata": { |
| 103 | + "kernelspec": { |
| 104 | + "display_name": "Python 3", |
| 105 | + "language": "python", |
| 106 | + "name": "python3" |
| 107 | + }, |
| 108 | + "language_info": { |
| 109 | + "codemirror_mode": { |
| 110 | + "name": "ipython", |
| 111 | + "version": 3 |
| 112 | + }, |
| 113 | + "file_extension": ".py", |
| 114 | + "mimetype": "text/x-python", |
| 115 | + "name": "python", |
| 116 | + "nbconvert_exporter": "python", |
| 117 | + "pygments_lexer": "ipython3", |
| 118 | + "version": "3.6.7" |
| 119 | + }, |
| 120 | + "nteract": { |
| 121 | + "version": "0.10.0" |
| 122 | + } |
| 123 | + }, |
| 124 | + "nbformat": 4, |
| 125 | + "nbformat_minor": 2 |
| 126 | +} |
0 commit comments