In recent years, Cygwins X-windows icon in the notification area doesn't provide an option to start an xterm. If I mistakenly exit my last xterm, I need a way to launch a new one. Currently, I exit X-Windows, remove ~/.server* files, and /tmp/.X*, then restart X-Windows.
I found a command that I can enter after clicking on the Windows Start button:
C:\cygwin64\bin\xterm.exe -display :0
However, it also starts a DOS window in addition to the xterm. If I close the DOS window, the xterm disappears.
I tried the following, with the same effect:
cmd /q /c "C:\cygwin64\bin\xterm.exe -display :0"
cmd /q /c "start /b /min C:\cygwin64\bin\xterm.exe -display :0"
start /b cmd /q /c "C:\cygwin64\bin\xterm.exe -display :0"
start /b C:\cygwin64\bin\xterm.exe -display :0
Note that the two commands that lead with start aren't recognized when I type the command after clicking on the Windows Start button, so I can only use them by manually opening a cmd window. But the problem remains the same; I have a lingering command window.
In separate trials, I also tried putting each of the above three commands into ~/bin/myXterm.bat, clicking the Windows Start button, and typing the full Windows path to myXterm.bat. Same result -- a lingering command window in addition to the desired xterm
Is there a command that won't leave a command window lingering?
I plan to type the command after clicking on the Windows Start button, then right-click the resulting icon in the Taskbar and create an icon from it. I can then find a way to pin it to the start menu or as a persistent shortcut in the Taskbar. It would be preferable if the host shell for xterm did not even appear on the taskbar, as the taskbar is often crowded and extra icons simply create cognitive noise (but small ones for shortcuts are OK).
Note that this question and
this questions are not the same as mine.
What worked
I right-clicked my desktop and chose to create a new shortcut. I specified the following for the Target field
powershell "start C:\cygwin64\bin\xterm.exe -Args \" -display :0 \" -WindowStyle Hidden"
For the Start in field, I specified C:\cygwin64\home\%USERNAME% (use the Cygwin user home directory as it is set up in your installation).
I then right-clicked the shortcut and chose to pin it to the Start Menu.
What doesn't work
I initially put the above command into ~/bin/MyXterm.bat. I can create a shortcut, but I cannot pin it to the Start menu. I don't have that option in the context menu for the BAT file or the shortcut. If I use Windows Explorer to browse to ~/bin, the Applications Tool ribbon has a button to pin the shortcut, but it's grayed out.
I am baffled by why something so simple in the past is so complicated now, costing the afternoon.
Related
I'm trying to switch from vim/gvim to neovim on Linux. Up to now my standard workflow started with opening the cli, navigate to my project directory, and run gvim <filename> with the file I intend to start working with.
With neovim I can start it from the KDE menu to get a nice GUI. according to the menu settings, it simply runs nvim with an optional filename parameter. But I don't find the way to run nvim from the cli in a way, that it starts the GUI. Running nvim <filename> simply starts the cli UI.
Google gave me a lot of interesting information, but not, what I'm looking for.
There are different GUIs for neovim. Check which one do you actually use and start it from the command line. Navigate to the KDE menu for neovim GUI, right-click on it and select Edit application... Go to the Application tab and check the Command edit box. There you'll see the actual command which is run by KDE when you select the corresponding menu item. You can create your own shell script or alias which will run this command and use it on the command line.
UPDATE
Maybe some parameter or environment variable is passed to nvim so it changes its behavior. You can try to see what system call KDE actually performs to start the editor. For example, I'm using KDE plasma, so pidof plasmashell gives me the pid which I need. Then:
strace -f -v -e trace=execve -p `pidof plasmashell` &> plasma.trace
After that go to KDE menu and start neovim. Terminate the strace command with Ctrl-C and check the plasma.trace file for the execve system calls made to start the neovim process.
In Explorer sequence Shift+F10 -> open command window here opens cmd in current directory.
Is there any way to do the same via shortcuts to launch cmd with administration rights?
Complete shortcuts are listed here
Link to the answer
Right-click Start & choose Command Prompt or Command Prompt (Admin) from the Quick Link menu. You can also use keyboard shortcuts for this route: Windows key + X, followed by C (non-admin) or A (admin).
Type cmd in the search box, then press Enter to open the highlighted Command Prompt shortcut. To open the session as an administrator, press Alt+Shift+Enter.
From File Explorer, click in the address bar to select its contents; then type cmd and press Enter. That opens a non-admin Command Prompt session in the current folder.
In a File Explorer window, hold down Shift as you right-click on a folder or drive. That opens a non-admin Command Prompt session in the selected location.
To open an administrative Command Prompt window in the current folder, use this hidden Windows 10 feature: Navigate to the folder you want to use, then hold Alt and type F, S, A (that keyboard shortcut is the same as switching to the File tab on the ribbon, then choose Open command prompt as administrator).
Simply open cmd prompt from start as Run as Administrator,
Copy the path where you want to execute using location/Address Bar
Use CD space paste the address and press Enter
It will set to the desired folder path
I added the commands to the Explorer context menu in the registry for the background, folders, and files.
I know that you wanted a keyboard shortcut. I am hoping that you can use and adapt the commands and use the existing Windows shortcut system that allows you to set keyboard shortcuts.
Here is a link to an article that has the commands and a link to a ZIP with a REG file:
https://dkcool.tailnet.net/2019/05/add-open-admin-command-prompt-to-the-explorer-context-menu-in-windows-10/#tldr/
Adding to the Windows registry:
For the folder context-menu: (right-clicking on a folder in an explorer window)
powershell -WindowStyle Hidden "start cmd \"/k cd /d %1\" -v runAs"
For the background context-menu: (right-clicking on the background of
an explorer window):
powershell -WindowStyle Hidden "start cmd \"/k cd /d %V\" -v runAs"
For the file context-menu: (right-clicking on a file in an Explorer
window):
powershell -WindowStyle Hidden "start cmd \"/k cd /d %w\" -v runAs"
Here is a link to an article about the shell variables:
https://superuser.com/questions/136838/which-special-variables-are-available-when-writing-a-shell-command-for-a-context
EDIT:
I added keyboard shortcuts using Shift+F10, Shift+Context menu key, or Shift-Right click, and then a given letter for the desired option, which you can modify in the registry. I put all of the files onto GitHub at the link below.
https://github.com/DKCTC/windows-terminal-admin-shortcuts-registry
I also needed the same so as to initiate my angular development test easier.
However without running Command prompt as an administrator 'ng serve' won't work.
Had been using Git Bash for a while. Git Bash website
So I chose Gitbash to initiate the same, from the root folder of the app.
[Right Clicked inside the root folder and Chose Git Bash Here]
and ran the command 'ng serve'. The build was compiled and I was able to access the port[4200].
You can open the PowerShell by holding ALT and typing S->M->A. Then in the PS type cmd to move to cmd.
You can use powershell as well. It will be easy.
Go to your file location
PRESS Alt + F + S + A or Alt + f + s + a
If youre looking for a lazy solution which does not get you into powershell, you can use this nice script to run a batch file as admin. The only thing you have to do is add cmd.exe at the end. Place this batch file inside the folder you want and run it.
You can run a script in PowerShell something like below you can just have the syntax checked and can try implementing below sample
powershell changepath.sh <path>
changepath.sh
CD $args[0]
chmod rwxrwxrwx user ...
If I run gedit in the Linux terminal ($ gedit) it opens as a background job; which is not what I'm after at the moment.
Other programs (such as emacs) run in the foreground with commands like ($ emacs) and only run in the background if I've specified it via something like ($ emacs &).
I've tried searching for a solution but almost everything is about the opposite (trying/struggling to get things to run in the background).
Any ideas?
As it works for me: I run gedit /tmp/file.txt for the first time and it runs in the foreground. Then I open another terminal tab and run gedit /tmp/file2.txt while Gedit is still open — the second command instructs running instance of Gedit to open second tab and exits immediately. Gedit is still in the foreground in the first terminal tab.
According to gedit help, it has an option
-w, --wait Open files and block process until files are closed
If in the second terminal tab I run gedit --wait /tmp/file3.txt, then it opens a new tab in the existing Gedit window but the command stays in the foreground until I close that file tab.
Just in case: it was tested under KDE, Ubuntu 16.04, gedit version is 3.18.3
Is there a command in cygwin terminal that when it's executed, the cygwin window is bring to the top/front? (To notify user that the job it's running is done)
First, iconify (ESC[2t) the window and then de-iconify (ESC[1t) it directly.
This brings the window in front of all other windows.
echo -e "\e[2t\e[1t"
Btw. I tested first with ESC[5t (Raise the xterm window to the front of the stacking order)
But this doesn't work as expected, as it only brings the window to the front of all mintty windows.
How do you install Vim such that it runs in the command line?
I saw a post here and it said to make sure that
[✓] Create .bat files for command line use
was checked. I did make sure that it was checked, but vim won't open in the command line. However,
gvim
will open gvim from the command line, which is a pop-up window. How do I open Vim so that I can edit files directly from the command line? I think that I need to edit the PATH, but I don't know what that is or how to edit it.
EDIT: I also looked at this and followed the directions, tailored to my system. Now vimtutor will briefly open the vimtutor for less than a second and close it! But Vim still doesn't work. Gvim will open Gvim still.
EDIT: I don't think I was clear when I wrote my post. Running
vim
does not open Vim on my computer. Neither does
vim.exe
Use the bottom right Win8 gesture and go as following: Settings > PC Info > Advanced System Settings > Advanced > Environment Variables. Under system variables find Path in the list.
Path is just a semicolon separated list of directories. Append vim.exe to the list and it's now in your path.
You want to run vim.exe, not gvim.exe.
Add this to the Path under system variables "C:\Program Files\Vim\vim82" . Then you are all done.
To Edit Environment Variables:
Click on Start Menu -> Type Environment Variables and Press Enter Supporting Image -> In bottom Right Corner you will find "Environment Variables" Supporting Image -> Under System Variables Search for Path Supporting Image -> Double Click To Edit -> Click on new and Paste the file address given AboveSupporting Image
Now you're done. Test it just by writing vim in Command Prompt or Windows Terminal.