Navigate through Top Command's Pages in HP-UX - unix

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

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.

How to scroll up in Vim buffer with R (using Nvim-R)

I'm a happy user of the Nvim-R plugin, but I cannot find out how to scroll up in the buffer window that the plugin opens with R. Say for instance that I have a large output in console, but I cannot see the top of it - how do I scroll up to see this? In tmux for instance there's a copy mode that quite handily lets you do this, but how is this done in the R buffer?
An example below where I'm very curious to see what's on the line above the one begining with "is.na(a)...". How can this be achieved?
I have scoured the documentation found here, but without luck.
The answer is apparently to use Ctrl+\ Ctrl+n according to this answer on the bugreports for NVim-R.
Here's what my output looks like when I output mtcars:
When I hit Ctrl+\ Ctrl+n, I can move the cursor and I get line numbers:
To get back to interactive, I just use i, the same way I normally would.
Apparently, if you are using neovim, then you can add let R_esc_term = 0 in your ~/.vimrc file and you can then use the escape key, but if you don't use neovim, you are stuck using the two ctrl commands ¯\_(ツ)_/¯.
As pointed out by ZNK, it is about switching to normal mode in Vim's terminal. This, however, can easily fail due to cumbersome keybinding. If such is the case, remap the default keybinding to something reasonable, say, by putting this in your .vimrc:
tnoremap jk <C-\><C-n>
This works for me in Linux running Vim 8.0 in terminal (e.g. does not require Neovim). As you can see, I use 'jk' to switch from insert to normal mode. One can use Esc instead of jk, however, this makes me unable to use up arrow to retrieve command line history as been reported elsewhere.

ZSH avoid adding empty commands to history?

In zsh (with oh-my-zsh, is that matters) when I enter empty commands (e.g. just press enter) I see empty lines added to my ~/.zsh_history:
: 1508496422:0;ls
: 1508496422:0;vim
: 1508496482:0;
: 1508496482:0;
: 1508496482:0;
: 1508496482:0;
: 1508496490:0;
: 1508496490:0;
: 1508496490:0;
: 1508496490:0;
: 1508496494:0;ls
I'm wondering if it's possible to avoid adding these lines. I checked http://zsh.sourceforge.net/Doc/Release/Options.html but no luck. The reason why I'm trying to avoid adding empty lines is I'm using fzf and fzf lists these empty commands when I search in last commands in a directory.
If this is not possible in zsh side I'll try to search for a solution in fzf side.
There are a few Zsh settings to control what goes into your history
(though I'm surprised emtpies end up there; I can't reproduce that
despite also using fzf and hitting blank RETs a lot).
The man page for zshoptions(1) describes:
HIST_IGNORE_[ALL_]DUPS — This should at least reduce your
consecutive multiple empties down to one.
HIST_IGNORE_SPACE — Your empties might be treated as whitespace
and thus be eliminated. I like this feature anyway for intentionall
discarding commands by starting them with a space.
There is also the HISTORY_IGNORE option (not to be confused with
Bash's HISTIGNORE) — described in zshparam(1) with an example —
which lets you remove a set of patterns. An empty pattern may fix
your case. It also has a zshaddhistory hook that you could use to
more finely control exactly what goes into history.

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#"

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