# How to return to command line prompt after reading manual page



## PawillyLanc (Apr 30, 2019)

I am trying FreeBSD for the first time and installed Release 12.0 Stable on my laptop. I have brought up the manual page for the command man and, after reading through to "end", cannot return to the command line prompt. If I am correct, typing 0 should exit, but doesn't. Your guidance (and patience with this basic question) will be appreciated. Thank you.


----------



## gpw928 (May 1, 2019)

Hi,

Your man(1) command will be using a pager to display the manpage.

The pager to use may be set in the environment with either the PAGER or MANPAGER environment variables.  It defaults to "less -sR".

The method you use to escape from less(1) depends on the options with which it was invoked.

You generally type "q" to exit less(1), though I believe that, with the default options used by man(1),  hitting the space bar will do it too.

You can also set the default  options used by less(1).  I have the following in my shell profile:

```
LESS="-smeqX"; export  LESS
```
Cheers,


----------



## F1R3-R4H (May 1, 2019)

You're using Xorg? Try to cut it with "ctrl + z"; it doesn't matter if you not, because it applies also to CLI mode.


----------



## linux->bsd (May 1, 2019)

Funny enough, one of the annoyances I find with FreeBSD is that man() exits after you reach EOF, and also doesn't restore the terminal's text. I also don't get the logic behind continuing to use more() as the default pager instead of less().


----------



## ralphbsz (May 1, 2019)

Funny how tastes differ!  I don't like the fact that less is the default pager.  I would much rather use a trivial version of more, which just immediately exists if there is less than a page, and only need space bar or "q" to get out.  And I really don't want to press the final space bar at the end; more can just exit.  And restoring the screen content is evil: If I say "man foo", it is because I want to see the man page of foo.  Hiding it again at the end is dumb ... it prevents me from keeping the information on the screen and referring back to it later.

In a nutshell, today's less has a huge amount of functionality that I don't need.  In and of itself that's not a bad thing, but it gets in the hair when it gives me a complex prompt, refuses to exit when it is no longer needed, and messes with my screen.

If this bothered me a lot, I would find some third-party version of more and install it, but it is not a huge deal.  For now I make do by hand-setting PAGER=more, MORE=-Er and LESS_IS_MORE.


----------



## Datapanic (May 1, 2019)

linux->bsd said:


> Funny enough, one of the annoyances I find with FreeBSD is that man() exits after you reach EOF, and also doesn't restore the terminal's text. I also don't get the logic behind continuing to use more() as the default pager instead of less().



Restoring the terminal text is Linux like behavior.   I think that you can create an . rc file that will set things up the way you want.  .vimrc probably...


----------



## gpw928 (May 1, 2019)

linux->bsd said:


> Funny enough, one of the annoyances I find with FreeBSD is that man() exits after you reach EOF, and also doesn't restore the terminal's text.


One man's bug is another man's feature.

However it can be trained as you wish.

I have it exit the second time it reaches EOF, and always leave the screen as man painted it (because that will show what I wanted to find).

Getting all that to work on every variety of Unix/Linux I am obliged to use is a bit of a struggle, but possible:

```
[jatz.230] $ egrep "PAGER|LESS|EXINIT|case|esac" $HOME/.kshrc
PAGER=less
LESS="-smeqX"
EXINIT="set shiftwidth=4 nowrapscan ai magic"
case `uname -a` in
    Linux*) EXINIT="$EXINIT t_ti= t_te="
esac
export PAGER LESS EXINIT
[jatz.231] $ cat $HOME/.vimrc
set compatible ai sw=4
set t_ti=
set t_te=
set nowrapscan
```


----------



## SirDice (May 1, 2019)

F1R3-R4H said:


> You're using Xorg? Try to cut it with "ctrl + z"; it doesn't matter if you not, because it applies also to CLI mode.


This has nothing to do with Xorg, it's a feature of the shell. A ctrl-Z puts the current running process on "pause" in the background and drops you back to the shell. The process is still running but not active. You can get back to it with the `fg` command.



linux->bsd said:


> Funny enough, one of the annoyances I find with FreeBSD is that man() exits after you reach EOF,


That's more(1) behavior. 


linux->bsd said:


> I also don't get the logic behind continuing to use more() as the default pager instead of less().


Did you miss that storm? That switch actually happened not too long ago and caused many people to freak out over it. We have scores of threads with people being confused by the "sudden" different behavior of freebsd-update(8).


----------



## PawillyLanc (May 2, 2019)

Thanks to all for your helpful replies.


----------



## linux->bsd (May 2, 2019)

ralphbsz said:


> Hiding it again at the end is dumb ... it prevents me from keeping the information on the screen and referring back to it later.



I get your argument. less() has the `-X` flag which behaves exactly as you prescribed. But if I'm looking at the manpage it's usually just to get a clear definition of how a specific flag works, or to find the actual switch itself. Under those circumstances, my existing terminal text is much more valuable to me.



Datapanic said:


> I think that you can create an . rc file that will set things up the way you want. .vimrc probably...



Problem is I manage hundreds of remote boxes which don't have my custom configs. So I just roll with defaults everywhere and make changes once I'm interacting with the program. Example: I run top, then hit `a` and `P` immediately.



