Browse Source

Simplify help function, add help to mediacontrol.sh

master
Riyyi 6 years ago
parent
commit
28012b6257
  1. 37
      .scripts/mediacontrol.sh
  2. 56
      .scripts/vimplugin.sh
  3. 69
      dotfiles.sh

37
.scripts/mediacontrol.sh

@ -6,6 +6,42 @@ RELOAD="pkill -RTMIN+1 i3blocks"
[ -z "$2" ] && NUM="2" || NUM="$2"
help() {
B=$(tput bold)
N=$(tput sgr0)
cat << EOF
${B}NAME${N}
mediacontrol - control the volume of the system
${B}SYNOPSIS${N}
./mediacontrol.sh <command> [<arg1>]
${B}DESCRIPTION${N}
Commands can be truncated, i.e.
\`${B}mediacontrol.sh t${N}\` for \`${B}mediacontrol.sh toggle${N}\`
Arguments need to be of numeric value.
${B}COMMANDS${N}
${B}u*, up <amount>${N}
${B}d*, down <amount>${N}
${B}s*, set <volume>${N}
${B}t*, toggle${N}
${B}m*, mute${N}
${B}u*, unmute${N}
${B}getv*, getvolume${N}
${B}getm*, getmute${N}
EOF
}
case "$1" in
u*) pulsemixer --change-volume +"$NUM" ; $RELOAD ;;
d*) pulsemixer --change-volume -"$NUM" ; $RELOAD ;;
@ -15,4 +51,5 @@ case "$1" in
u*) pulsemixer --unmute ; $RELOAD ;;
getv*) pulsemixer --get-volume | awk '{print $1}' ;;
getm*) pulsemixer --get-mute ;;
*) help ;;
esac

56
.scripts/vimplugin.sh

@ -9,33 +9,33 @@ START="$DIR/start"
OPT="$DIR/opt"
help() {
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
echo "${BOLD}NAME${NORMAL}"
echo " vimplugin - vim plugin manager"
echo ""
echo "${BOLD}SYNOPSIS${NORMAL}"
echo " ./vimplugin.sh <command> [<arg1> <arg2>]"
echo ""
echo "${BOLD}COMMANDS${NORMAL}"
echo " init"
echo " Creates all the required directories/files."
echo ""
echo " install <url> [\"start\"/\"opt\"]"
echo " Install a new plugin, <url> need to be a valid \
GitHub URL,
start/opt to install the plugin in the start/opt directory \
(default: start)."
echo ""
echo " list <number>"
echo " Prints all the installed plugins, <number> prints \
just the plugin in that position."
echo " remove"
echo " Remove plugin, script will prompt a selection menu."
echo " update"
echo " Installs/updates all plugins from the config file."
echo ""
B=$(tput bold)
N=$(tput sgr0)
cat << EOF
${B}NAME${N}
vimplugin - vim plugin manager
${B}SYNOPSIS${N}
./vimplugin.sh <command> [<arg1> <arg2>]
${B}COMMANDS${N}
${B}init${N}
Creates all the required directories/files.
${B}install <url> ["start"/"opt"]${N}
Install a new plugin, <url> need to be a valid GitHub URL,
start/opt to install the plugin in the start/opt directory
(default: start).
${B}list <number>${N}
Prints all the installed plugins,
<number> prints just the plugin in that position.
${B}remove${N}
Remove plugin, script will prompt a selection menu.
${B}update${N}
Installs/updates all plugins from the config file.
EOF
}
init() {
@ -146,6 +146,6 @@ remove() {
if type "$1" 2> /dev/null | grep -q "function"; then
"$@"
else
echo "script: command not found: $1"
help
fi

69
dotfiles.sh

@ -14,39 +14,40 @@ FILES=$(find . \( -path ./.git -o \
-path ./screenshot.png \) -prune -o -type f -print)
if [ "$1" == "help" ] || [ "$1" == "" ]; then
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
echo "${BOLD}NAME${NORMAL}"
echo " dotfiles - file copy script for this repository"
echo ""
echo "${BOLD}SYNOPSIS${NORMAL}"
echo " ./dotfiles.sh <command> [<args>]"
echo ""
echo "${BOLD}COMMANDS${NORMAL}"
echo " list"
echo " Prints all the dotfiles added to this directory."
echo ""
echo " get <filepath>"
echo " Add file to this directory."
echo ""
echo " pull"
echo " For each file in this directory, copy that file \
on the system to this directory."
echo ""
echo " push"
echo " For each file in this directory, copy that file \
to its location on the system."
echo ""
echo " package [list]"
echo " List all the packages installed on the system."
echo ""
echo " package store"
echo " Store the list of all the installed packages on the \
system."
echo ""
echo " package install"
echo " Install all the core packages of the list."
B=$(tput bold)
N=$(tput sgr0)
cat << EOF
${B}NAME${N}
dotfiles - file copy script for the dotfiles repository
${B}SYNOPSIS${N}
./dotfiles.sh <command> [<args>]
${B}COMMANDS${N}
${B}list${N}
Print all files added to the dotfiles directory.
${B}get <filepath>${N}
Add file to the dotfiles directory.
${B}pull${N}
For each file in the dotfiles directory, copy that file on the system to
the dotfiles directory.
${B}push${N}
For each file in the dotfiles directory, copy that file to its location
on the system.
${B}packages [list]${N}
List all the packages installed on the system.
${B}packages store${N}
Store the list of all the installed packages on the system.
${B}packages install${N}
Install all the core packages of the list.
EOF
elif [ "$1" == "list" ]; then
for f in $FILES; do
@ -91,7 +92,7 @@ elif [ "$1" == "pull" ] || [ "$1" == "push" ]; then
fi
done
elif [ "$1" == "package" ]; then
elif [ "$1" == "packages" ]; then
PACKAGE_LIST=$(comm -23 <(pacman -Qeq | sort) <(pacman -Qgq base base-devel | sort))
if [ "$2" == "list" ] || [ "$2" == "" ]; then

Loading…
Cancel
Save