UNIX open multiple windows and pass login/password - unix

Straight to the point; I'd like to create a script in UNIX to open two windows at a specific location on the screen, enter in username and password (which would be given by the user as an argument) and then execute another script.
I'd like to know if this is possible and if so; where should I look?
I'm new to UNIX, but am quite familiar with scripting and programming.
EDIT after thb and notfed responded
I am currently running SunOS 5.6 on OS X

Regarding the location of the windows, review X(7) -- that is, type the command man 7 X at the terminal and review the result -- and scroll down that man page to the section GEOMETRY SPECIFICATIONS, if your version of the man page has such a section. In brief, to have the program xfoo open its window with a size of 200 horizontally and 160 vertically, with its upper left corner at coordinates (40, 100), give the command xfoo -geometry 200x160+40+100.
This may not be a complete answer to your question, since you prudently have not given full details, but one suspects that it will set you on the right track, so to speak.
Regarding your authentication question, the crypt(3) manpage and its SEE ALSO section might help. For more advanced handling, see Libpam, where PAM stands for Pluggable Authentication Modules.

If the two windows are Xterms, then there's an easy way to do this;
Note this is from a ksh script, but should work in bash
## This is how big (how many columns & rows) your Xterm will be
GEOM0=198x20
GEOM1=98x45
## Colors
COLOR="-bg black -fg white -cr red"
## Xterm Options (See Man page)
XOPTS="+ah +ai -b 2 -cb +cn -j -ls -rw -aw -si +sk"
## Scroll-back Buffer
SCRLB="9999"
## Commands to execute (you could put an SSH command here)
CMD0="-e /bin/gtail -F /var/adm/messages"
CMD1="-e /bin/gtail -F /var/log/secure"
TITLE="-title Something Clever Here "
TERMBIN=/usr/openwin/bin/xterm
# PLACEMENT
# We specify where we want the window to pop-up by adding "+#+#" to the GEOM.
################################################################################
## Top-Left corner (For my monitor, that's "+2+2")
${TERMBIN} ${XOPTS} -sl ${SCRLB} -fn 6x10 ${COLOR} -geometry ${GEOM0}+2+2 ${TITLE} ${CMD0} &
## Top-Center (For my monitor, that's "+2+233")
${TERMBIN} ${XOPTS} -sl ${SCRLB} -fn 6x10 ${COLOR} -geometry ${GEOM1}+2+233 ${TITLE} ${CMD1} &

Related

Which keybind for smart-searching in history with ZSH?

