From 387053ffab4a0e7cd5b761dcb9724f2714b782c3 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Mon, 8 Aug 2022 17:35:54 +0200 Subject: [PATCH 1/3] Initial Release --- README.md | 69 +++++++++++++++++++++++++- install.sh | 118 +++++++++++++++++++++++++++++++++++++++++++++ latest_release.txt | 1 + src/bin/pman.sh | 45 +++++++++++++++++ src/man/pman.1 | 54 +++++++++++++++++++++ uninstall.sh | 11 +++++ 6 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 install.sh create mode 100644 latest_release.txt create mode 100644 src/bin/pman.sh create mode 100644 src/man/pman.1 create mode 100644 uninstall.sh diff --git a/README.md b/README.md index 03b5361..691fdd2 100644 --- a/README.md +++ b/README.md @@ -1 +1,68 @@ -Under construction +# Pman + +A simple tool that prints man pages in a PDF file (with vim keys support) for an easier reading. + +## Table of contents +* [Description](#description) +* [Installation](#installation) +* [Dependencies](#dependencies) +* [Usage](#usage) +* [Documentation](#documentation) + +## Description + +A simple tool that prints man pages in a PDF file (with vim keys support) via [Zathura](https://pwmt.org/projects/zathura/) for an easier reading, which also allows you to select the man page to display through a list generated via [Dmenu](https://tools.suckless.org/dmenu/). + +## Installation + +### AUR + +Arch (or Arch based distro) users can install the [pman](https://aur.archlinux.org/packages/pman "pman AUR package") AUR package. + +### From Source + +#### Installation + +Launch the following command in your terminal to execute the install script (requires "curl" and "sudo") : +``` +curl -s https://raw.githubusercontent.com/Antiz96/pman/main/install.sh | bash +``` + +#### Update + +Simply re-execute the install script (requires "curl" and "sudo") : +``` +curl -s https://raw.githubusercontent.com/Antiz96/pman/main/install.sh | bash +``` + +#### Uninstalling + +Launch the following command in your terminal to execute the uninstall script : +``` +curl -s https://raw.githubusercontent.com/Antiz96/pman/main/uninstall.sh | bash +``` + +## Dependencies + +Arch-Update depends on [zathura](https://pwmt.org/projects/zathura/) (and zathura-pdf-poppler) to print the PDF file and [dmenu](https://tools.suckless.org/dmenu/) to display the list of available man pages. + +## Usage + +Simply launch the `pman` command in your terminal to open the menu list of all the man pages available on your system, allowing you to search and select the man page you want to read. +You can also specify the man page to open directly in the command, like so : +``` +pman ls +``` + +Check the screenshots below for more information. + +### Screenshot + +## Documentation + +Refer to the [Wiki Documentation Page](https://github.com/Antiz96/pman/wiki/Documentation "Wiki Documentation Page"). +
+
+The full documentation is also available as a man page and with the "--help" function. +
+Type `man pman` or `pman --help` after you've installed the **pman** package. diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c1e3e87 --- /dev/null +++ b/install.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +pkgname="pman" +url="https://github.com/Antiz96/pman" +latest_release=$(curl -s https://raw.githubusercontent.com/Antiz96/pman/main/latest_release.txt) + +checksum=$(curl -Ls "${url}/releases/download/v${latest_release}/sha256sum.txt") +current_version=$("${pkgname}" -v 2>/dev/null) + +package() { + + package_manager=$( (ls /usr/bin/apt || ls /usr/bin/dnf || ls /usr/bin/pacman || ls /usr/bin/emerge) 2>/dev/null | awk -F/ '{print $4}' ) + + if [ -z "${package_manager}" ]; then + echo -e "This script only supports the following package manager to handle dependencies :\napt\ndnf\npacman\nemerge\n\nYour package manager is not supported\nYou'll need to install the following packages yourself to make \"pman\" work correctly (if you don't have them installed already)\nzathura\zathura-pdf-poppler\ndmenu" + fi + + if ! command -v zathura > /dev/null ; then + echo "Installing dependencies via ${package_manager} : zathura" + + case "${package_manager}" in + apt) + sudo apt install -y zathura > /dev/null || exit 1 + ;; + dnf) + sudo dnf install -y zathura > /dev/null || exit 1 + ;; + pacman) + sudo pacman -S --noconfirm zathura > /dev/null || exit 1 + ;; + emerge) + sudo emerge zathura > /dev/null || exit 1 + ;; + esac + fi + + case "${package_manager}" in + apt) + if ! apt list --installed | grep -q zathura-pdf-poppler ; then + echo "Installing dependencies via ${package_manager} : zathura-pdf-poppler" + sudo apt install -y zathura-pdf-poppler > /dev/null || exit 1 + fi + ;; + dnf) + if ! dnf list installed | grep -q zathura-pdf-poppler ; then + echo "Installing dependencies via ${package_manager} : zathura-pdf-poppler" + sudo dnf install -y zathura-pdf-poppler > /dev/null || exit 1 + fi + ;; + pacman) + if ! pacman -Q | grep -q zathura-pdf-poppler ; then + echo "Installing dependencies via ${package_manager} : zathura-pdf-poppler" + sudo pacman -S --noconfirm zathura-pdf-poppler > /dev/null || exit 1 + fi + ;; + emerge) + if ! qlist -I | grep -q zathura-pdf-poppler ; then + echo "Installing dependencies via ${package_manager} : zathura-pdf-poppler" + sudo emerge zathura-pdf-poppler > /dev/null || exit 1 + fi + ;; + esac + + + if ! command -v dmenu > /dev/null ; then + echo "Installing dependencies via ${package_manager} : dmenu" + + case "${package_manager}" in + apt) + sudo apt install -y suckless-tools > /dev/null || exit 1 + ;; + dnf) + sudo dnf install -y dmenu > /dev/null || exit 1 + ;; + pacman) + sudo pacman -S --noconfirm dmenu > /dev/null || exit 1 + ;; + emerge) + sudo emerge dmenu > /dev/null || exit 1 + ;; + esac + fi + + curl -Ls "${url}/archive/v${latest_release}.tar.gz" -o "/tmp/${pkgname}-${latest_release}.tar.gz" || { echo -e >&2 "An error occured during the download of the ${pkgname}'s archive\n\nPlease, verify that you have a working internet connexion and curl installed on your machine\nIf the problem persists anyway, you can open an issue at ${url}/issues" ; exit 1; } + + if ! echo "${checksum}" "/tmp/${pkgname}-${latest_release}.tar.gz" | sha256sum -c --status -; then + echo -e >&2 "\n${pkgname}'s archive integrity check failed\nAborting\n\nPlease, verify that you have a working internet connexion and curl installed on your machine\nIf the problem persists anyway, you can open an issue at ${url}/issues" + rm -f "/tmp/${pkgname}-${latest_release}.tar.gz" + exit 1 + else + echo -e "\n${pkgname}'s archive integrity validated\nProceeding to installation..." + fi + + tar -xf "/tmp/${pkgname}-${latest_release}.tar.gz" -C /tmp/ || exit 1 + chmod +x "/tmp/${pkgname}-${latest_release}/src/bin/${pkgname}.sh" || exit 1 + gzip "/tmp/${pkgname}-${latest_release}/src/man/${pkgname}.1" || exit 1 + sudo cp -f "/tmp/${pkgname}-${latest_release}/src/bin/${pkgname}.sh" "/usr/local/bin/${pkgname}" || exit 1 + sudo mkdir -p /usr/local/share/man/man1 || exit 1 + sudo cp -f "/tmp/${pkgname}-${latest_release}/src/man/${pkgname}.1.gz" /usr/local/share/man/man1/ || exit 1 + rm -rf "/tmp/${pkgname}-${latest_release}" "/tmp/${pkgname}-${latest_release}.tar.gz" || exit 1 +} + +if ! command -v "${pkgname}" > /dev/null ; then + echo "${pkgname} is going to be installed" + package + echo -e "\n${pkgname} has been successfully installed\nPlease, visit ${url} for more information\n\nThanks for downloading !" + exit 0 +elif [ "${current_version}" != "${latest_release}" ]; then + echo "A new update is available for ${pkgname}" + package + echo -e "\n${pkgname} has been successfully updated to version ${latest_release}\nPlease, visit ${url} for more information" + exit 0 +else + echo "${pkgname} is up to date -- reinstallation" + package + echo -e "\n${pkgname} has been successfully reinstalled\nPlease, visit ${url} for more information" + exit 0 +fi diff --git a/latest_release.txt b/latest_release.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/latest_release.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/src/bin/pman.sh b/src/bin/pman.sh new file mode 100644 index 0000000..ba563ff --- /dev/null +++ b/src/bin/pman.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +#Current version +version="1.0.0" + +#Replace the $1 var by "option" just to make the script more readable/less complex +option="${1}" + +#If the option passed to the "pman" command matches an available man page, print it to a PDF file via "zathura" +if man -k . | awk '{print $1}' | grep -iq ^"${option}"$ ; then + man -Tpdf "${option}" | zathura --mode=fullscreen - +else + case "${option}" in + #If no option is passed to the "pman" command, print the list of available man pages through "dmenu" and print the selected one to a PDF file via "zathura" + "") + man_selected=$(man -k . | awk '{print $1}' | dmenu -l 15) + + if man -k . | awk '{print $1}' | grep -iq ^"${man_selected}"$ ; then + man -Tpdf "${man_selected}" | zathura --mode=fullscreen - + else + man "${man_selected}" + echo >&2 "Try 'pman --help' for more information." + exit 1 + fi + ;; + #If the -v (or --version) option is passed to the "pman" command, print the current version + -v|--version) + echo "${version}" + exit 0 + ;; + #If the -h (or --help) option is passed to the "pman" command, print the documentation (man page) + #The documentation is also readable here https://github.com/Antiz96/pman/blob/main/README.md or by typing the following command in a terminal : man pman + -h|--help) + #Print the documentation (man page) and quit + man pman | col + exit 0 + ;; + #If any other option(s) are passed to the script, print an error and quit + *) + man "${option}" + echo >&2 "Try 'pman --help' for more information." + exit 1 + ;; + esac +fi diff --git a/src/man/pman.1 b/src/man/pman.1 new file mode 100644 index 0000000..91b2250 --- /dev/null +++ b/src/man/pman.1 @@ -0,0 +1,54 @@ +.TH "PMAN" "1" "August 2022" "Pman v1" "Pman Manual" + +.SH NAME +pman \- A simple tool that prints man pages in a PDF file (with vim keys support) for an easier reading. + +.SH SYNOPSIS +.B pman +[\fI\,OPTION\/\fR] [\fI\,MAN PAGE\/\fR] + +.SH DESCRIPTION +A simple tool that prints man pages in a PDF file (with vim keys support) via Zathura for an easier reading. It also allows you to select the man page to display through a list of all the available man pages on your system generated via Dmenu. + +.SH OPTIONS +.PP +.RB "If no option is passed, print the list of all the available man pages on the system, allowing you to search and select the one to print as a PDF." +.br +.br +.RB "You can also specify the man page to open directly in the command :" +.br +.RB "pman 'man page to open', ie: pman ls" +.PP + +.TP +.B \-v, \-\-version +Print the current version + +.TP +.B \-h, \-\-help +Print the help + +.SH EXIT STATUS +.TP +.B 0 +if OK + +.TP +.B 1 +if problems (user tried to open a non-existing man page...) + +.SH SEE ALSO +.BR zathura (1), +.BR dmenu (1), +.BR echo (1), +.BR grep (1), +.BR man (1), +.BR col (1), +.br +The documentation is also available on the GitHub page https://github.com/Antiz96/pman + +.SH BUGS +Please report bugs to the GitHub page https://github.com/Antiz96/pman + +.SH AUTHOR +Robin Candau diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..ca4f446 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +pkgname="pman" +url="https://github.com/Antiz96/pman" + +echo -e "${pkgname} is going to be uninstalled\n" + +sudo rm -f "/usr/local/bin/${pkgname}" || exit 1 +sudo rm -f "/usr/local/share/man/man1/${pkgname}.1.gz" || exit 1 + +echo -e "${pkgname} has been successfully uninstalled\nPlease, visit ${url} for more information" From d3da0ca0e2aff4c7ba0f9a2421611c882343342c Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Mon, 8 Aug 2022 19:01:08 +0200 Subject: [PATCH 2/3] Initial Release --- README.md | 18 +++++++++--------- install.sh | 8 ++++---- src/bin/pman.sh | 16 ++++++++-------- src/man/pman.1 | 12 ++++++------ uninstall.sh | 4 ++-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 691fdd2..855beef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pman +# Zaman A simple tool that prints man pages in a PDF file (with vim keys support) for an easier reading. @@ -17,7 +17,7 @@ A simple tool that prints man pages in a PDF file (with vim keys support) via [Z ### AUR -Arch (or Arch based distro) users can install the [pman](https://aur.archlinux.org/packages/pman "pman AUR package") AUR package. +Arch (or Arch based distro) users can install the [zaman](https://aur.archlinux.org/packages/zaman "zaman AUR package") AUR package. ### From Source @@ -25,21 +25,21 @@ Arch (or Arch based distro) users can install the [pman](https://aur.archlinux.o Launch the following command in your terminal to execute the install script (requires "curl" and "sudo") : ``` -curl -s https://raw.githubusercontent.com/Antiz96/pman/main/install.sh | bash +curl -s https://raw.githubusercontent.com/Antiz96/zaman/main/install.sh | bash ``` #### Update Simply re-execute the install script (requires "curl" and "sudo") : ``` -curl -s https://raw.githubusercontent.com/Antiz96/pman/main/install.sh | bash +curl -s https://raw.githubusercontent.com/Antiz96/zaman/main/install.sh | bash ``` #### Uninstalling Launch the following command in your terminal to execute the uninstall script : ``` -curl -s https://raw.githubusercontent.com/Antiz96/pman/main/uninstall.sh | bash +curl -s https://raw.githubusercontent.com/Antiz96/zaman/main/uninstall.sh | bash ``` ## Dependencies @@ -48,10 +48,10 @@ Arch-Update depends on [zathura](https://pwmt.org/projects/zathura/) (and zathur ## Usage -Simply launch the `pman` command in your terminal to open the menu list of all the man pages available on your system, allowing you to search and select the man page you want to read. +Simply launch the `zaman` command in your terminal to open the menu list of all the man pages available on your system, allowing you to search and select the man page you want to read. You can also specify the man page to open directly in the command, like so : ``` -pman ls +zaman ls ``` Check the screenshots below for more information. @@ -60,9 +60,9 @@ Check the screenshots below for more information. ## Documentation -Refer to the [Wiki Documentation Page](https://github.com/Antiz96/pman/wiki/Documentation "Wiki Documentation Page"). +Refer to the [Wiki Documentation Page](https://github.com/Antiz96/zaman/wiki/Documentation "Wiki Documentation Page").

