Run script until current line - spyder

Is there a hotkey for running the script from the beginning to the current line where the cursor is positioned? I know this can be done by selecting all code and hitting F9. However, I am wondering if this can be done by a single key/combination of keys.

Related

How can I paste multiple line command with Docker interactive mode but not evaluating?

For example I am opening an interactive command line window.
docker exec -it container rails c
When I paste a multiple-line command, it evaluate every line instead of pasting a block. How can I configure it as not to evaluate?
Order.last
.user
.id
Ah, simple trick here: type begin + enter, paste the code, type end:
begin
Order.last
.user
.id
end
It cannot and should not be configurable. The reason is that the console cannot posisible know when you have finished typing the whole command, as the first line is a completely valid ruby statement. Things are slightly different if you adapt different coding style:
Order.last.
user.
id
The code above will work once copied to console (but gosh, I really hate that style!) because it is clear to the interpreter that the statement is not completed yet - similarly to missing closing bracket or quote. Wrapping the code in begin/end have the same effect - it tells the interpreter that the code is not yet completed, so it awaits for the final end.

In Fish, how do you tweak things around to match special key bindings?

Context
So I finally give a try to Fish, and as one would expect I encounter some frictions due to differences with my usual routines.
The most astonishing for me, as for many other, was the absence of the bang operator. I'm fine with the lose of sudo !!, as the suggested function replacement seems even better to me, I named it gar which means "To make, compel (someone to do something); to cause (something to be done." However I'll need a replacement for !<abc><enter> which grab the last history line starting with <abc> and run it without further ado, suggestions are welcome.
Now, for the more personal things:
- I use a Typematrix 2030 keyboard
- I use a bépo layout
- I like to configure default finger position keys with the most used actions
Aims
As on my keybord <enter> is well positioned and is semantically relevant for that, ideally I would like to achieve the following key binding:
ctrl-enter: accept the whole suggestion and run it without further confirmation
ctrl-tab: accept the whole suggestion and wait for further edit
alt-enter: redo the last command without further confirmation
But according to xev it appears that, at least with Gnome-terminal, this combinations are not recognized. Are they terminal that supports it? For now I remapped these three to <ctrl>-i, <alt>-i and <alt>-I respectively:
bind --preset \ci forward-char execute
bind --preset \ei forward-char
bind --preset \eI forward-word
This works as expected, but it seems that now the tab key will also map to the first item. I guess that tab map to <alt>-i at some point in the shell stack. I wasn't aware of that, so I don't know yet if it will be possible for Fish to separate each of them.
To manage jobs, I also came with
bind --preset \es fg
bind --preset \eS bg
The first works as expected, but the second one doesn't. With application like vim, the binding should be operated in the application configuration itself of course. But for things as trivial as yes, <alt>-S won't work as expected while <crl>-z continue to operate normally.
I also would like to bind some commands like ls -alh and git status --short to a directly executed command, showing the result bellow the currently edited line, allowing to further type seamlessly, but didn't find the way to do it yet.
Summary of remaining question
So here are my more precise questions summarised:
how do I bind the sleep signal to <alt>-S?
is there a terminal I can use where <alt>-<enter> and <ctrl>-<enter> works?
how to seamlessly run command while maintaining the current line edition in place?
can you bind something to <alt>-i without altering <tab>?
how do I bind the sleep signal to -S?
What you are doing with bind \es fg is to alter a binding inside the shell.
But when you execute yes, the shell isn't currently in the foreground, so shell bindings don't apply.
What you'd have to do instead is change the terminal settings via stty susp \cs,
but fish resets the terminal settings when executing commands (so you can't accidentally break them and end up in an unusable environment), so there currently is no way to do this in fish.
can you bind something to <alt>-i without altering <tab>?
Sure. You bind \ei. Which is escape+i, which is alt-i (because in a terminal alt is escape).
Your problem is with ctrl-i, which in the way terminals encode control+character is tab. The application receives an actual tab character, and at that point the information has been lost.
is there a terminal I can use where - and - works?
Most terminals should send \e\r for alt-enter. ctrl-enter again is unencodable with the usual code (because \r is ctrl-m), just like ctrl-tab is.
Any fix to this requires the terminal to encode these combination differently.
how to seamlessly run command while maintaining the current line edition in place?
I don't know what you mean by this. I'm guessing you want fish to remain open and editable while a command also runs in the foreground. That can't work. There's no way to synchronize output from two commands to a terminal, not with cursor movement being what it is.

Can I force applescript to run synchronously?

I'm writing a simple applescript script for iTerm2 that generates a bunch of tabs and starts running services within them (I have a lot of microservices, and all need to be running to test things locally).
Things are mostly working, however I'm experiencing some slightly odd behavior which I think is related to applescript sending commands early. Let's look at a concrete example:
create tab with default profile
tell the current session
write text "cd services/myservice"
write text "make build-docker"
write text "make run-docker"
end tell
In theory, this chunk should
1) Create a new tab
2) Change into a new directory
3) Build a docker image and
4) Run that docker image.
This will occasionally work, but more frequently I run into problems on step 4. Specifically, I'll check the tab only to find out that 'make build-docker' was the last command run. This command takes some time, so I'm assuming "make run-docker" is sent while build is running and is ignored. Is there a way to force applescript/iTerm2 to wait for this command to finish so that run is executed correctly?
Hopefully this is clear. Thanks for reading!
If you have iTerm's shell integration enabled, you can poll is at shell prompt to determine if the command has finished:
tell application "iTerm2"
tell current window
create tab with profile "BentoBox"
tell current session
write text "sleep 5"
repeat while not (is at shell prompt)
delay 0.5
end repeat
write text "sleep 5"
end tell
end tell
end tell
Otherwise, you will want to string all the commands together in one tell:
write text "cd services/myservice; make build-docker; etc; etc; etc.."
Or place them in a shell script and execute that:
write text "my_super_duper_shell_script.sh"
Or use AppleScript to write the cmds to a tmp file and execute that:
re : How can I create or replace a file using Applescript?

