Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Black Mamba - open quickly and other shortcuts
-
@zrzka said:
Also I just added Cmd-Shift-0 (zero) to open Dash with a) selected text as a query, b) if there's no selection, cursor position is used to find identifier around it.
Very nice idea!
-
@zrzka, thanks. This is looking pretty cool. Is there a strategy that i can clone the repo into the site-package-3 dir. i cloned it then moved it, i was a little unsure of what i was doing. Maybe this cant be done because of site-packages-3 being a special folder. Not sure. But maybe I should just clone the blackmamba dir and deal with the startup seperately. I just want to be able to update as you update by doing a git pull, rather than moving etc...
I have one suggestion, is to do print statements in your startup file. Just a few to say what's going on. I do that for my simple startup for changing the screen brightness, font size, turning off animations etc...Anyway, just a suggestion. I inserted a print line just saying 'doing some blackmamba stuff'.
-
You can clone it directly into the
site-packages-3
folder in this way ...[site-packages-3]$ pwd ~/Documents/site-packages-3 [site-packages-3]$ ls -la .git (352.0B) 2017-08-12 10:15:40 LICENSE (1.2K) 2017-08-12 10:15:40 Readme.md (2.2K) 2017-08-12 10:15:40 blackmamba (384.0B) 2017-08-12 10:15:40 external_screen.py (5.6K) 2017-08-12 10:15:40 pythonista_startup.py (1.3K) 2017-08-12 10:15:40 [site-packages-3]$ rm -rf .git LICENSE Readme.md blackmamba external_screen.py pythonista_startup.py [site-packages-3]$ ls -la [site-packages-3]$ git clone https://github.com/zrzka/pythonista-site-packages-3.git [site-packages-3]$ ls -la .git (352.0B) 2017-08-12 10:16:16 LICENSE (1.2K) 2017-08-12 10:16:15 Readme.md (2.2K) 2017-08-12 10:16:15 blackmamba (384.0B) 2017-08-12 10:16:15 external_screen.py (5.6K) 2017-08-12 10:16:15 pythonista_startup.py (1.3K) 2017-08-12 10:16:16 [site-packages-3]$
And then you can update it via
git pull
...[site-packages-3]$ pwd ~/Documents/site-packages-3 [site-packages-3]$ git pull [site-packages-3]$
-
Added some comments as requested and I also created
blackmamba.startup
file where all the startup things are done. Then I removedpythonista_startup.py
from GitHub repo, so, it will not interfere with yourpythonista_startup.py
file and did add Installation section to the readme. Just copy & paste the lines from this section to yourpythonista_startup.py
file. This will be stable interface for BM initialization. Alsopythonista_startup.py
file is ignored by git (.gitignore
), feel free to modify it, add your custom routines,git pull
will be happy.Yeah, I know it's akward installation process, but because I still consider it as hack, not going to provide better way to install / update it. And I hope that some of these features will be added to the Pythonista, thus lot of things will be removed, new ones added, ...
-
@zrzka, sorry. I cant see what I am doing wrong. I have done this a few times so all your cmds are not there. But I think you can see from the printout below, the site-packages-3 dir is empty before I do the clone. Bu you can see I only end up with a single folder in the site-packages-3 dir after the clone.
I cant see what I am doing wrong[site-packages-3]$ pwd
~/Documents/site-packages-3
[site-packages-3]$ ls -la[site-packages-3]$ git clone https://github.com/zrzka/pythonista-site-packages-3.git
[site-packages-3]$ ls -la
pythonista-site-packages-3 (256.0B) 2017-08-12 15:39:32
[site-packages-3]$ -
I had probably older StaSH. Did update StaSH and you're right, now
git clone
behaves correctly. So the clone command is:git clone https://github.com/zrzka/pythonista-site-packages-3.git .
(<- space dot at the end)
-
@zrzka , perfect, works great. Thanks for your help. You might want to make a note in your installation instructions about the trailing period. I can see you changed it, but this would trip up newbies like me.
-
Done :) More updates later, going to take week off :)
-
@zrzka , ok. Enjoy. Thanks again.
-
cool,perfect,thanks.
and wish @omz next pythonista update can support it native.
-
@zrzka, hey. I know you are off right now, hope you are having a good break. But when you return could you consider having a (dedicated) key combo (cmd-something) that you can apply to invoke a given wrench menu item. Eg. Maybe the user could pass the name of the wrench item name as a param in the bm.start('StaSh'). I guess it could also be a .py filename. Although that seems a bit more on the wild side. Maybe you have some better ideas than that.
I also mention dedicated, because I think it would get infinitely more complicated to let users to map their own keys.
Anyway thanks again, still only a day or so with what you have done so far and its very useful for me with the Apple iPad Pro keyboard. -
@Phuket2 thanks for the suggestions.
Open Quickly
I would like to reuse Open Quickly dialog (when I refactor it) for:
- Run Quickly (search for just
.py
and run it, basically emulation of open and tapping on play), - Wrench Quickly, same idea, but you can search for wrench items.
UI for mapping keys
I'm not going to provide UI for mapping keys, because it's a lot of work, which can be replaced with something more simpler. I can remove HW shortcuts registration from
bm.start
, can provide something likebm.register_default_key_commands
. And if you don't call this function in yourpythonista_startup.py
file, feel free to map your own shortcuts viabm.register_key_command
. Or call it and add your own afterbm.start()
.Shortcut for the wrench item
Just do this in your
pythonista_startup.py
file:#!python3 import blackmamba.startup as bm import blackmamba.key_commands as bkc import blackmamba.uikit as bui def launch_wrench_item(name): print('Wrench item: {}'.format(name)) def launch_stash(): launch_wrench_item('StaSh') bm.start() bkc.register_key_command( bkc.PYTHONISTA_SCOPE_EDITOR, 'S', bui.UIKeyModifierCommand | bui.UIKeyModifierShift, launch_stash, 'Launch StaSh')
This maps
Cmd-Shift-S
tolaunch_stash
, where you can do whatever you want :) - Run Quickly (search for just
-
Some breaking changes pushed. Check Usage section in the readme. Summary:
external_screen.py
moved toblackmamba/experimental
blackmamba/startup.py
trashedregister_default_key_commands
introduced inblackmamba/__init__.py
- removed scope in
blackmamba/key_commands.py
- usage examples updated
- repository renamed (
pythonista-site-packages-3
->blackmamba
)
If you don't want to check all these changes, just update your
pythonista_startup.py
content:#!python3 import blackmamba as bm bm.register_default_key_commands()
-
@zrzka , hey thanks. The git pull worked perfectly. Thanks for your help to get it setup correctly. Makes a huge difference being able to do that. I haven't added my own keys yet, but will put some thought into it. I am always running 'Check Style' and 'Reformat Code' these days so I am guessing, i just need to find these scripts and run them from function stubs like you do with the hallo example. Anyway, will give it a go later.
Thanks again. This is really fantastic with an external keyboard. I am sure a lot of other apps would be envious of this ability.Oppps, sorry, I missed the post above this...Looks like the wrench keys have been handled. That's great. I will try them now!!!!
-
@Phuket2 wrench item(s) are not handled yet. It's just silly example how to print smth with keyboard shortcut. I'll try to add run script / wrench item today. Then you'll be able to use it.
-
@zrzka , ok. Cool. I had a lame attempt to get it working and started going down a rabbit hole. But for me it will be a big help. Esp the check styles/reformat code. @ccc has beaten me with a big stick so I don't dare to push anything anymore until I have done all the checks :) I find it super annoying and time consuming. But I am happy I am staring to take the time to do things properly. Just a matter of time it will become second nature.
Ok, will keep a look out for the next update :) -
@Phuket2 I did refactor my picker, thus I was able to add Run Quickly... (Cmd Shift R) and Wrench Quickly... (Cmd Option R). But it does work only and only if scripts are Python 3 compatible. Otherwise you can run them, but they will fail to execute. See another thread for more info. Sorry for this, will try to solve it somehow.
It's useless for StaSh (Python 2) and maybe for many more scripts.
-
@Phuket2 works now, but it's kinda limited. See this commit.
-
Another update ...
wrench_picker
renamed toaction_picker
Wrench Quickly...
renamed toAction Quickly...
with new shortcutCmd-Shift-A
ide.run_action
added (see example below)- slight Action Quickly... UI improvements
- title is custom title or just script name without extension if title is not provided
- subtitle is script path
... and here's an example how to register custom shortcut to launch StaSh for example ...
#!python3 import blackmamba as bm from blackmamba.key_commands import register_key_command from blackmamba.uikit import * # UIKeyModifier* import blackmamba.ide as ide bm.register_default_key_commands() def launch_stash(): ide.run_action('StaSh') # <- editor action custom title, case sensitive # or ide.run_script('launch_stash.py') register_key_command('S', UIKeyModifierCommand | UIKeyModifierShift, launch_stash, 'Launch StaSh...')
ide.run_action
accepts editor action custom title and it's case sensitive. Another option is to ignore editor actions and use justide.run_script
with script name. -
Another installation method added (StaSh & Pip). Check readme. This is preferred way to install Black Mamba. The old git way still works and will work.