User:Eleanorg/Custom 'man'command

From XPUB & Lens-Based wiki

This is a simple shell script to customise the 'man' command in your terminal. It plays on the abbreviation of 'manual' to 'man' in the command syntax - rather appropriate as, being female, the first thing you do when you need help on your computer is locate a man.

The 'man' you've commanded greets you with a stereotypical phrase - you don't know whether it will be helpful, patronizing or even a bit creepy. CustomManCommand1.png

 

#!/bin/bash

#To be used with alias 'man' to simluate an actual man instead of manual prompt
# Usage: 
# 1. Save this script as man.sh and make executable. 
# 2. Create the following alias in .bashrc file: alias man='man.sh'
# 3. When you need help in the terminal, type: man

# Array of remarks:
Remarks=( "Can you pass me the keyboard?" 
"Well you won't be able to do it with a GUI"
"Shall I show you how to fix it?"
"It'll be quicker if I do it"
"Have you tried turning it off and on again?"
"Well if you insist on using proprietary software..."
"Though you'll have to make it worth my while..."
"Hm. Leave it with me and come back next week."
"So you didn't take a note of the error message?" )

# Array of names:
Names=( "Dave"
"Silvio"
"Mr. Stock"
"Michael"
"Aymeric"
"Laurier"
"Jonas"
"Leiven" )

# Count how many elements in each array:
num_remarks=${#Remarks[*]}
num_names=${#Names[*]}

# echo random name and random remark
echo "Hi, ${Names[$((RANDOM%num_names))]} here."
echo "Now let's take a look...."
echo ${Remarks[$((RANDOM%num_remarks))]}

#Syntax learnt:
#Creating an array and calling array values
#Specifying shell to use in first line
#Array values containing empty space & single quotes