Last active
August 29, 2015 14:12
-
-
Save adamancini/9a93e9d33e6a86ad01f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
set -ex | |
TEMP_DIR="$(mktemp -d -t XXXX)" | |
# cleanup | |
trap 'RESULT=$?; rm -rf "$TEMP_DIR" ; exit $RESULT' INT TERM EXIT QUIT | |
OLD_PWD="$PWD" | |
cd "$TEMP_DIR" | |
RESULT_DIR='linux_manpages' | |
RESULT_DIR_ABSOLUTE="$TEMP_DIR/$RESULT_DIR" | |
copy_manpages() { | |
TARGET="$1" | |
mkdir -p "$TARGET" | |
manpath | tr ':' "\n" | while read -r MANDIR; do | |
set -x | |
cd "$MANDIR" | |
MANDIR_UNDERSCORED="$(echo "$MANDIR" | tr '/' '_')" | |
# -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) | |
( set +e | |
if [ -z "$TARGET" ]; then | |
echo "missing TARGET" >&2 | |
exit 1 | |
fi | |
rsync -a --no-l --no-p --no-t --no-g --no-o --no-D -vL -- man* "$TARGET/$MANDIR_UNDERSCORED"/ >&2 | |
RESULT="$?" | |
case "$RESULT" in | |
0|23) exit 0 ;; # success | |
*) exit 1 ;; # failure | |
esac | |
) | |
done | |
} | |
copy_manpages "$RESULT_DIR_ABSOLUTE" | |
if [ "$1" = '-' ]; then | |
tar zc "$RESULT_DIR" | |
else | |
MANPAGES_TARBALL="$OLD_PWD/linux_manpages.tar.gz" | |
MANPAGES_TARBALL_TEMP="${MANPAGES_TARBALL}.tmp" | |
trap 'RESULT=$?; rm -rf "$MANPAGES_TARBALL_TEMP" "$TEMP_DIR" ; exit $RESULT' INT TERM EXIT QUIT | |
tar zcvf "$MANPAGES_TARBALL_TEMP" "$RESULT_DIR" | |
mv "$MANPAGES_TARBALL_TEMP" "$MANPAGES_TARBALL" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# from osx box: | |
# | |
# | |
# bash <(curl https://gist.githubusercontent.com/steakknife/7969875/raw/run_me_from_osx.sh) [email protected] | |
# | |
# | |
# note: This recreates "$HOME/Library/Application Support/Dash/Man Pages/Linux" | |
# todo: Then do something to make dash see them without adding to normal MANPATH | |
# | |
# | |
set -ex | |
WHERE="$HOME/Library/Application Support/Dash/Man Pages/Linux" | |
rm -rf "$WHERE" | |
mkdir -p "$WHERE" | |
ssh "$@" 'sh <(curl https://gist.githubusercontent.com/steakknife/7969875/raw/run_me_from_osx.sh) -' | tar zxv -C "$WHERE" | |
mv "$WHERE"/linux_manpages/* "$WHERE" | |
rmdir "$WHERE"/linux_manpages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment