Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example in manual #253

Closed
mptre opened this issue Sep 24, 2017 · 11 comments
Closed

Update example in manual #253

mptre opened this issue Sep 24, 2017 · 11 comments

Comments

@mptre
Copy link
Owner

mptre commented Sep 24, 2017

I've always been bothered by the fact that I can't run one of the
examples in the manual without installing the missing utilities fltr
and tac:

$ apropos -l . | fltr | pick -do | tac | xargs man

Instead, I think we can come up with something as useful but portable.

Thoughts and ideas would be appreciated.

@ghost
Copy link

ghost commented Sep 30, 2017

How about:

apropos . | sed 's/ -/\t-/' | IFS=$'\t' pick -d | awk '{print $2 " " $1}' | tr -d '()' | xargs man

for the above example? (The -l switch to apropos seems not to be portable ...)

@mptre
Copy link
Owner Author

mptre commented Oct 1, 2017

Cool. But, I was hoping for something less complex but equally useful.
An example not related to finding manuals would be fine too.

@ghost
Copy link

ghost commented Oct 1, 2017

eval "$(fc -ln 1 | pick)" # Select a line in the command history to execute

... works with bash (version 3 & 4, not 2) and zsh (bash prints some superfluous leading spaces, but I want to avoid the use of cut or sed) ... also in README.md it should be:

cd "$(find . -type d | pick)"

... to deal with spaces in directory names ...

@mptre
Copy link
Owner Author

mptre commented Oct 1, 2017

eval "$(fc -ln 1 | pick)" # Select a line in the command history to execute

Very nice! This should be sufficient:

$ $(fc -ln | pick)
cd "$(find . -type d | pick)"

... to deal with spaces in directory names ...

Correct, care to draft a PR?

mptre added a commit that referenced this issue Oct 1, 2017
Replace example with a more portable but equally useful one. Proposed by
Jenz Guenther in PR #253.
@mptre
Copy link
Owner Author

mptre commented Oct 1, 2017

Does commit e50564b look good?

@ghost
Copy link

ghost commented Oct 1, 2017

eval is evil, but by omitting the 1 after -ln only the last 16 entries of the history will show up ...
I will craft a PR for README.md ...

mptre added a commit that referenced this issue Oct 1, 2017
Replace example with a more portable but equally useful one. Proposed by
Jenz Guenther in PR #253.
@mptre
Copy link
Owner Author

mptre commented Oct 1, 2017

eval is evil, but by omitting the 1 after -ln only the last 16 entries of the history will show up

Didn't know, fixed!

@mptre mptre closed this as completed Oct 1, 2017
@ghost
Copy link

ghost commented Oct 1, 2017

eval is evil

... but aliases will not be expanded without eval and result in a command not found-message ...
now I remember the reason for using the evil eval ... ;-)

mptre added a commit that referenced this issue Oct 2, 2017
Otherwise, aliases won't be expanded. Pointed out by Jenz Guenther in
issue #253.
@mptre
Copy link
Owner Author

mptre commented Oct 2, 2017

Thanks, fixed in commmit 031817f.

@ghost
Copy link

ghost commented Oct 3, 2017

My bad: quoting the command after eval is not really necessary ...

mptre added a commit that referenced this issue Oct 3, 2017
Pointed out by Jenz Guenther in issue #253.
@mptre
Copy link
Owner Author

mptre commented Oct 3, 2017

Right, thanks. Fixed in commit ae84349.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant