Skip to content

Commit

Permalink
Added two tiny, but useful utility functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
seldon committed Nov 15, 2013
1 parent 7799685 commit a667039
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions shell/.bash.d/utils.sh
@@ -0,0 +1,19 @@
## outputs the number of (regular) files contained within a given directory
# if invoked without an argument, defaults to the current directory
function count-files {
dir=$1 || $CWD
find $dir -type f |wc -l
}

## converts a man page to a PDF file
# Usage: man2pdf <COMMAND> [OUTPUT_DIR]
# where COMMAND is the shell command/program whose manual page is to be
# converted and OUTPUT_DIR is the filesystem directory where to place the
# generated PDF file (defaults to the current directory).

function man2pdf {
command=$1
out_dir=$2 || $PWD
out_fname=${command}_manpage.pdf
man -Tps $command | ps2pdf - ${out_dir}/${out_fname}
}

0 comments on commit a667039

Please sign in to comment.