Cygwin shortcut to start xterm - cygwin

I've been using cygwin for very long time. Back in the day, we used to be able to create a shortcut and it automatically starts X and starts an Xterm with the preferences saved in a file.
Today, I'm finding myself launching xlaunch, and then clicking throw a few dialogs to start xterm. Is there a way I can shortcut all this and just click one shortcut to get the result?
Thank you

Solution using startxwin that belongs to xinit package
Create you customized script from the baseline:
cp /etc/defaults/etc/X11/xinit/startxwinrc ~/.startxwinrc
remove a bit of the duplication at the begin of ~/.startxwinrc
to avoid a recursive call and at the end add how many xterm calls
you want before the Menu manager.
/usr/bin/xterm &
exec /usr/bin/xwin-xdg-menu

Related

xdotool key does nothing inside .sh script

I have this script to launch nmon; I want the window to be aligned on the right of the screen as I launch it. To do so I have the shortcut sup+right that works if done manually but does nothing inside the script.
It is very simple:
su
export NMON=MMMmcdt-
nmon
xdotool key ‘super+Right’
Thank you for your help
I see two problems there:
running nmon will block - you need to change that to "nmon &" (that is run nmon as a "background process" so it does not block the shell)
you are not ensuring you send the key to the correct window, if you VM is set not to focus newly created windows you will send super+right to a wrong window.
Assuming your Window Manager is set to focus newly open windows, this is a simple fix:
su
export NMON=MMMmcdt-
nmon &
xdotool key ‘super+Right’

running x11 on cygwin, all terminals stuck at one corner

I am trying to run x11 on cygwin, mainly to run xfig utility, and I am facing a problem.
When I run xinit to start x11, I get a big popup window with one terminal open. But I am unable to open any other terminals in it. To be more specific, when I run "xterm &" in it, a new terminal opens up but it sits on top of the old terminal, and there is no way I can move this window, so the old terminal is as good as useless to me, till I kill the new terminal.
I also tried running "xwin". There a big window popped up, but it does not contain any terminal, and I cant open any terminal, whether by left or right clicking.
I also tried running "startx". A big window opens up but gets killed automatically after a few seconds.
How can I use x11 effectively on cygwin? As of now, I can use with "xinit", but with only one terminal.
The proper mode to start the Xserver on cygwin is to use starxwin.
From its manual:
The startxwin script is a front end to xinit(1) that provides a
some what nicer user interface for running a single session of the X Window
System in multiwindow mode. It is often run with no arguments.
To move windows around, you need to have a window manager running. You can start this either from the xterm, by passing the name of the window manager as an argument to startx, or by starting it from your X11 startup configuration (memory says that would be ".xinitrc" in your home directory on most unix boxes, but I am not sure if that's true on Windows using Cygwin). The .xinitrc file is "just" a shell-script, with the end of the script indicating "X should shut the server down now" (see example at the end).
There are many possible window managers, including fvwm2 (which according to your comment, you managed to find on your own). A full list of X11 window managers is probably too long to fit in this answer (there are many, there are new ones popping up, and old ones going out of maintenance on an ongoing basis). Some of the not entirely uncommon ones are fvwm2 (already mentioned), cinnamon, twm, ctwm, ratpoison, ... For a more up-to-date list, ask your favourite search engine for "list of X11 window managers".
Example .xinitrc file:
# This is an example .xinitrc file, starting first an xterm,
# then a window manager. As the X server terminates when this script
# does, we start the X terminal in the background, but the window
# manager in the foreground, so that "WM exists" signals "X server shuts down"
xterm &
fvwm2

Select(mark) & right click paste feature (like on cisco's IOS) on linux (bash)

Is it possible to make/enable/config bash on linux to be able to copy content from terminal by just selecting it and to paste by right click (like when you connect to switch/router with ssh)?
Yep it is in fact it's on by default in most terminals see below for example. Ctrl-Shift-C & Ctrl-Shift-V are also very helpful in this regard. I'm using konsole in KDE but gnome-terminal and nearly every other terminal has this ability.
Without X/Gnome/KDE: if you install gpm you can use your mouse for copy/mark and paste on console.

alt-tab like functionality when using terminal?

When working in GUI we do alt-tab (or cmd-tab in mac) to switch between multiple programs, for example I am writing a text file in a text editor and then I do alt-tab to switch to already running browser to google up something then I alt-tab again to come back to keep editing.
How do you perform such "switch between" programs in command line interface - for example working with a ssh command line shell?
EDIT: I forgot to mention it, I am using ssh to connect to my university's server, and they don't have screen & tmux installed, and my account have no right to install any new apps... Is there any built-in functionality to perform this task, or any work around? For exmaple can I "minimize" running proggram and come back to regular shell interface, do some work, then display the "minimized" process again?
Another workaround: use the shell's job control, eg if you're editing a file, CTRL-z pauses the editor and brings you back to the shell, where you can compile, see manpages, browse the web or whatever -- and of course you can background the browser or anything else.
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.
As a crude workaround, run multiple terminal windows on your computer, and alt-tab between them.
Incidentally, at the Linux console, you can switch virtual terminals with ctrl+alt+F for at least F1 through F6, commonly F8 or more (depends on how the distro sets them up). Not your case, I know, but in case future visitors should benefit.
If you are comfortable in Emacs, it allows you to run multiple independent ansi-term buffers.
You can also use "GNU screen" to emulate multiple terminals in one terminal.

How to remember multiple tabs' session in terminal? (Alike FF session manager)

how does one "undo close-tab" in terminal? And quite related to it, is it possible to remember a session of tabs in terminal?
I mean (alike Firefox) if I close all tabs in a particular terminal window, how do I open with same the next day?
Its really useful to remember the terminal session for people like me who use multiple tabs a lot, and do not wish to start the next day with remembering what (and whereall) one was working, when one left the desk the day before.
In mouse right-click menu of gnome-terminal, one could easily (and I have) mistakenly click close tab instead of 'Copy'and lost track of what and where one was before selecting the text selected. In this case, undo closed-tab will serve a great purpose (available in Firefox already)
Thanks!
--V
For the gnome terminal, you can use
gnome-terminal --profile=〈your profile〉 --save-config=〈file〉
I launch it as a background task to save the terminal state periodically.
"termit" can save sessions and is scriptable in lua: https://github.com/nonstop/termit/wiki
I don't know about an "undo close tab" feature, though.
For reference, my termit lua config can be found here: https://github.com/thet/dotfiles-termit
On Linux, gnome-terminal is able to load multiple tabs with different working directories. Like termit (which is much more flexible due to it's lua scripting interface), it doesn't have a "undo close tab" feature.
Open Gnome terminal with multiple tabs, each one in another working directory: gnome-terminal --tab --working-directory=/home --tab --working-directory=~ --tab --working-directory=/opt.
Open Gnome terminal with multiple tabs and one base working directory: gnome-terminal --working-directory=/home --tab --tab --tab.
For more options do: gnome-terminal --help-all.
The gnome terminal doesn't have such features, but if you're open to change you could try konsole, it has some nice 'save session' options you could find helpful, though nothing about re-opening accidentally closed tabs, as far as I know.
The other thing, if you're particular about your desktop, is that KDE's konsole might not fit all too well within Gnome.

Resources