32

--

Display and Create Aliases


#!/bin/bash

function display_aliases
{
  if [ -f ~/.bash_aliases ]; then
    cat ~/.bash_aliases
  else
    echo "There isn't any aliases yet..."
  fi
}

function create_alias
{
  echo "type the alias in the form \"ls='ls -h'\""
  read input
  echo "alias $input" >> ~/.bash_aliases
  echo "done"
}

while n=1; do
  echo "Please choose an option:"
  echo "1: Display aliases"
  echo "2: Create aliases"
  echo "3: Quit"
  echo "#?"
  read input

  if [ "$input" = "1" ]; then
    clear
    display_aliases;
    echo
  elif [ "$input" = "2" ]; then
    clear
    create_alias;
    echo
  elif [ "$input" = "3" ]; then
    clear
    echo "Exiting..."
    exit
  else
    clear
    echo "Invalid - Please try again";
    echo
  fi
done

Comments

Please sign in or sign up to comment.