Date created: 09/06/16 10:53:33. Last modified: 08/07/19 10:55:12

Aliases

In ~/.bashrc on Linux or .bash_profile on Mac:

# Longer history with timestamps
shopt -s histappend
export HISTCONTROL=ignoredups:ignorespace
export HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '
export HISTSIZE=100000
export HISTFILESIZE=100000

# Custom prompt string
PS1='`
if [ $? -eq 0 ];
then echo -n "\[\e[00;30m\]\u\[\e[01;32m\]@\[\e[00;30m\]\h \[\e[01;32m\][\[\e[00;30m\]\D{%F %T}\[\e[01;32m\]] (\[\e[00;30m\]\W\[\e[01;32m\])\$";
else echo -n "\[\e[00;30m\]\u\[\e[01;31m\]@\[\e[00;30m\]\h \[\e[01;31m\][\[\e[00;30m\]\D{%F %T}\[\e[01;31m\]] (\[\e[00;30m\]\W\[\e[01;31m\])\$";
fi`\[\033[0m\]'

# User specific aliases and functions source ~/.my-aliases.sh source ~/.other-aliases.sh
# Always start a screen session if [ -z "$STY" ]; then screen -R; fi

In ~/.my-aliases.sh

#!/bin/bash

adusername="james.bensley.domain"
logDir="$HOME/.ssh/logs"
mkdir -p $logDir

ssh () {
  /usr/bin/ssh [email protected] 2>&1 | tee $logDir/`date +"%Y-%m-%d--%H-%M-%S-%N"`-$1.txt
# On Mac, gdate comes from "brew install coreutils"
# /usr/bin/ssh [email protected] 2>&1 | tee $logDir/`gdate +"%Y-%m-%d--%H-%M-%S-%N"`-$1.txt } telnet () { /usr/bin/telnet [email protected] 2>&1 | tee $logDir/`date +"%Y-%m-%d--%H-%M-%S-%N"`-$1.txt }

change () {
if [[ -n $1 ]]
then
eval $1 | tee -a ./$1.txt
fi
} # # Some Devices # alias lab-2801-1='telnet 10.116.26.20' # Cisco 2801 LAB RACK 2 alias lab-2801-2='telnet 10.116.26.21' # Cisco 2801 LAB RACK 4 alias lab-2960-rack1-30net='telnet 10.116.26.10' # Cisco 2960 ToR switch Rack 1 - 30 Network alias lab-2960-rack1='ssh [email protected]' # Cisco 2960 ToR switch Rack 1 alias lab-2960-rack2='ssh [email protected]' # Cisco 2960 ToR switch Rack 2 alias lab-2960-rack3='ssh [email protected]' # Cisco 2960 ToR switch Rack 3 alias lab-2960-rack4='ssh [email protected]' # Cisco 2960 ToR switch Rack 4 alias lab-2960-rack5='ssh [email protected]' # Cisco 2960 ToR switch Rack 5 alias lab-2960-rack6='ssh [email protected]' # Cisco 2960 ToR switch Rack 6