lldb 'step into' can't jump into function call on Xcode7?

I use Xcode7 to debug a App.
Seems step into behave like the step over, can't jump into the execution of a sub procedure? It's just jump to the next line in the source code each time.
And if I'm debug in the UIKit method(I don't have source code), it's jump to the next instruction.
As you have found, step-in avoids frames with no debug information. Most people like to just hit one step command, rather than switching between step & next depending on the line they are on, and in my experience, tend to choose step. This is made more pleasant if the debugger doesn't stop in printf & other code you have no debug info for.
However, lldb's "step" command has an option to control this:
-a <boolean> ( --step-in-avoids-no-debug <boolean> )
A boolean value that sets whether stepping into functions will step over functions with no debug information.
If you use this frequently, you can either reset the step alias to include this option, or make another alias that includes it. Use the command alias command to do this.
And if you always want step-in to step into code with no debug information, just set the global setting:
settings set target.process.thread.step-in-avoid-nodebug 0
either at the start of a debug session or in your .lldbinit.
Note, most of lldb's commands are documented in the help system. For instance, help step would have shown the above option for the step command, and apropos step would have shown the setting.
From GDB Manual:
Also, the step command only enters a function if there is line number information for the function. Otherwise it acts like the next command. This avoids problems when using cc -gl on MIPS machines. Previously, step entered subroutines if there was any debugging information about the routine.
And I found Step into works well when I have source file.
So maybe I have make a mistake. But the lldb is very lack of documents.

attempt to index field '' (a nil value)