gpw928 said:


> Getting all that to work on every variety of Unix/Linux I am obliged to use is a bit of a struggle, but possible:



Very true. I used to have a very customized .tmux.conf file with `send-keys` key bindings for vim and bash. I now just use defaults everywhere instead.



SirDice said:


> Did you miss that storm?



Now that you mention it, I do remember reading your posts advising users on the new changes.

We truly are creatures of habit.


----------



## obsigna (May 2, 2019)

ralphbsz said:


> Funny how tastes differ!  I don't like the fact that less is the default pager.  I would much rather use a trivial version of more, which just immediately exists if there is less than a page, and only need space bar or "q" to get out.  And I really don't want to press the final space bar at the end; more can just exit.  And restoring the screen content is evil: If I say "man foo", it is because I want to see the man page of foo.  Hiding it again at the end is dumb ... it prevents me from keeping the information on the screen and referring back to it later.
> 
> In a nutshell, today's less has a huge amount of functionality that I don't need.  In and of itself that's not a bad thing, but it gets in the hair when it gives me a complex prompt, refuses to exit when it is no longer needed, and messes with my screen.
> 
> If this bothered me a lot, I would find some third-party version of more and install it, but it is not a huge deal.  For now I make do by hand-setting PAGER=more, MORE=-Er and LESS_IS_MORE.


For me exactly that is the most disturbing mess with less that the man pages just disapear when you hit the end. I use a remote terminal program which allows me to scroll back an unlimited count of lines of a session and as well search for key words in the whole in-/output which has been produced in its course. Sometimes I need to consult several man pages for getting some procedures straight, and having it left on screen is simply a must have for me. Therefore, one of the very first things which I do when setting up a new system is editing my .cshrc in order to exchange less by more and while I am already there also vi by nano.


----------



## Spartrekus (May 2, 2019)

ralphbsz said:


> Funny how tastes differ!  I don't like the fact that less is the default pager.  I would much rather use a trivial version of more, which just immediately exists if there is less than a page, and only need space bar or "q" to get out.  And I really don't want to press the final space bar at the end; more can just exit.  And restoring the screen content is evil: If I say "man foo", it is because I want to see the man page of foo.  Hiding it again at the end is dumb ... it prevents me from keeping the information on the screen and referring back to it later.
> 
> In a nutshell, today's less has a huge amount of functionality that I don't need.  In and of itself that's not a bad thing, but it gets in the hair when it gives me a complex prompt, refuses to exit when it is no longer needed, and messes with my screen.
> 
> If this bothered me a lot, I would find some third-party version of more and install it, but it is not a huge deal.  For now I make do by hand-setting PAGER=more, MORE=-Er and LESS_IS_MORE.



Do like me, make your _less_ yourself, it will taste better. I have about 2 to 3 sort of them, which can fit my needs.
clang is there by default, which is nice.

Regular users rely on what is available: more and less.

Maybe find one C code that might be suitable for your needs.


----------



## F1R3-R4H (May 3, 2019)

> This has nothing to do with Xorg, it's a feature of the shell. A ctrl-Z puts the current running process on "pause" in the background and drops you back to the shell.


That's why I put the next line: it doesn't if he/she is using X.


> The process is still running but not active.


 Should I care about a process that it's in such status? Look why I said this...in a fork of FreeBSD I had troubles with  zombies process  and because of that I had to uninstall that system. I didn't trusted in it. But this can't occur in FBSD? Or should I bring it with `fg` ?


----------



## Spartrekus (May 3, 2019)

you can adapt _tcless_ if you want. 

There is a short howto about man file format somewhereelse.


----------



## SirDice (May 3, 2019)

F1R3-R4H said:


> Look why I said this...in a fork of FreeBSD I had troubles with zombies process and because of that I had to uninstall that system.


A zombie process is something completely different and has nothing to do with background/foreground. A zombie process is a _dead_ (i.e. finished, done) process that's stuck in the process list. A CTRL-Z doesn't _exit_ the process, it puts it on hold in the background. 






						Zombie process - Wikipedia
					






					en.wikipedia.org


----------



## Deleted member 30996 (May 3, 2019)

I change my usr account .cshrc to the following when editing files after install.


```
setenv    PAGER    more
```

It's always been that way for me and displayed odd behavior with Portmaster among other things so I changed it back to Happiness for me.


----------



## Sevendogsbsd (May 3, 2019)

PawillyLanc said:


> Thanks to all for your helpful replies.


Curious why you are using STABLE? STABLE is a development version of FreeBSD. I will admit the names of the different versions confused me when I first started using FreeBSD. RELEASE is the production release of the operating system. You can use whichever version you like, but keep in mind there may be issues with development versions.


----------



## Spartrekus (May 3, 2019)

SirDice said:


> A zombie process is something completely different and has nothing to do with background/foreground. A zombie process is a _dead_ (i.e. finished, done) process that's stuck in the process list. A CTRL-Z doesn't _exit_ the process, it puts it on hold in the background.
> 
> 
> 
> ...



there are many alternatives to less tools.


----------

