Skip to content

Commit

Permalink
A bunch of cleanup
Browse files Browse the repository at this point in the history
Wrapped the .toprc configuration in it's own fuction and performed sensible setup & takedown of the .toprc file.
  • Loading branch information
Node0 committed Jan 29, 2016
1 parent 04abf17 commit aacf0ed
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions BASH/activityLog/activityLog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/env bash
#!/bin/bash

# Notice
# ----------------------------------------------------------------
Expand Down Expand Up @@ -243,11 +243,8 @@ fi
cd ~


if [[ -f ~/.toprc ]];
then
"${mv}" ~/.toprc ~/.backup_toprc;

echo "RCfile for \"top with windows\"
function configureTop {
topRcContents="RCfile for \"enhanced top metrics\"
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
winflags=30137, sortindx=10, maxtasks=0
Expand All @@ -260,9 +257,36 @@ Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX
winflags=62777, sortindx=4, maxtasks=0
summclr=3, msgsclr=3, headclr=2, taskclr=3" > ~/.toprc;
fi
summclr=3, msgsclr=3, headclr=2, taskclr=3";

if [[ $1 == "--setup" ]];
then
if [[ -f ~/.toprc ]];
then
prevConfigExists=1;
"${mv}" ~/.toprc ~/.backup_toprc;
echo "${topRcContents}" > ~/.toprc;
else
prevConfigExists=0;
echo "${topRcContents}" > ~/.toprc;
fi
fi

# Restore the .toprc file which we backed up previously
if [[ $1 == "--restore" ]];
then
if [[ -f ~/.backup_toprc && ${prevConfigExists} == 1 ]];
then
"${mv}" ~/.backup_toprc ~/.toprc
else
if [[ -f ~/.toprc && ${prevConfigExists} == 0 ]]
then
"${rm}" -f ~/.toprc;
fi
fi
fi
}
configureTop --setup;

function uptimeString {
"${uptime}" |\
Expand Down Expand Up @@ -368,6 +392,4 @@ fi
# that we've changed back to how
# we found them before this script ran.
HOME="${homeDirEnvBackup}";

# Restore the .toprc file which we backed up previously
"${mv}" ~/.backup_toprc ~/.toprc
configureTop --restore;

0 comments on commit aacf0ed

Please sign in to comment.