creating multiple tabs in the xterm session of cygwin
If you're already open to starting up X11, check out mrxvt. It does multiple tabs, and last I checked, it built smoothly under Cygwin.
There's also Terminator, which is a java terminal emulator... ISTR it doesn't require X11.
Customize linux terminal PS1 variable in a function before starting a session
You are correct; your local host does not display another prompt after you add TITLE
to PS1
until after ssh
exits. Instead, just output TITLE
immediately.
function fn() {
set-title "$1"
ssh $1
}
function set-title() {
printf '\e]2;%s\a' "$1"
}
Note that setting PS1
locally before running ssh
has no effect on your prompt on the remote host anyway.
How to effectively work with multiple files in Vim
Why not use tabs (introduced in Vim 7)?
You can switch between tabs with :tabn
and :tabp
,
With :tabe <filepath>
you can add a new tab; and with a regular :q
or :wq
you close a tab.
If you map :tabn
and :tabp
to your F7/F8 keys you can easily switch between files.
If there are not that many files or you don't have Vim 7 you can also split your screen in multiple files: :sp <filepath>
. Then you can switch between splitscreens with Ctrl+W and then an arrow key in the direction you want to move (or instead of arrow keys, w for next and W for previous splitscreen)
Get the actual geometry of a gnome-terminal
I can propose you a workaround for this problem which is working for me. First of all you obtain the geometry of the window with the following command:
xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
You will get something like this:
Absolute upper-left X: 783
Absolute upper-left Y: 344
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 722
Height: 434
Depth: 32
Visual: 0x76
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x4400005 (not installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +783+344 -175+344 -175-272 +783-272
-geometry 80x24+775+315
Neither the information in the -geometry 80x24+775+315
section nor the information in Absolute upper-left X: 783
and Absolute upper-left Y: 344
allows you to launch a gnome-terminal in the same position than the current on. You have to mix both data to get the appropriate information.
gnome-terminal --geometry=80x24+783+315
Note: I have check this under Ubuntu 11.10 | Unity
Elegant and efficient way to start GUI programs from terminal without spamming it (Bash or any Posix shell)
As others have pointed in the comments, I think the real problem is a way to distinguish between gui vs. non-gui apps on the commandline. As such, the cleanest way I could think of is to put this part of your script:
#!/bin/bash
if [ $# -gt 0 ] ; then
($@ &) &>/dev/null
else
echo "missing argument"
fi
into a file called gui
, then chmod +x
it and put it in your ~/bin/
(make sure ~/bin
is in your $PATH
). Now you can launch gui apps with:
`gui google-chrome`
on the prompt.
Alternatively, you can do the above, then make use of bind
:
bind 'RETURN: "\e[1~gui \e[4~\n"'
This will allow you to just do:
google-chrome
on the prompt and it would automatically append gui
before google-chrome
Or, you can bind the above action to F12
instead of RETURN
with
bind '"\e[24~": "\e[1~gui \e[4~\n"'
To separate what you want launched with gui
vs. non-gui.
More discussion on binding here and here.
These alternatives offer you a way out of endless aliases; a mix of:
- Putting
gui
in your~/bin/
, and - Binding use of
gui
toF12
as shown above
seems the most ideal (albeit hacky) solution.
Update - @Enno Weichert's Resultant Solution:
Rounding this solution out ...
This would take care of aliases (in a somewhat whacky way though) and different escape encodings (in a more pragmatic rather than exhaustive way).
Put this in $(HOME)/bin/quiet
#!/bin/bash -i
if [ $# -gt 0 ] ; then
# Expand if $1 is an alias
if [ $(alias -p | awk -F "[ =]" '{print $2}' | grep -x $1) > 0 ] ; then
set -- $(alias $1 | awk -F "['']" '{print $2}') "${@:2}"
fi
($@ &) &>/dev/null
else
echo "missing argument"
fi
And this in $(HOME)/.inputrc
#
# Bind prepend `quiet ` to [ALT][RETURN]
#
# The condition is of limited use actually but serves to seperate
# TTY instances from Gnome Terminal instances for me.
# There might very well be other VT emulators that ID as `xterm`
# but use totally different escape codes!
#
$if $term=xterm
"\e\C-j": "\eOHquiet \eOF\n"
$else
"\e\C-m": "\e[1~quiet \e[4~\n"
$endif
Related Topics
Understanding /Boot/Config File
How to Create a Multi Partition Sd Disk Image Without Root Privileges
Openssl/Rsa - Using a Public Key to Decrypt
Calculate Total Disk I/O by a Single Process
Substituting a String in Place of Variable in Shell
Cx_Oracle: Distutils.Errors.Distutilssetuperror: Cannot Locate Oracle Include Files
Why Does Git Fail on Push/Fetch with "Too Many Open Files"
How to Compile Intel MAC Binaries on Linux
Autoconf Complains "C Compiler Cannot Create Executables" on Linux Mint
Bash: Loop Until Command Exit Status Equals 0
Copy and Overwrite a File in Shell Script
Why Does Pages Allocation with Order of 10 or 11 Using _Get_Free_Pages() Usually Fail
Distro for Linux Kernel Development
Berkeley Db Mismatch Error While Configuring Ldap
Amazon Ec2 Lost Private Key, How to Get Access to The Server