changing 'man' to use 'more' instead of 'less -is' as pager with 'alias' command
Disclosure:
Platform: Mac OS X 10.8.2 Mountain Lion bash --version: 3.2.48(1)-release (x86_64-apple-darwin12) ~/.bash_profile: currently empty, but compatible with test in #1 below. Problems: #1) Code:
alias Code:
alias helpme='echo goodie' if I then type Code:
alias Code:
alias helpme='echo goodie' I have found that pressing and holding \[ESC\] prompt me to see a list of commands and aliases (including any I just made). However, if I attempt to look at the definition of a (system-wide/default) alias, then I get, for example: Code:
alias pico Code:
pico cake Code:
nano cake #2) I would like to have man use more instead of less when I'm browsing man pages. I would like to do this for a couple reasons, one is so I can easily copy all the text to a GUI text editor, then work with it in my preferred program. Currently man actually uses less -is (ignore case, and squeeze blank lines respectively). So when I man less I get this: http://pastebin.com/5mkQdr9U On line 724, which is fantastic, it says: "You may define your own less commands by using the program lesskey (1)" However, looking at https://developer.apple.com/library/...lesskey.1.html Lets me see that: Quote:
So I went ahead and created the $HOME/.less file and put it Code:
LESS_IS_MORE=1 Also, I found it confusing in this section, but maybe it just means I can't do this anyjmore? line 724: Quote:
Then I put the line: Code:
LESSKEY=TRUE So, no idea where to go from there. So I also tried something else: I was also playing around with the /private/etc/man.conf file, and saw that these two lines might be easily changed to fix this issue. So I changed lines: 105-106 which read Code:
PAGER /usr/bin/less -is This worked, mostly. Now my man pages remain visible from the top to wherever I have paged down to so far, and then more exits with my final next-page command. Good enough. Of course this started out with me wanting to use an alias for the man + more combination which was going to be a syntax problem for me to solve, but I found it to be a little more complex. This is still my preference however, because currently I am changing the behavior of man system wide! I then found that killing a man command with control-\ yielded this: Code:
( cd '/usr/share/man' && /usr/bin/tbl /usr/share/man/man1/builtin.1 | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | ( /usr/bin/less -is || true ) ) investigating further by reading man man then man man.conf I came across the relevant two lines. A question I have related to this is: is it generally not a good idea to edit files in /private ? I've edited the hosts file (/private)/etc before to stop from connecting to ad servers. But beyond that, I'd rather not even do that system wide actually. So I guess I may have a partial, though not ideal solution to #2. But I would still like to be able to find out the definition of an alias, and ideally... make more complicated aliases than l='ls -l' (very annoying that this is not a default alias on Mac if you ask me). Why don't I just use something like: Code:
man man >> myfavmanpageatm because, then I look at that file with nano and it looks like this: Code:
man(1) man(1) the flags are all repeated, so it looks like: -ii ignore case -ss squeeze lines etc. EDit: I have figured out that those symbols can be read by 'more'... so, is there a way to remove those and have it readable by nano? May Loki help me, I know this is a long one... |
Quote:
Quote:
Quote:
Code:
alias man='man -P more' Quote:
Code:
LESSKEY=$HOME/.less # or choose another file, if you like Quote:
Code:
tr -cd '[:print:][:space:]' |
Quote:
However, why can't I get the definition of a system alias? Is it perhaps that pico is just a symlink and not a shell alias at all? Since the single command alias with no flags/args returns nothing (when I have none in my bash profile) does that mean there are no aliases defined by default by the system? So, as admin we have the record of what happens in my first post, but now I thought to try sudo: Code:
sudo alias pico Another obvious point: Quote:
The other part of the problem is that the below still doesn't work. But that's fine, it's one less file to mess around with (no pun intended). And since we were cautioned by apple to just 'investigate' I'm not sure it'll ever work. For completeness I did try it as below however: Code:
#inside ~/.less: About tr , Quote:
Code:
man man | tr -cd '[:print:][:space:]' >> man.man Also, I could do this: Code:
man less | nano of course I can do this (but it's almost as ugly): Code:
man less | nano yoyo |
Quote:
Quote:
Quote:
Put this ~/.lesskey Code:
#command Code:
lesskey ~/.lesskey Quote:
I haven't tested the tr command though, since on my system redirecting man to a file doesn't produce any problem characters. I was guessing that the ^Hs are control characters, but on the off chance they have been escaped somewhere along the line, you could try sed 's/\^H//g' Quote:
|
Thanks a mil
Hi there again, thanks again for this, we had to get our program out so the last couple months have been rather the heaviest of my life...
Quote:
Quote:
::SADFACE!:: Quote:
Quote:
Code:
man man | sed 's/\^H//g' >> man.man so, I guess for now I have to settle for: Code:
$ man man | nano manman I thought some the special characters might be denoting color, but even in a b&w terminal session the commands all have the same output. Thanks again for checking this all out. I'm going to mark this as solved, because we've gone far and beyond answering the items in the title of the question. If you're still interested in working on the formatting issue, feel free, I'll definitely update this issue if/when I come across a more suitable solution. Thanks ntubski! |
According to this Linux man page howto: 10. How do I get a plain text man page without all that ^H^_ stuff?
Code:
man man | col -bx > man.man |
Fantastic! That does the trick, thank you so much for going on this journey of discovery with me! I'm glad we both got something out of the trip (sounds like)!
|
All times are GMT -5. The time now is 01:03 AM. |