Missing windows command line history when executed from Matlab - windows

I occasionally use the Matlab 'dos' command which brings up a command window and executes a program for me. However, I've discovered that the command issued through Matlab is not present in the history of the command window - which means that I can't simply hit the up arrow key to call up the command and run it again.
Is there a way to retrieve Windows command window history when the original command was issued through the Matlab 'dos' function?

No. The Windows command processor only stores what you typed in the command history. Alternative command processors may differ.

Related

Repeat last command windows terminal

On the Windows Terminal, is there a way to repeat the last command by starting character, similar to the feature on a Unix Terminal?
For example, if I type the command cd .. then laster type !cd on a Unix Terminal, it will do the command cd .. again. However, I can't find this feature on the Windows Terminal.
EDIT: Here is the terminal I am using (as installed by Windows, no specific configurations):
EDIT: I am aware that pressing the up/down arrow can navigate the history of commands, but I am in a situation where I use a multitude of different commands and use the arrow keys every time can be tedious. Accessing last command by starting letter will be a lot more useful, similar to the ! command on Unix mentioned above.
Two Solutions
Ctrl + r, then type initial letter(s)
type initial letter(s), then F8
If you are using PowerShell or Bash on your Windows Terminal, you can use a feature called Reverse Search. This will go through your history backwards and show you the recently used command based on the starting characters.
In order to activate reverse search, press Ctrl + R on the terminal and type out the initial characters and watch the recent command appear.
Bonus tip: You can press Ctrl + R further to show next recent command
Note: This does not work for Command Prompt (cmd.exe)

Call the previous command in lldb inside Xcode

I have a basic question on lldb in Xcode.
When using lldb in Xcode, how you guys call the command previously executed ?
Typing the same command every time is very frustrated to me, and
now looking the way to call them in efficient way.
I know "command history" will list the command with the number,
and the $ will execute the command.
But is there something similar like ctrl-p/ctrl-n or ctrl-r in bash
to show or search the previous commands ?
(lldb command running on terminal (not build-in lldb inside
Xcode) can do this.)
I'm using Xcode version 11.5(11E608c).
Use up arrow in the LLDB command prompt. It works similar to Terminal in that regard.
Type Ctrl R and then type part of the command you want. It'll display the first matching command. Keep typing Ctrl R and it will cycle through previous matching commands.

Run Windows command automatically before every command entered

