I'm using jupyter lab.but everytime when i touch a new file or directory it default names Untitle.I have to click it and select "rename".
Is there a shortcut to rename a file or a directory? i have search this question in google but i didn't find what i want.
Thanks!
You don't need to select the file and rename it.
You can give desired name just after a notebook it created or while it's open.Right Click on the tab where Untitled(in my case it is Untitled1) is written, in top left corner and select Rename Notebook.
It will open a popup text box.
change the name and click on RENAME.
I managed to enable the shortcut by going Settings > Keyboard Shortcuts and add descriptions as below (and hit the save button at the upper right).
"command": "docmanager:rename",
"keys": [
"Ctrl R"
],
"selector": "body"
Image
I am also having the same problem. I found the settings in using my jupyter-themer
from the Menu: Help-> Edit Keyboard Shortcuts -> rename notebook.
see image description
Related
Hi i'm new into vscode and when i run a program there is some text that i want to get rid of.
i mainly want to remove the first two paragraphs, but also removing the path would be ideal
i tried code runner but thats not the solution i'm looking for
i also tried changing the color to black but i reckon there is a way to remove it
Adding the "-NoLogo" start parameter will remove the paragraph of text; If you open your settings file (Ctrl+Shift+P and then type "Settings" -> User Settings JSON), you can use the following bit of configuration:
// should go in the main JSON object with the other keys
"terminal.integrated.profiles.windows": {
// it might generate some more profiles automatically, but powershell is what matters
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": ["-NoLogo"]
}
}
I believe by default those lines will always appear because those are the one that show up when you open cmd on Windows.
Also, by default, the path open to the current project folder, that the reason why you see the path.
You can do a cls to clear the terminal, but the path will remain unless you change the directory.
You can read more about VS Code integrated terminal here and about terminal profiles here
First go to terminal settings and then the add -nologo arg
How can I move a line (or set of selected lines) down or up in jupyter notebook. Are there any shortcuts?
After moving line 3 one line up:
For example ALT+UP or ALT+DOWN is for up/down displacement that is used in Eclipse IDE.
This question discusses cell displacement.
TLDR:
By following this tutorial, I was able to enable all the sublime-text shortcuts (which includes the moving lines with Ctrl+Up/Ctrl/Down).
I then was able to furthermore, customize the shortcuts by editing the sublime.js
Complete answer:
Find your jupyter path with jupyter --config-dir
Add the following code to <JUPYTER-PATH>/custom/custom.js:
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
// setTimeout(function(){ // uncomment line to fake race-condition
cell.Cell.options_default.cm_config.keyMap = 'sublime';
var cells = IPython.notebook.get_cells();
for(var cl=0; cl< cells.length ; cl++){
cells[cl].code_mirror.setOption('keyMap', 'sublime');
}
// }, 1000)// uncomment line to fake race condition
}
);
You need to find this codemirror/keymap/sublime.js (that is required in the code from point 2), for me, it was in <MY-PYTHON-ENVIRONMENT>/lib/python3.8/site-packages/notebook/static/components/codemirror/keymap/sublime.js
At the end of this file, you can edit the shortcuts, in the keyMap.pcSublime section of this file (if you have a PC).
For OP, the lines to edit would be: swapLineUp and swapLineDown
I did this with Ubuntu & sublime installed.
You can select the line with mouse in jupyter notebook. Drag it
up or down before the line where you want to move it. Press >
button on keyboard while your text is still selected.
This will bring the cursor to end of selected line,
but before the text of line being replaced. Press Enter.
Since jupyter works with code blocks you can use that shortcut between code blocks as
Ctrl + Shift + -
But this will only works between code cells not in the same code block. I don't think there is a built-in shortcut for that. For more shortcuts you can look here: https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
There's no such a shortcut in Jupyter, however, you can manage your own shorcuts Go to Help > Edit keyboard Shortcuts and start setting your commands.
There's some good info on this other post which will lead you to manage your profile's notebook.json file and so on.
Hope this was useful ;)
Edit: typo
You can create your custom shortcuts in Jupyter notebook
Jupyter Shortcuts
I'd like to tag some files on my Mac with Finder under a certain color tag, and then be able to get that list of files using a Python or bash script. Is it possible to get the list of tags associated with a file via the command line or a Python script?
It's possible.
But you'll have to rely on xattr, xattr-lib should do the trick.
Some examples have already been made on how to use the xattr command line tool, those can be found here:
https://apple.stackexchange.com/questions/110662/possible-to-tag-a-folder-via-terminal
Get file's "get info" attributes in mac using python
How can I add OS X "tags" to files programmatically?
I hope these help you out.
In worse case you could use a tool called tag:
tag -l file # list
tag -a tag1 file # add
tag -s red,blue file # set
tag -r \* file # remove all tags
tag -f green # find all files with the green tag
tag -f \* # find all files with tags
tag -m red * # match (print files in * that have the red tag)
This in combination with say subprocess.Popen could solve your needs.
Late to the party here, but this is something that has been bugging me too — and I eventually came up with a run-round for tech-shy people that requires no line-command coding, just ordinary Finder commands and SimpleText. Try the following:
open a Finder window containing the tagged files and Select All
right-click on the selected files to get Contextual Menu and choose "Copy [x number of] files". If it doesn't say "Copy [x number of] files" but just "Copy [filename] you've accidentally deselected the files; reselect all, and try right-clicking again.
open SimpleText. Make sure that it is set to use Plain Text and NOT Rich Text. (Menu Bar: Format>Make Plain Text/Rich Text). If it is set to Rich Text, this technique will not work: you will get a document containing the actual files rather than a list of their names!
paste. This should paste a list of the filenames of all selected files, one per line, in the order in which they appear in the Finder. Hurrah!
Hope this works for you. It changed my life.
I'm trying to add a context menu option for New -> Python Script on Windows 7. However, everything I've tried has failed.
The way that I thought it should work is below:
Add the following registry key:
[HKEY_CLASSES_ROOT\.py\ShellNew]
"FileName"="Template.py"
Null File version:
[HKEY_CLASSES_ROOT\.py\ShellNew]
"NullFile"=""
Optional registry key
[HKEY_CLASSES_ROOT\.py]
"PerceivedType"="text/plain"
#="Python Script"
Add the file to the Windows, ShellNew folder...
This does nothing, although I've done this before, and it worked with other file types. I'm unable to find anything for this anywhere, because they do everything I try for other file types.
What am I doing wrong?
EDIT: Python 2.7.8 or later has this option added during setup/installation.
Reference: MSDN Extending Shortcut Menus
I have found that the easiest way to do this is with the following method, which I have tested on my Windows 10 PC.
Open Regedit
Navigate to Computer\HKEY_CLASSES_ROOT.py
Right click on the .py key > New > Key
Name the new key "ShellNew"
Inside the ShellNew key, add a new string value
Name the string value "NullFile"
Change the NullFile's value to 1
That's it!
(note: this should work with all plain-text file formats)
HKEY_CLASSES_ROOT\.py\PerceivedType="text"
together with
HKEY_CLASSES_ROOT\.py\ShellNew\NullFile=""
works for me on Windows 7.
I have also set HKEY_CLASSES_ROOT\Python default value to "Python Script"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.py]
#="Python"
"Content Type"="text/x-python"
"Python"="Python"
"PerceivedType"="text"
[HKEY_CLASSES_ROOT\.py\ShellNew]
"NullFile"=""
[HKEY_CLASSES_ROOT\Python]
#="Python Script"
Use open++. It's easy to configure, and maybe it can do what you want.
In Sublime Text 2, I want to be able to save all open/loaded files that have names.
I like how Sublime can have files with filenames, and have files that were never saved, and can be closed and it remembers about the untitled files and reloads them without me having to save them.
But when a file has a filename and has some changes in the buffer not yet saved, sublime shows it as such, with the filename and circle, I close sublime, and reopen it, I sublime has remebered it as it was and so the changes are still not saved to the file. That's great.. But.. I'd like a command to save all, but not the untitled ones.
There is a save all option in the menu, but it pops up a dialog box asking regarding saving of untitled files.
What API functions would be involved to write a command that leaves the untitled ones as is, and saves the ones with filenames? (and is there any example code I can run that uses those API functions?)
AFAIK, an opened file is represented by one or more views. So try to get all views and save those with file names. I wrote a simple example. Hope it can help you.
By the way, you can check all API's via the following link.
Sublime Text 2 API Reference
import sublime, sublime_plugin
class SaveAllExistingFilesCommand(sublime_plugin.ApplicationCommand):
def run(self):
for w in sublime.windows():
self._save_files_in_window(w)
def _save_files_in_window(self, w):
for v in w.views():
self._save_exiting_file_in_view(v)
def _save_exiting_file_in_view(self, v):
if v.file_name():
if v.is_dirty():
v.run_command("save")
lhuang's answer is fantastic, and does exactly what I think you want it to do. Make sure you save the plugin as Packages/User/save_all_existing_files.py in order for it to work properly. You can reach the Packages directory via the Preferences -> Browse Packages... menu item. I do have a few additions to make your life a little easier, though - a menu item and a key combination.
You generally shouldn't edit anything in the Packages/Default directory, as all the files can be overridden/expanded upon, but in this case I recommend it for aesthetics sake. Open Packages/Default/Main.sublime-menu and add the following line right after line 128, which should be the save_all menu item:
{ "command": "save_all_existing_files", "caption": "Save All Named Files", "mnemonic": "F" },
This will add a "Save All Named Files" option to the File menu. Next, go to Preferences -> Key Bindings - User and add the following line:
{ "keys": ["ctrl+alt+shift+s"], "command": "save_all_existing_files" },
If this file doesn't have any other contents, surround the above line with square brackets [ ] and remove the trailing comma, otherwise Sublime will complain at you.
Once the keymap file is saved, you can trigger the command by hitting CtrlAltShiftS. Obviously, you can change the keys if you don't like them. If you pick a combination that gives weird behavior, check out the FindKeyConflicts plugin by #skuroda - it's invaluable for troubleshooting your setup, and especially when developing your own packages.
Good luck!
Just add the next line to the Preferences > Key Bindings - User
{ "keys": ["super+shift+s"], "command": "save_all" }
super is a Command key in OS X. Use ctrl on Windows.