#!/bin/bash

# http://www.shellperson.net/using-sudo-with-an-alias/
alias sudo='sudo '

alias grep='grep --color=auto'

# always show English man pages
alias man='LANG=C man'

if command -v vim &> /dev/null;
then
  alias vimdent='vim -esc "normal gg=G" -c "wq"'
fi

if command -v ccze &> /dev/null;
then
  function ct()
  {
    local FILENAME="$1"
    shift
    # The $@ means that we can pass
    # additional parameters to tail
    tail "$@" -f "$FILENAME" | ccze
  }
  complete -f ct
fi

if command -v dot &> /dev/null;
then
  function dot2png()
  {
    local FILENAME="$1"
    dot -Tpng "$FILENAME" > "$(basename "$FILENAME" .dot).png"
  }
fi

if command -v tidy &> /dev/null;
then
  alias htmltidy='tidy -utf8 -asxhtml -i -access 1'
fi

if command -v diff &> /dev/null;
then
  # Can be used with programs which expect a diff as input, e.g.:
  # filediff file.c | .../linux/scripts/checkpatch.pl -
  function filediff()
  {
    echo "Signed-off-by: "
    diff -pruN /dev/null "$@"
  }
fi

# Drupal coding standard checks using Code Sniffer:
# https://www.drupal.org/node/1419980
if command -v phpcs &> /dev/null;
then
  alias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"
fi