Is it possible to have the command prompt automatically run a command before every command that is entered?
The problem is sometimes when I kill the web server I am running to develop with in the command prompt with 'CTRL' + 'c' the process will change the color of the command prompt. This will linger in the command prompt and leave the color purple, making things hard to read. Currently when this happens I run color 07 before I start the server again. Is there a way to automatically run color 07 in the background when I type the next command so I always start with white?
You can adjust the prompt text by setting the PROMPT variable. This may allow you to use an ANSI escape code to reset the text color to default. Since some command prompt windows have ANSI color support turned on and some do not, it is difficult for me to tell if this will work as-is, but you can try it:
set PROMPT=$e[0m$P$G
If it does not work as-is, you could try one of a number of solutions to enable ANSI escape codes.
Since it sounds like you want the color command before you run the server, you can just make an alias to your command which runs both.
Try this?
Edit:
The general part of your question seems to be answered here for linux shell. If cygwin is available you could use that solution and still run your commands in windows. Could not find a trap equivalent for windows.

Suppress command window when running console application on Windows

Is there a way to suppress showing the command window when running a console application on Windows XP?
Details: I am calling a (console-based) program from Vim. I would like to avoid the command window being shown every time I do this.
Try start /B <program name> to start the program without a new window.
Did you try shell.vim?
The xolox#shell#execute() function
This function enables other Vim
plug-ins to execute external commands
in the background (i.e.
asynchronously) without opening a
command prompt window on Windows.
i can't believe no one has suggested simply using :silent
for example, I have the following in my .vimrc (gvim on Win7)
"open windows explorer to the directory of the current file
:map <leader>ex :silent !Explorer %:p:h<CR>
When I didn’t want to see the output of external commands called from the Vim command line, I would prepend them with :silent. However, this results in a command window momentarily flashing on screen when running GVim under MS Windows. After a short while, I got annoyed by this behaviour so I researched alternative solutions (which is how I came across this question).
The best solution I came up with was to use Vim’s inbuilt system function which runs shell commands without opening an external command window. While the output of the shell command is not printed, its exit status is conveniently available via v:shell_error. It also has the advantage that it’s portable across (all) platforms.
Example (the echo statement should print 0 if C:\Windows exists):
call system("dir c:\windows")
echo v:shell_error
You could maybe use some autohotkey script of this kind:
Loop {
WinWait, my command window title
WinHide
}
I was trying to use git-bash as my shell from vim on Windows but having the command prompt open whenever a command was run, as you described. My eventual solution was to install the plugin xolox/vim-shell and add the following snippet to .vimrc:
if has('win32')
set shell=bash\ -c
set shellcmdflag=
set shellxquote='
set shellquote=
set shellredir=>
set noshelltemp "This prevents an external window from opening.
endif
This utility will also do the job:
http://www.ntwind.com/software/utilities/hstart.html

bash script on cygwin - seems to get stuck between consecutive commands.

I am using a bash script to run a number of application (some repeatedly) on a Windows machine through cygwin. The script contains commands to launch those applications, line by line. Most of these applications run for many minutes and many times I have observed that the i+1 th application is not being started even after i th application is completed. In such cases, if I press enter in the cygwin console on which the bash script is running, the next application starts running. Is it because of any issue with bash on cygwin? Or is it an issue with the Windows OS itself? Have any of you observed such an issue with bash + cygwin + Windows?
Thanks.
I think I have seen this before.
Instead of
somecommand
try
somecommand </dev/null
If that doesn't work, try
cmd /c somecommand
Or experiment with other redirections, e.g.
somecommand >/dev/null
Sounds like you may have a problem with your shell script encoding; DOS (and Windows) uses CR+LF line endings, whereas Linux uses LF endings. Try saving the file as LF.
What might also be going on:
When I was running Cygwin on a school laptop, I encountered a dramatic slowing of shell scripts vs. when they were running in a native Linux environment. This was especially apparent when running a configure script from GNU Autotools.
Check your path for slow drives. (From the Cygwin FAQ):
Why is Cygwin suddenly so slow?
If suddenly every command takes a very long time, then something is probably attempting to access a network share. You may have the obsolete //c notation in your PATH or startup files. Using //c means to contact the network server c, which will slow things down tremendously if it does not exist.
You might also want to check whether you have an antivirus program running. Antivirus programs tend to scan every single executable file as it is executed; this can cause problems for even simple shell scripts that run hundreds or even thousands of individual programs before they run their course.
This mailing list post outlines what is needed to pseudo-mount the main /usr/bin directory as cygexec. I'm not sure what that does, but I found it helped.
If you're running a configure script, try the -C option.
Hope this helps!
Occasionally, I'll get this behaviour because I have accidentally deleted the 'she-bang' at the top of the script, that is, deleted the #!/bin/bash on the first line of the script.
It's even more likely for this to happen when a parent shell script calls a child script that has the she-bang missing!
Hope this helps.
A bit of a long shot, but I have seen some similar behaviour previously.
In Windows 2000, if any program running in a command prompt window had some of it's text highlighted by the cursor, it would pause the command running, and you had to press enter or clear the highlighting to get the command prompt to continue executing.
As I said, bit of a long shot, but accidental mouse clicks could be your issue...
Install cygwin with unix style line breaks and forget weird problems like that.
Try saving your script as "the-properly-line-broken-style" for your cygwin. That is, use the style you specified under installation.
Here is some relevant information:
https://stackoverflow.com/a/7048200/657703

Resources