How to automaticly reset tmux window indexes - tmux

Let's say, I have five windows open in tmux session. I close the window at index 1, so I am left with windows on indexes 0, 2, 3 and 4. Is there a way to reinex them automaticly (so that the result would be 0, 1, 2 and 3)? I know i could switch positions of the windows until I get there, is there another way?

renumber-windows [on | off]
If on, when a window is closed in a session, automatically renum-
ber the other windows in numerical order. This respects the
base-index option if it has been set. If off, do not renumber
the windows.
Put it in your tmux conf.
set -g renumber-windows on

Related

VI editor “ESC” + X” do not work correctly

For some reason when I am on VI MODE editing a file, when I do a SHIFT+A to append and write something next to that, example tabs 81234. When I try to do ESC then x to delete the 1234 it doesn't work. First when I hit ESC cursor stays next to the 4, example tabs 81234[] when it should go back to 4, so hitting x wont delete the character only if I go up or down arrows i then can use x do delete.
I have other environments like UAT or MO with the exact same configuration and there it works with no issue.
Any ideas?

ESS (Emacs): do not change window configuration under R debugging (tracebug)

I would like to prevent ESS from changing my window configuration but when ESS tracebug is active, entering debugging changes the window configuration.
Suppose three windows in the emacs frame: (1) an R file that defines a function; (2) an R script that calls the function defined in (1); (3): the inferior R ess process. If from (2) I send code to the R interpreter, by default (2) gets replaced by (1) (showing the line to be evaluated, etc). The window showing (3) is left where it originally was; so we actually have the buffer that was in (1) shown twice (at 2 and at 1).
This happens to me under this configuration (starting emacs as emacs -Q)
(package-initialize)
(use-package ess)
I have an additional configuration (all in the spirit of "do not disrupt my window configuration: I'll tell you in what window to start by issuing M-x R there"):
(setq display-buffer-alist
'(("*R" . (display-buffer-same-window)))
)
With this configuration, under debug, window (2) now displays the R session (i.e., the inferior R buffer is shown at the original window location 3, and now at 2 also).
The screenshots below show this issue. The first screenshot with the three windows as described (1, 2, 3, from top to bottom).
The second screenshot (using the configuration of display-buffer-same-window) immediately after evaluating the function into R (C-c C-f), and then, from (2), evaluating the line (C-c C-n).
If I disable tracebug, M-x ess-tracebug, no window changes take place, but I do not want to disable following the execution on the window (window 1) that has the code. I would like to use tracebug but avoid any change to my window configuration: just show (1) with the debugging stuff, but leave (2) alone. How can I do that?
No answer, but I concur, I find it infuriating that ess changes the window configuration in an haphazard way, even duplicating buffers in another frame.

Limit line length in ansible's console output

When running ansible-playbook in a console, one could resize the console window to limit the line-length of the console output. ansible uses the fcntl.ioctl to get TIOCGWINSZ, when it finds a tty os.isatty(0) eg: (copied from /ansible/utils/display.py)
def _set_column_width(self):
if os.isatty(0):
tty_size = unpack('HHHH',
fcntl.ioctl(0, TIOCGWINSZ, pack('HHHH', 0, 0, 0, 0)))[1]
else:
tty_size = 0
self.columns = max(79, tty_size - 1)
Tools like man provide an environment variable MANWIDTH to provide this, without resizing the console window.
How can i resize the console output without resizing the console window?
The check in ansilbes os.isatty(0) checks if stdin is open, so the solution was to just redirect stdin, when invoking the command eg, i did:
ansible-playbook -v -i dev --check --diff playbook.yml 0</dev/null
NOTE: This does not limit the output of the modules, but that's another story, i guess.
EDIT: As can be seen in the function _set_column_width the output defaults to 79 char line length, when there is no tty (stdin is closed).

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

UNIX open multiple windows and pass login/password

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} &

Resources