bash_profile
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash_profile [2024/08/23 16:28] – steve | bash_profile [2026/08/10 19:37] (current) – steve | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| <code bash .bash_profile> | <code bash .bash_profile> | ||
| # | # | ||
| + | echo ' | ||
| + | PersonalServer=usmifmomlnxv001 | ||
| + | Tmp=" | ||
| + | Host=" | ||
| # | # | ||
| # | # | ||
| - | # Set our time-zone, otherwise we get UTC and have to think; | + | # Set our time-zone; |
| export TZ=" | export TZ=" | ||
| - | # Set defaults for the history stuff big and per machine. | ||
| - | # This is important because HOMEDIR is an nfs mount through | ||
| - | # autofs across most machines. | ||
| # Below doesn' | # Below doesn' | ||
| - | # file, only what it looks like with the history command. | + | # file, only what it looks like with the history command. |
| - | HISTTIMEFORMAT=" | + | HISTTIMEFORMAT=" |
| + | # Set defaults for the history file big and per machine. | ||
| HISTSIZE=11000 | HISTSIZE=11000 | ||
| HISTDIR=${HOME}/ | HISTDIR=${HOME}/ | ||
| - | mkdir -p ${HISTDIR} | + | mkdir -p ${HISTDIR} |
| - | HISTFILE=${HISTDIR}/ | + | # Should exist, but just to be certain. |
| + | HISTFILE=${HISTDIR}/ | ||
| + | |||
| + | function | ||
| + | # This lets you get the history for a machine you aren't on at the | ||
| + | # moment, along with the date and time you ran the command. | ||
| + | if [ $# -eq 0 ]; then | ||
| + | Q=${Host} | ||
| + | else | ||
| + | Q=${1} | ||
| + | fi | ||
| + | if [ -e ~/ | ||
| + | while IFS= read -r Line | ||
| + | do if [[ " | ||
| + | then date -d " | ||
| + | else echo " | ||
| + | fi | ||
| + | done < ~/ | ||
| + | else echo "No history for ${Q}" | ||
| + | fi | ||
| + | } | ||
| # And a thing to make and save logs, use like; | # And a thing to make and save logs, use like; | ||
| # <some program> | LOG | # <some program> | LOG | ||
| # Output goes to screen and log. | # Output goes to screen and log. | ||
| - | LOGFILE=${HISTDIR}/ | + | LOGFILE=${HISTDIR}/ |
| LOG () { | LOG () { | ||
| tee -a ${LOGFILE} | tee -a ${LOGFILE} | ||
| } | } | ||
| - | # Below shows ansi colors in log files. | + | function KeyBackup() { |
| + | sudo tar -czvf / | ||
| + | cp / | ||
| + | sudo rm / | ||
| + | } | ||
| alias less=' | alias less=' | ||
| + | # Above shows ansi colors in log files. | ||
| # If we're on the home machine, syncronize with OneDrive. | # If we're on the home machine, syncronize with OneDrive. | ||
| - | if [ "${HOSTNAME}" == "PersonalBox" ] ; then | + | if [ "${Host}" == "${PersonalServer}" ] ; then |
| - | onedrive --synchronize | + | |
| + | if [[ $(find / | ||
| + | onedrive --sync | ||
| + | touch / | ||
| + | echo ' | ||
| + | fi | ||
| + | fi | ||
| - | # And, if we' | + | # And, while we' |
| - | if [ -e ~/ | + | if [ " |
| - | | + | Files=( /Backup/*/Summary ) |
| + | if [[ -e " | ||
| + | egrep --color=never '^/Backup' | ||
| + | echo ' | ||
| fi | fi | ||
| fi | fi | ||
| - | # Get the aliases and functions | + | alias ls='ls --time-style=" |
| - | if [ -f ~/.bashrc ]; then | + | |
| - | . ~/.bashrc | + | |
| - | fi | + | |
| - | + | ||
| - | alias ls=' | + | |
| alias ll='ls -l' | alias ll='ls -l' | ||
| alias l='ls -altr' | alias l='ls -altr' | ||
| - | alias l.='ls -d .*' | + | alias Rel='cat /etc/*ease | grep PRETTY | cut -d " |
| - | alias R='cat /etc/*ease | grep PRETTY | cut -d " | + | alias Diary=' |
| - | alias D=' | + | alias Disks=' |
| - | alias I='ip a | grep -E " | + | alias IP='ip a | grep -E "inet\ |inet6\ "' |
| - | alias F='df -hlBM --output=source, | + | alias Free='df -lBG --output=source, |
| + | alias Last=' | ||
| + | [ -e / | ||
| + | alias P=' | ||
| + | alias Users=' | ||
| + | alias Root=' | ||
| + | alias RW=' | ||
| + | alias Count=' | ||
| + | alias Who=' | ||
| + | alias Wttr=' | ||
| - | # And, if you want the weather; | + | Rel=$(cat / |
| - | alias W='curl wttr.in' | + | |
| - | cat /etc/*ease | grep PRETTY | + | # This line does a good job of identifying what we're running on |
| + | Platform=$(cat /sys/class/ | ||
| + | if [ -z " | ||
| + | Platform=$(dmesg | ||
| + | fi | ||
| + | |||
| + | if [ -z "${Platform}" | ||
| + | Platform=$(hostnamectl | grep -i ' | ||
| + | fi | ||
| - | # ~/bin is usually a link to a shared bin folder. | ||
| if [ -d ~/bin ] | if [ -d ~/bin ] | ||
| then | then | ||
| Line 64: | Line 111: | ||
| fi | fi | ||
| - | # ~/ | ||
| if [ -d ~/ | if [ -d ~/ | ||
| then | then | ||
| Line 70: | Line 116: | ||
| fi | fi | ||
| - | # This line lists out the aliases with capital letters | + | echo ${Rel} on ${Platform} |
| - | echo ' | + | echo ' |
| + | |||
| + | echo -n " | ||
| + | ip route get 1.1.1.1 | awk ' | ||
| + | echo ' | ||
| + | |||
| + | echo ' | ||
| + | echo ' | ||
| + | |||
| + | # And, finally, if we're on the home machine, run ~/.sshrc | ||
| + | if [ " | ||
| + | then | ||
| + | if [ -e ~/.sshrc ] | ||
| + | then | ||
| + | . ~/.sshrc | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | # If dealing with systemctl unit files, export vim as editor if it exists; | ||
| + | if [ -e / | ||
| + | then | ||
| + | export SYSTEMD_EDITOR=/ | ||
| + | fi | ||
| + | |||
| + | # For a multi-line prompt that can easily be copied and pasted; | ||
| + | export PS1=" | ||
| # vim: | # vim: | ||
| </ | </ | ||
bash_profile.1724430497.txt.gz · Last modified: by steve