I was trying to run this script done by SethBling, but it gives me this error:
LuaInterface.LuaScriptException: DP1.state
LuaInterface.LuaScriptException: [string "main"]:337: attempt to index field 'neurons' (a nil value)
This is the code
In case this didn't solve your problem try this:
"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load." from JaRetroYT over on reddit.
A flamanis posted this comment on youtube. I followed the instructions and got it working.
HOW TO GET IT TO WORK! THIS ALL TAKES PLACE INSIDE THE FOLDER YOUR BIZHAWK EMULATOR IS IN.
Execpt this part: Before EVER opening the lua console on BizHawk,
(If you have, instructions on how to reset your stuff will be at the
bottom) go onto the level you want to have it learn, and when the
level starts up, click on file. Go down and open the menu of save
state, at the bottom click the create named state, and then finally
name it DP1, however put it after all the slashes and whatever so just
delete the gamestate.whatever jargon that it auto names it. After
doing that, either move that file from the SNES/State folder to where
you have your lua file, or the other way around. and then load up the
lua file into the console, and boom you're good.
IF YOU ALREADY TRIED TO RUN THE LUA FILE AND IT ERRORS: You either need to delete your save, or edit the lua file slightly. If you want to do the delete save approach, then go into the SNES folder and then into the SaveRAM
folder and delete your file for the game. THIS DOES NOT DELETE THE
EMULATION, just the save. If you want to edit the lua file, then at
the top, the very top line, (create a new one if you want to, just
make sure it's before any other text) add this: pool = nil that's it.
It will reset the data so that it can run again. You still need that
save state though. You will probably want to edit the file again after
you've started running it and remove that line or it will restart
every time you turn it on.
Alrighty, I said I'd answer this better, and sometimes people do just google randomly for their solutions.
Soo, Bizhawk emulator has a way to run Lua scripts, which is nice.
So Seth's program assumes a few things about how the game is set up, and how the user (that is you) has done certain things beforehand.
The main thing that you need to do beforehand is create what is known as a save state. This is a point in the game that you can instantly reload back to, and how the program restarts the level so that each 'run' is essentially the exact same. This differs slightly from normal games where you 'load' the game, because games back around SMB weren't as 'random' as games now. So saving the game and loading it should give the same exact result with the same inputs every time.
You should create the save state right at the very start of the level. To create this illustrious save state you want to click on the file button at the top of your screen to open the drop down, and then select save state and create a new one. This should create a save state that you can then load to return to that exact moment in the game.
To have the program be able to load your save state to run you can do one of two things
1: Rename the actual save state file name to be just DP1.savestate
2: Modify the Lua file and change the DP1.savestate part to be the name of your save state
Then you just need to move them into the same folder, and you should be golden.
If you attempted to run the file before making a save state, it will have tried to run and errored with attempt to index field 'neurons' (a nil value) or something similar. (It's been a while, it could have stopped on the first run because it couldn't find the save state, so this might just only happen on the 2nd and further runs)
What this means is that it essentially created it's "brain" but left it completely empty. Which is bad. There's two ways to fix this, and they're fairly straightforward.
1: You need to delete the actual game save, otherwise known as the SaveRAM. The file that you need to delete can be found in the folder for whatever console you're running, in Seth's video he was using the SNES, so that's the folder you'd want to go into. Inside that folder is then the SaveRAM folder, you can either just delete that folder, or go into it and delete the one for the game you were running.
2: You need to edit the Lua file to reset itself, all this requires is putting the text pool = nil at the very top. This will then delete the "brain" before anything else happens, which will let the program create a new one. Fair warning: This is not just a one time effect, if you restart the program at this point you will lose your entire progress. What you need to do is after it starts running, stop it and edit the file again, and remove the line you just added. This will stop it from deleting it's "brain" every time the program starts, and you should be able to freely run the game.
I do hope that there are still people who look at Seth's video and wants to make it run themselves, good luck to you guys, and happy gaming.
"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load."
from JaRetroYT over on reddit.
Move the savestate and lua script to the main folder for the emulator (where EmuHawk.exe is)

Resources