Date created: Tuesday, September 6, 2016 10:53:33 AM. Last modified: Thursday, October 6, 2022 1:49:18 PM
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 $@ 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 $@ 2>&1 | tee $logDir/`gdate +"%Y-%m-%d--%H-%M-%S-%N"`-$1.txt } telnet () { /usr/bin/telnet $@ 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 $adusername@10.116.26.11' # Cisco 2960 ToR switch Rack 1 alias lab-2960-rack2='ssh $adusername@10.116.26.12' # Cisco 2960 ToR switch Rack 2 alias lab-2960-rack3='ssh $adusername@10.116.26.13' # Cisco 2960 ToR switch Rack 3 alias lab-2960-rack4='ssh $adusername@10.116.26.14' # Cisco 2960 ToR switch Rack 4 alias lab-2960-rack5='ssh $adusername@10.116.26.15' # Cisco 2960 ToR switch Rack 5 alias lab-2960-rack6='ssh $adusername@10.116.26.16' # Cisco 2960 ToR switch Rack 6
Previous page: 'adb' - Notes
Next page: Allow sudo command without password