I would like to use a custom command in Dragon NaturallySpeaking such that while I'm using text Wrangler, and that on my Mac, trying to go to a specific line For example
{control} + J
_arg1
{RETURN}
so for example if I were to say "go to line 10" then my script would execute
{control} + J
10
{RETURN}
and take me to line 10
Related
Consider:
ssh -i "key.pem" root#server.com
Is there a quick way to jump to the beginning of "root" in such a Bash command in the terminal, without iterating over every word/character?
Yes. Bring up the last command using up arrow. These shortcuts will help:
Ctrl + E - go to the end of the line
Ctrl + A - go to the start of the line
Alt + left - go back one word
Alt + right - go right one word
Ctrl + W - delete the last word
To search the command line and the command line history, use:
Ctrl + R and then type the search string, e.g. "roo" to search backwards for "root#...". In the example you have given, however, it will be easier just to jump forward or back by words.
Ctrl + S search forwards (rarely useful). (If forward searching doesn't appear to work, try this other Stack Overflow answer.)
See also this page and google "Bash command line editing" for more tricks.
Let's say I'm in a buffer like this, on line 4, I want to run line 1 to 2 and have the output in the same buffer on line 4 (where cursor is):
echo "Testing"
echo "more testing"
# and here I want the output from running lines 1 to 2
...I know I can do 1,2w !sh to run lines 1 and 2 and have the output shown in whatever that temporary buffer is. But, how do I get into my actual buffer for later editing?
(And the same thing to work with visual mode selected text, not just with line ranges given by numbers.)
You were using :w !... (:help :w_c), but you probably want :! (:help :!):
gg - go to top
Vj - select the two lines
y - yank into a buffer
4gg - go to 4th line
V - select it
p - paste over it
gv - reselect the pasted range
:!sh<CR> - execute in shell and replace
or, trusting ex commands more,
:4d
:1,2y
:3pu
:4,5!sh
NB: !sh is in most cases equivalent to !, as ! will call your default shell.
Yey! Found it. In case anyone else needs this exact same hack on a virgin/foreign vim (plugin-less or someone else's server/config):
:1,2r !sh %
(yeah, output goes after commands, or technically the commands are replaced with their echo but whatever, not at cursor position, but good enough for me to replicate my Sublime + SublimeCommand workflow in vim :) )
In terminal app,when I enter "command + {" or "command + {",it will go next or before window, not next tab,who can tell me ,why?
You probably entered cmd[ and cmd] accidentally, since they do change the window.
Make sure to enter cmdshift[ and cmdshift] as they produce cmd{ and cmd} respectively.
This is because shift[ = {, etc., depending on your keyboard layout. (Just as you would press shift[ to type {, provided you're using the English or some similar keyboard layout.)
There are plenty of ways to switch tabs.
You can use command + shift + }, swipe with three fingers, or use command + [tab number, i.e. 1].
final ,I found ,the answer is "shift + command + }"。 but,in teminal menu,it show the "command + {" is shortcut for "show pervious tab"。
I have a script in a file:
#../Python32/Test.py
y = input("Please input:")
print("'" + y + "'")
from command line, I run the script, and the result is different between XP and Win7:
On XP:
> Python Text.py
Please input:h
'h'
On Win7, the result is:
> Python Text.py
Please input:h
'h
On Win7, the second single quote is missed in the result.
But if the script is like following:
#../Python32/Test2.py
y = input("Please input:")
print("'" + y.rstrip() + "'")
The results are the same on both win7 and XP.
> Python Text.py
Please input:h
'h'
Comparing the results, there should be special character following the read string from command line on win7. I searched it on the internet and tried all the ways which I know, but cannot get the answer.
What's the special character followed the read string via command line on win7? Or is there a way that I can print the special character in my script?
Thanks advance for your response.
You have a carriage return in the string, from the CRLF line ending on Windows. This moves the cursor to the beginning of the line, overwriting the first quote. input() is supposed to remove that. I thought that bug was fixed in 3.2.1. Are you sure you're not using 3.2?
I have these lines in my ~/.inputrc:
set editing-mode vi
set keymap vi
This allows me to use vi keybindings in every program that uses GNU readlines for text input. Examples: python, irb, sftp, bash, sqlite3, and so on. It makes working with a command line a breeze. Matlab doesn't use readlines, but vi keybindings would be amazing to have when debugging or working interactively. Is there an existing solution?
I tend to use matlab -nosplash -nodesktop from the command line and that got me thinking: would it be possible to write a wrapper that does use readlines and pass the input to matlab? (If I have to implement this, I'd probably prefer to do so in Ruby.)
Update:
Thanks for the help. This almost works:
# See also: http://bogojoker.com/readline/
require 'readline'
puts 'Starting Matlab...'
io = IO.popen('matlab -nosplash -nodesktop 2>&1', 'w+')
while input_line = Readline.readline('>> ', true)
io.puts input_line
puts io.gets
end
But it only reads a single line from Matlab at a time (because I'm using gets). Any ideas on how to get everything until the next time it's waiting for input? Here's what's happening (I'm entering stuff at the >> prompt):
Starting Matlab...
>> 1
>> 2
< M A T L A B (R) >
>> 3
Copyright 1984-2009 The MathWorks, Inc.
>> 4
Version 7.8.0.347 (R2009a) 32-bit (glnx86)
>> 5
February 12, 2009
>> 6
>> 7
>> 8
To get started, type one of these: helpwin, helpdesk, or demo.
>> 9
For product information, visit www.mathworks.com.
>> 0
>> 1
>>
>> 2
ans =
>> 3
>> 4
1
>> 5
>> 6
>>
>> 7
ans =
>> 8
>> 9
2
>> 0
>> 1
>>
>> 2
ans =
>> 3
>> 4
3
Yes, that should be easy enough. It's just a special case of the general "open a process and bind to its stdin and stdout" problem, and that's not difficult.
A bit of Google searching finds that IO.popen() is the right piece of Ruby for that, and there's a little more detail in the replies here: http://groups.google.com/group/ruby-talk-google/browse_thread/thread/0bbf0a3f1668184c. Hopefully, that's enough to get you started!
Update: Looks like you're almost there with your wrapper. What you need to get finished is recognize when Matlab is asking for input, and only ask the user for input then. I'd suggest trying this pseudocode:
while input_line = Readline.readline('>> ', true)
io.puts input_line
while ((output_line = io.gets) != '>> ') // Loop until we get a prompt.
puts io.gets
end
end
That's not quite right, as you need to do the inner loop once before you ask for the first input line, but it should give you the idea. You might need to adjust the prompt text that it's looking for, too.
Update 2: Okay, so we also need to account for the fact that there's no EOL after a prompt and so io.gets will hang. Here's a revised version that uses the fact that you can give a blank line to a Matlab prompt and it will just give you another prompt without doing anything. I've rearranged the loop to make things a little clearer, though this means you now have to add logic to figure out when you're done.
while [not done] // figure this out somehow
io.puts blank_line // This will answer the first
// prompt we get.
while ((output_line = io.gets) != '>> ') // Loop until we get a prompt.
puts io.gets // This won't hang, since the
end // prompt will get the blank
// line we just sent.
input_line = Readline.readline('>> ', true) // Get something, feed it
io.puts input_line // to the next prompt.
output_line = io.gets // This will eat the prompt that corresponds to
// the line we just fed in.
end
You could have used rlwrap in a straight-forward manner.
rlwrap is a wrapper that uses the GNU readline library to allow the editing
of keyboard input for any other command.
http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap
Unfortunately it will block context-sensitive tab completion in MATLAB, which is useful on its own.
Actually, you might be better off writing this in C - then you can call the matlab engine directly. This basically allows you to write your own front-end to matlab, if you are so inclined, using the GNU Readline library.