When using the up and down arrow in my terminal (iTerm 2 on Mac OS Catalina), I can browse through my last commands using the up and down arrows.
I use ZSH (Oh-my-zsh to be precise) and if I type e.g. vim then press up, it will browse my history for any commands issued starting with vim.
I think it's annoying to have to move my hand to the arrow keys, so i wanted to bind ctrl-j and ctrl-k for browsing up and down.
I looked at bindkey and bound ^j to down-history and ^k to up-history. This allows me to browse my history, but not with the "smart" functionality (i'm not sure of the right terminology here) - It simply goes up and down in my history, without regards to my input.
I've looked through the standard widgets on the Zsh Line Editor manual, but I cannot find the right command for this.
Which command should I bind ^j and ^k to to get my desired result?
After some further digging, i ended up on the The Z-Shell Line Editor page at the section called "Prefix searching".
It revealed that the widget I was after, is called history-beginning-search-backward.
When using that widget, it works almost as I wanted it to, but not jumping to the end of the line.
A quick search lead me to another StackOverflow Question, that states that if you want to jump to the end of the line (as with the up arrow), it should be done as follows;
I had the same question and managed to find the solution with some experimentation.
I added the following to my .inputrc
"\eOA": history-search-backward # Up
"\eOB": history-search-forward # Down
"\C-P": "\eOA\C-E" # Ctrl-P
"\C-N": "\eOB\C-E" # Ctrl-N
This binds two hotkeys to Ctrl-P and Ctrl-N. One for history search, and the other Ctrl-E for end-of-line.

Navigate through Top Command's Pages in HP-UX

I PuTTY to a HP-UX box, and when I run top command, it only displays the first 21 processes. I also see on the top right hand corner of the list there is a header that says Page# 1/12. I need to know, in such environment, how I can navigate/scroll through pages to view other processes. (I have tried everything from PgUp/PgDown, and pretty much every key with Shift/Alt/Ctrl at no avail.
Try increasing the scrollback (default is 200) and using SHIFT+PAGEUP/SHIFT+PAGEDOWN.
http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter3.html#using-scrollback
http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter4.html#config-scrollback
Depending on the environment/tools sometimes just spacebar works for me as well.
To navigate, use the following:
j : Next screen
k : Previous screen
l : First screen
I don't think one can scroll on top output, not sure about HP-UX though I believe it should be same behaviour, Did you try using number (eg. press 2 for second page, or n for next page ..just a guess )
There are couple of option if you want to see all process...
1. use htop where you can use page up/page down (or up and down arrow key) to scroll
2. run the top command only one iteration using -n option and take output in any file
top -b -n 1
3. ps -ef command can give you list of all process, ps command also have option to sort output based on %CPU or %MEM

Unicode character bug upon exiting tmux with alternate screen overridden

I've removed and added a few times now the following line to ~/.tmux.conf:
set -ga terminal-overrides ',xterm*:smcup#:rmcup#'
Which according to the person who provided it does the following:
to fool the multiplexers into thinking that the terminal has no "alternate screen" mode (such as that used by pico, mutt, etc). This is accomplished by setting termcap commands for the session.
The 'xterm*' part of the command should be set to whatever your terminal-emulator is declared as.
The end result is that the overflow ends up in the terminal's scrollback buffer instead of disappearing. Of course, since this is one static buffer, things will get messy as you switch between screen or tmux windows, but this is handy for quickly flicking up to see the output of an ls command or the such.
I don't quite understand the bolded section (emphasis added), but guess this is the source of what I'm seeing. It's causing some weird sort of unicode overspill upon exiting tmux.
Pasted as plaintext this text won't show up, but the symbol [001B]112 appears alongside the usual [exited]:
]112[exited]
(FWIW I think it has pasted in that line, but isn't displaying)
I followed this advice ("Use terminal scrollbar with tmux"), and while it does work, this is just ugly/annoying to see that upon exiting. Can anyone advise how to fix or avoid the output message?
Offhand, I would get the unwanted "message" is some hard-coded application (or script) which is helpfully resetting the xterm dynamic text cursor color. See XTerm Control Sequences in the description of Operating System Controls:
The dynamic colors can also be reset to their default
(resource) values:
...
Ps = 1 1 2 -> Reset text cursor color.
So... somewhere there is some script doing the equivalent of
echo -n -e '\e]112\a
The results probably depend most on what particular terminal emulator you are using. Both screen and tmux filter out escape sequences that their developers did not care to implement, and pass through those that the terminal "should" handle.
Just take a look at sentence you provided: "The 'xterm*' part of the command should be set to whatever your terminal-emulator is declared as."
In my case, the $TERM has value xterm-256color and the corresponding line in ~/.tmux.conf looks like:
set -g terminal-overrides "xterm-color256:smcup#:rmcup#"

RStudio HiDPI support

RStudio is great IDE for R development. I wonder if there is any way for nice support HiDPI resolution?
I currently have 13 inch display and 3200x1800 resolution, it is even hard to read RStudio options to adjust more appropriate setting.
This is of course not an RStudio issue but general issue related to high resolution display which requires HiDPI support to make it reasonably usable.
Posting it here as question because RStudio still doesn't allow to fill questions/issues on github.
RStudio is a Qt application. I've solved this by setting a scaling factor in Qt with this environment variable (note it must be an integer):
export QT_DEVICE_PIXEL_RATIO=2
The Arch wiki has some excellent advice on getting HiDPI working.
UPDATE: This solution is only for WINDOWS!
There is a simple solution for you, it comes from the option "Compatibility" of the execute file.
Close all current RStudio windows.
Right click on the shortcut of RStudio (or the original exe file) and choose Properties
In the RStudio Properties pop-up windows, choose the tab Compatibility
Tick on option Override hide DPI scaling... and then choose System from the drop-down list.
Apply > OK.
(Re)open Rstudio to see the change
Note that, on the HiDPI screen, resolution of modified RStudio is not so good but it really solved the bad scale problem.
You can also apply this technique to other apps without supporting HiDPI.
I use the following bash script to determine the current screen resolution and substitute the scaling factor by 1 (normal resolution) or 1.75 (high resolution) in the RStudio desktop file:
#!/bin/bash
# Determine resolution
width=$(xdpyinfo | grep 'dimensions:' | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//')
echo "Screen width is $width pixels"
if [ $width -gt 3000 ]; then
echo "High resolution detected -> setting zoom level to 1.75"
sed -i 's/view.zoomLevel.*/view.zoomLevel=1.75/' ~/.config/RStudio/desktop.ini
else
echo "Normal resolution detected -> setting zoom level to 1.0"
sed -i 's/view.zoomLevel.*/view.zoomLevel=1/' ~/.config/RStudio/desktop.ini
fi
QT_QPA_PLATFORMTHEME=gtk2 /usr/lib/rstudio/bin/rstudio %F
I am on Ubuntu 17.10. If I want to use the GTK theme, I have to set the QT_QPA_PLATFORMTHEME environment variable.

Vim with R-plugin and LaTeX-Suite results in backslash in insert mode misbehaving

Here's what happens. I'm using Vim + LaTeX-Suite to edit TeX files in Vim. This could be in the Terminal or in MacVim.
I happily
Insert lots of $\LaTeX \commands$ etc. I love using the $\backslash$.
TeX works great. No problem.
Then I go and open up a .R file in the same window (different tab). R-Plugin for Vim uses the <Leader> key (mapped to \ as per usual) to execute commands, e.g. I type \sa to send the selection to R and execute and move the window down. Life is nice.
Problem: even though while editing an R file, Vim is nice enough not to bug me in insert mode when I type \, for some reason when I switch back to the tab to edit the TeX file, then type \ in insert mode, it moves the cursor left of the \ and pauses as though waiting for the rest of the command, before then re-moving to the right of the \ and moving on as I type.
Below shows what happens just from typing \ in insert mode; obviously I could reproduce this by moving the cursor to the left with the arrow keys, but that's not how this happened--the cursor just moves left for a split second as though waiting for the R command to finish being input.
So: how can I stop the annoying behavior in the TeX file insert mode, without sacrificing other functionality? Note, (a) I don't expect mapping <Leader> to a different key to help since then that key will just have the same left-cursor-move problem in TeX; (b), I like the leader as \ anyway so I don't want to change it.
Put this line in your vimrc (requires Vim-R-plugin >= 0.9.9.2):
let g:vimrplugin_insert_mode_cmds = 0
If the problem persists, you can do the following in Normal mode to know what are the keyboard shortcuts in Insert mode:
:imap

Resources