The full documentation is also available as a man page and with the "--help" function.
-Type `man pman` or `pman --help` after you've installed the **pman** package. +Type `man zaman` or `zaman --help` after you've installed the **zaman** package. diff --git a/install.sh b/install.sh index c1e3e87..e6a17b9 100644 --- a/install.sh +++ b/install.sh @@ -1,8 +1,8 @@ #!/bin/bash -pkgname="pman" -url="https://github.com/Antiz96/pman" -latest_release=$(curl -s https://raw.githubusercontent.com/Antiz96/pman/main/latest_release.txt) +pkgname="zaman" +url="https://github.com/Antiz96/zaman" +latest_release=$(curl -s https://raw.githubusercontent.com/Antiz96/zaman/main/latest_release.txt) checksum=$(curl -Ls "${url}/releases/download/v${latest_release}/sha256sum.txt") current_version=$("${pkgname}" -v 2>/dev/null) @@ -12,7 +12,7 @@ package() { package_manager=$( (ls /usr/bin/apt || ls /usr/bin/dnf || ls /usr/bin/pacman || ls /usr/bin/emerge) 2>/dev/null | awk -F/ '{print $4}' ) if [ -z "${package_manager}" ]; then - echo -e "This script only supports the following package manager to handle dependencies :\napt\ndnf\npacman\nemerge\n\nYour package manager is not supported\nYou'll need to install the following packages yourself to make \"pman\" work correctly (if you don't have them installed already)\nzathura\zathura-pdf-poppler\ndmenu" + echo -e "This script only supports the following package manager to handle dependencies :\napt\ndnf\npacman\nemerge\n\nYour package manager is not supported\nYou'll need to install the following packages yourself to make \"zaman\" work correctly (if you don't have them installed already)\nzathura\zathura-pdf-poppler\ndmenu" fi if ! command -v zathura > /dev/null ; then diff --git a/src/bin/pman.sh b/src/bin/pman.sh index ba563ff..2f5e128 100644 --- a/src/bin/pman.sh +++ b/src/bin/pman.sh @@ -6,12 +6,12 @@ version="1.0.0" #Replace the $1 var by "option" just to make the script more readable/less complex option="${1}" -#If the option passed to the "pman" command matches an available man page, print it to a PDF file via "zathura" +#If the option passed to the "zaman" command matches an available man page, print it to a PDF file via "zathura" if man -k . | awk '{print $1}' | grep -iq ^"${option}"$ ; then man -Tpdf "${option}" | zathura --mode=fullscreen - else case "${option}" in - #If no option is passed to the "pman" command, print the list of available man pages through "dmenu" and print the selected one to a PDF file via "zathura" + #If no option is passed to the "zaman" command, print the list of available man pages through "dmenu" and print the selected one to a PDF file via "zathura" "") man_selected=$(man -k . | awk '{print $1}' | dmenu -l 15) @@ -19,26 +19,26 @@ else man -Tpdf "${man_selected}" | zathura --mode=fullscreen - else man "${man_selected}" - echo >&2 "Try 'pman --help' for more information." + echo >&2 "Try 'zaman --help' for more information." exit 1 fi ;; - #If the -v (or --version) option is passed to the "pman" command, print the current version + #If the -v (or --version) option is passed to the "zaman" command, print the current version -v|--version) echo "${version}" exit 0 ;; - #If the -h (or --help) option is passed to the "pman" command, print the documentation (man page) - #The documentation is also readable here https://github.com/Antiz96/pman/blob/main/README.md or by typing the following command in a terminal : man pman + #If the -h (or --help) option is passed to the "zaman" command, print the documentation (man page) + #The documentation is also readable here https://github.com/Antiz96/zaman/blob/main/README.md or by typing the following command in a terminal : man zaman -h|--help) #Print the documentation (man page) and quit - man pman | col + man zaman | col exit 0 ;; #If any other option(s) are passed to the script, print an error and quit *) man "${option}" - echo >&2 "Try 'pman --help' for more information." + echo >&2 "Try 'zaman --help' for more information." exit 1 ;; esac diff --git a/src/man/pman.1 b/src/man/pman.1 index 91b2250..664ad65 100644 --- a/src/man/pman.1 +++ b/src/man/pman.1 @@ -1,10 +1,10 @@ -.TH "PMAN" "1" "August 2022" "Pman v1" "Pman Manual" +.TH "ZAMAN" "1" "August 2022" "Zaman v1" "Zaman Manual" .SH NAME -pman \- A simple tool that prints man pages in a PDF file (with vim keys support) for an easier reading. +zaman \- A simple tool that prints man pages in a PDF file (with vim keys support) for an easier reading. .SH SYNOPSIS -.B pman +.B zaman [\fI\,OPTION\/\fR] [\fI\,MAN PAGE\/\fR] .SH DESCRIPTION @@ -17,7 +17,7 @@ A simple tool that prints man pages in a PDF file (with vim keys support) via Za .br .RB "You can also specify the man page to open directly in the command :" .br -.RB "pman 'man page to open', ie: pman ls" +.RB "zaman 'man page to open', ie: zaman ls" .PP .TP @@ -45,10 +45,10 @@ if problems (user tried to open a non-existing man page...) .BR man (1), .BR col (1), .br -The documentation is also available on the GitHub page https://github.com/Antiz96/pman +The documentation is also available on the GitHub page https://github.com/Antiz96/zaman .SH BUGS -Please report bugs to the GitHub page https://github.com/Antiz96/pman +Please report bugs to the GitHub page https://github.com/Antiz96/zaman .SH AUTHOR Robin Candau diff --git a/uninstall.sh b/uninstall.sh index ca4f446..8f51523 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,7 +1,7 @@ #!/bin/bash -pkgname="pman" -url="https://github.com/Antiz96/pman" +pkgname="zaman" +url="https://github.com/Antiz96/zaman" echo -e "${pkgname} is going to be uninstalled\n" From 934d82c4c3143a5fb0067becbac4039d40791e18 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Mon, 8 Aug 2022 19:08:22 +0200 Subject: [PATCH 3/3] Initial Release --- src/bin/{pman.sh => zaman.sh} | 0 src/man/{pman.1 => zaman.1} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/bin/{pman.sh => zaman.sh} (100%) rename src/man/{pman.1 => zaman.1} (100%) diff --git a/src/bin/pman.sh b/src/bin/zaman.sh similarity index 100% rename from src/bin/pman.sh rename to src/bin/zaman.sh diff --git a/src/man/pman.1 b/src/man/zaman.1 similarity index 100% rename from src/man/pman.1 rename to src/man/zaman.1