I wanted to make a command that would take care of much of my formatting for me without the hassle of going back to the command and making major modifications depending on draft or final copy. So, I wrote this little stuff up to add to my tex_preamble.sh file.
...
\usepackage{ifthen}
\usepackage{fancyhdr}
\pagestyle{fancy}
...
\begin{document}
%% My Commands
\newcommand{\mycoursenum}{CHANGE THIS} %PHI 598
\newcommand{\mycoursename}{CHANGE THIS} %Science and Religion
\newcommand{\myname}{CHANGE THIS}
\newcommand{\mytimestamp}{\today--\currenttime}
\newcommand{\myhead}[1] % 2 options, "D" -- Draft or "F" -- Final
{
\ifthenelse{\equal{#1}{D}}{
\fancyhead{}
\fancyfoot{}
\fancyhead[RO,LE]{\myname}
\fancyhead[LO,RE]{\mytimestamp}
\fancyfoot[CO,CE]{\footnotesize \mycoursenum {\sc \mycoursename} -- \
\thepage}
}
{}
\ifthenelse{\equal{#1}{F}}{
\fancyhead{}
\fancyfoot{}
\fancyhead[RO,LE]{\myname}
\fancyfoot[CO,CE]{{\footnotesize \mycoursenum {\sc \mycoursename} -- \
\thepage}}
}{}
}
\myhead{D} % OR \myhead{F}
Frustration occurred this week as I found myself wanting to maintain two independent screen sessions for different purposes. One to do mutt and irssi, the other for a calendar and todo list. The problem with the standard screen -R is that if more than one of the screen sessions are detatched, it won’t automatically reattach one of them, rather it demands a pid.
This script is intended to function with two screenrc files, which load different programs on start, and then to load one or the other, depending on command line options. If one of the screen sessions is already active, then it will load it with screen -x, allowing multiple instances of the same screen session. Something to note, is that the new shared screen session is called with -A, which resizes all other instances to the new window sizing. Giving preference to the newest screen.
What allows the script to delineate between the two sessions is the -S parameter, which specifies a string that becomes searchable within screen -ls. To make this function with your screenrc files, just make the appropriate changes to the script in the getopts and the if/else structure that follows.
#!/bin/bash
#two calls, cal & chat
function BORKED() {
echo "oops... No screen type specified. Exiting."
exit
}
while getopts ho opt
do
case "$opt" in
o) CAL=1 ## calendar screen
conf="/home/kyle/.screen/screen_cal";;
h) CHAT=1 ## chat screen
conf="/home/kyle/.screen/screen_chat";;
\?) BORKED;;
esac
done
if [[ $CAL == 1 ]]; then
searchFor="cal"
elif [[ $CHAT == 1 ]]; then
searchFor="chat"
else
BORKED
fi
# Do screens of the type exist?
if [[ `screen -ls | grep -c $searchFor` -gt 0 ]]; then
screen=`screen -ls|grep $searchFor`
#what is the pid of the session?
screenID=`echo $screen|sed -e 's/\(.*\)\..*/\1/;s/^[ ]*//'`
#open the session again in a new term
screen -x $screenID
#if the screen session does NOT exist, open a new one
else
screen -A -S $searchFor -c $conf
fi
I know I have had a series of updates on this script, but I keep figuring out ways to make it even better! I have started incorporating a changelog to the file so I can keep track of differences. Anyway, here you are:
#!/bin/bash
# Written by Kyle Christensen 2009
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
### Changelog
#
# 12/02/09 --
# Changed the forced quiet mode to a variable to looks to the definition
# of the compiler for its quiet mode. I only use latex and pdflatex, so
# that is all that is explicitly included. Easy to add more, see function
# QUIET to do so. Or you can modifiy the $quiet variable to add it.
# Ensure that the string value begins with a space though, for safety sake.
#
# Modified COMPILE to check the value of $LATEX to determine the compile
# sequence. If $LATEX==latex then it uses dvips and ps2pdf to convert
# the tex file to pdf.
#
# 11/30/09 --
# Added a TOGGLE function to change the switches in the getopts
# portion so that there need not be any changes made when the default
# values are changed.
#
# Was working from the terminal, so I got frustrated with the error output
# of xpdf when there was no X running. Now does a check with pgrep for X
# to determine if xpdf will run. If X is not running, DISPLAY is never
# executed.
###
# Compile a latex document and cleanup the remainder files
###
if [ -z $1 ]
then
USAGE
exit 1
fi
###
# Default Variables
###
quiet= # needs only to be set if using a latex
# compiler other than latex and pdflatex
Verbose=0 # 0 = off || 1 = on
Display=1 # 0 = off || 1 = on
SpellCheck=1 # 0 = off || 1 = on
CleanUp=1 # 0 = off || 1 = on
RETRY=1 # How many times should the script retry
# the compilation of the tex file? Don't
# really need to make this more than one.
# Will be set to 0 if $Verbose is toggled on.
LATEX="pdflatex" # will handle "latex" or "pdflatex"
#####################################
## Function declarations
####################################
function QUIET { # Pass me $LATEX
comp=$1
if [[ $comp == "pdflatex" ]]; then
quiet=" -interaction nonstopmode"
elif [[ $comp == "latex" ]]; then
quiet=" -interaction=nonstopmode"
elif [[ -z $quiet ]]; then
echo "ERROR: "
echo "Using unknown compiler. Please manually"
echo "set the quiet variable in the source code."
echo "exiting"
exit 1
fi
}
function USAGE {
echo '''
tex2pdf.sh [-S] [-d] [-c] [-v] filename.tex
-S Spellchecking. Default is on, using this
switch will turn it off.
-d Display. Default is to run xpdf on the resulting
pdf file. Toggling this will prevent the display
of the file.
-c Cleanup. Delete extemporaneous files from the
computer when the script is done running. Default
is to have it on. Toggle to turn off.
-v Verbose. Default is to have it quiet. If it fails
on the first build, it will run again in verbose
mode. Turn this on to have it run once with
verbose. Even if it fails, this will only run once.
-h This help documentation.
'''
}
function CHECK_LATEX { ### We don't want latex to process files that are not actually latex files.
### Checking here for the proper extension, case insensitive.
if [[ `echo $ORIGINAL|sed -e 's/.*\(\.tex$\)/\1/'|grep -i -c ".tex"` == 0 ]]; then
echo "This doesn't appear to be a LaTeX file."
echo "The check is for a .tex extension"
echo "Exiting."
exit 1
fi
}
function CLEANUP {
echo "func cleanup"
rm $DVI $PS $LOG $AUX $IDX $ILG $TOC $IND
}
function SPELLCHECK {
echo "func Spell"
aspell -c $ORIGINAL # Spell check
}
function SETVARS {
echo "func SETVARS"
DVI=`echo $ORIGINAL | sed 's/tex$/dvi/'` #V
PS=`echo $ORIGINAL | sed 's/tex$/ps/'` #A
PDF=`echo $ORIGINAL | sed 's/tex$/pdf/'` #R
LOG=`echo $ORIGINAL | sed 's/tex$/log/'` #I
AUX=`echo $ORIGINAL | sed 's/tex$/aux/'` #A
IDX=`echo $ORIGINAL | sed 's/tex$/idx/'` #B
ILG=`echo $ORIGINAL | sed 's/tex$/ilg/'` #L
TOC=`echo $ORIGINAL | sed 's/tex$/toc/'` #E
IND=`echo $ORIGINAL | sed 's/tex$/ind/'` #S
}
function COMPILE {
echo "func COMPILE"
if [[ "$Compiler" == "$LATEX" ]]; then
$Compiler $ORIGINAL ## This will give us output if verbose is toggled.
else $Compiler $ORIGINAL 2&>/dev/null ## Otherwise, we will pipe output to null.
fi
makeindex $IDX 2&>/dev/null ### See the next note. Same reason
bibtex $ORIGINAL 2&>/dev/null ### bibtex will complain every compilation if there is not a bibtex entry
$LATEX $quiet $ORIGINAL 2&>/dev/null ### We don't ever need the output multiple times
$LATEX $quiet $ORIGINAL 2&>/dev/null ### so we can get rid of it on both of these
if [[ $LATEX == "latex" ]]; then
dvips -q -Ppdf -t letter -o $PS $DVI
ps2pdf $PS $PDF
fi
if [ $? != 0 ]; then
if [[ $RETRY -gt 0 ]]; then
Compiler="$LATEX" ## Force no quiet
echo "Failed to make a usable PDF, retrying with verbose
"
echo "press <Enter> to continue..."
rm $PDF
read null
RETRY=$((${RETRY}-1))
COMPILE
else
echo "Could not produce PDF."
exit 1
fi
fi
}
function DISPLAY {
echo "func DISPLAY"
xpdf $PDF
}
function CHECK_X {
if [[ `pgrep X|grep -c .` -gt 0 ]]; then
X=1
else X=0
fi
}
function TOGGLE () {
if [ -z $1 ]; then
echo "Something went very wrong. function TOGGLE"
echo "Press <Enter> to continue."
read null
exit 1
fi
# $1 is the variable that is sent to the function
# which is toggled 0 || 1 and returned as $switch
if [[ $1 == 1 ]]; then
switch=0
else switch=1
fi
return $switch
}
###########
## This is where the program is actually run
############
while getopts hvcdS opt
do
case "$opt" in ## Changed these variable changes to a toggle
## function so that a modification of the default
## value will also be honored when the script is
## executed here. No need to modify this part when
## another change is made earlier.
S) TOGGLE $SpellCheck
SpellCheck=$?;;
d) TOGGLE $Display
Display=$?;;
c) TOGGLE $CleanUp
CleanUp=$?;;
v) TOGGLE $Verbose
Verbose=$?;;
h) USAGE
exit;;
\?)
echo >&2
USAGE
exit 1;;
esac
done
shift `expr $OPTIND - 1`
ORIGINAL=$1 ## Set filename
CHECK_LATEX
SETVARS
QUIET $LATEX
if [[ "$SpellCheck" -eq 1 ]]; then
SPELLCHECK
echo "spellcheck finish"
fi
if [[ "$Verbose" -eq 1 ]]; then
RETRY=0
Compiler="$LATEX "
COMPILE
else
Compiler="$LATEX $quiet"
COMPILE
fi
if [[ "$Display" -eq 1 ]]; then
echo "Display: yes"
CHECK_X
if [[ $X == 1 ]]; then
DISPLAY
else echo "No X"
fi
fi
if [[ "$CleanUp" -eq 1 ]]; then
CLEANUP 2&>/dev/null ## I don't care if files dont exist.
echo ""
fi
I got tired of not having one central script to control all of my media keys, so this is a conglomeration of all my other scripts in one file. Modification is now somewhat easier because they are all in one place. If you are interested in using such a script, use xev to find the keycode of unmapped keys, then use xmodmap to map them. I am currently using fluxbox on this machine so the fluxbox keybinding system is rather simple and easy to use.
#!/bin/bash
# Written by Kyle Christensen 2009
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###
# Control music player mpd as audio levels
# Required programs: mpd, ncmpc, amixer, mpc
# all others should be available by default.
preferredTerm="aterm"
term=`which $preferredTerm`
function MPC {
echo $action
mpc=`which mpc`
case $action in
0) # prev
$mpc prev
;;
1) # next
$mpc next
;;
2) # stop
$mpc stop
;;
3) # toggle
$mpc toggle
;;
\?) echo "Something went very wrong. This option ($action) should
never be passed to this function (MPC). Check the source code." >&2
exit 1
;;
esac
}
function MPD {
mpdRunning=`pgrep mpd|grep -c .`
mpdPath="/etc/init.d/mpd"
if [[ $mpdRunning == 0 ]]; then #mpd off
$term -e sudo $mpdPath start
else
ncmpc=`which ncmpc`
$term -e $ncmpc 2>/dev/null &
fi
}
###
# Manage volume levels for my audio card.
###
audioChannel="PCM Headphone"
function volMute() {
cur=`amixer -c 0 sget "${audioChannel}" | grep % | sed -e 's/.*\[\(.*\)%.*/\1/'`
current=`echo $cur|cut -d\ -f1`
if [[ $current == 0 ]]; then
amixer -c 0 set "${audioChannel}" 70% 1>/dev/null
else {
amixer -c 0 set "${audioChannel}" 0% 1>/dev/null
}
fi
return 0;
}
function USAGE {
echo """$0 [-p][-n][-s][-S][-t][-u][-d][-m]
-p previous
-n next
-s stop
-t toggle (play/pause)
-S start service (must be configured in the source
for reliability. (How you start mpd)
-u volume up
-d volume down
-m volume mute (on unmute, defaults to 70% volume)
--help this text
""" >&2
}
while getopts "udmpnstS" opt; do
case $opt in
p)
#previous MPC
action=0
MPC
;;
n)
#next MPC
action=1
MPC
;;
s)
#stop MPC
action=2
MPC
;;
t)
#toggle (play/pause) MPC
action=3
MPC
;;
S)
#start service MPD
MPD
;;
u)
#turn vol up!
amixer -c 0 set "${audioChannel}" 1%+ 1>/dev/null
;;
d)
#turn vol down!
amixer -c 0 set "${audioChannel}" 1%- 1>/dev/null
;;
m)
volMute
;;
\?)
USAGE
exit 1
;;
esac
done
I found myself getting frustrated with having one conf file for my whole vim usage. So, I discovered recently that you can use different configurations for different filetypes. While this may be common knowledge among some, maybe someone will benefit from my recent knowledge acquisition.
Here is my $HOME/.vimrc file:
autocmd BufRead *.tex :source ~/.vim/tex.vimrc
autocmd BufRead ~/.mutt/temp/mutt* :source ~/.vim/mail.vimrc
autocmd BufRead *.cpp set cin
set tabstop=4
~/.vim/tex.vimrc
set linebreak "If word wrap is toggled, only wrap on whitespace
set textwidth=80 "Carriage return at 80 characters
set spell "Default is to have spellcheck on
"" My mappings
" <F7> toggle spellcheck
" <F11> view pdf of latex file
" <F12> compile latex file
"These are in command mode
nmap <F7> :set spell!<CR>
nmap <F11> :!/bin/tex2pdf.sh %<CR><Esc>
nmap <F12> :!/bin/xpdf_current.sh %&<CR><Esc>
"These are in insert mode
map! <F7> <Esc>:set spell!<CR>i
map! <F11> <Esc>:!/bin/tex2pdf.sh %<CR><Esc>i
map! <F12> <Esc>:!/bin/xpdf_current.sh %&<CR><Esc>i
~/.vim/mail.vim
" To use with Mutt, just put this line your ~/.vimrc :
" autocmd BufRead ~/.mutt/temp/mutt* :source ~/.vim/mail
" * <F1> to re-format the current paragraph correctly
" * <F2> to format a line which is too long, and go to the next line
" * <F3> to merge the previous line with the current one, with a correct
" formatting (sometimes useful associated with <F2>)
" turn on spell checking
set spell
" reformat paragraphs
nmap <F1> gqap
nmap <F2> gqqj
nmap <F3> kgqj
map! <F1> <ESC>gqapi
map! <F2> <ESC>gqqji
map! <F3> <ESC>kgqji
This final source I am borrowing from pbrisbin.com. There is a lot on his page that is worth looking at, if you are interested in a great tiling WM.
Ever want to find music, and not have the issue of downloading illegally from a P2P software? There can be people trying to trap you on those sorts of things. Well, here is a simple bash script that will take all command line arguments and do a search in google for indexed pages hosting music. Feel free to take / modify / whatever you want to.
#!/bin/bash
browser="firefox"
ARG=' intitle:"index.of" "parent directory" "size" "last modified" "description" [snd] (mp4|mp3|avi) -inurl:(jsp|php|html|aspx|htm|cf|shtml|lyrics|mp3s|mp3|index) -gallery -intitle:"last modified" -intitle:(intitle|mp3)'
$browser "http://www.google.com/search?hl=en&q=\"$@\" $ARG"
I have made a few modifications to this source code. Turns out I had a bug that prevented the second pass of the COMPILE function in the event of a failed compilation. Fixed that as well as moved the variable assignment to its own function so it must only be processed once in a given invocation. I have also added a usage function to post a brief help line in the event of improper calls. Finally, because I have this bound to a keymapping in vi, I would accidentally call it on files that were not latex files (oops.) This really screws some files up and makes some garbage files I would rather not have floating around. So the program now will check to ensure that the sourced file is a latex file. Indicated by a case insensitive check of the file extension for “tex” This is on line 49, if anyone has a need to change it.
#!/bin/bash
# Written by Kyle Christensen 2009
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###
# Compile a latex document and cleanup the remainder files
###
if [ -z $1 ]
then
echo "must specify a file"
exit 1
fi
###
# Default Variables
###
Verbose=0
Display=1
SpellCheck=1
CleanUp=1
RETRY=1
LATEX="pdflatex"
#####################################
## Function declarations
####################################
function USAGE {
echo '''
tex2pdf.sh [-S] [-d] [-c] [-v] filename.tex
-S Spellchecking. Default is on, using this
switch will turn it off.
-d Display. Default is to run xpdf on the resulting
pdf file. Toggling this will prevent the display
of the file.
-c Cleanup. Delete extemporaneous files from the
computer when the script is done running. Default
is to have it on. Toggle to turn off.
-v Verbose. Default is to have it quiet. If it fails
on the first build, it will run again in verbose
mode. Turn this on to have it run once with
verbose. Even if it fails, this will only run once.
-h This help documentation.
'''
}
function CHECK_LATEX { ### We don't want latex to process files that are not actually latex files.
### Checking here for the proper extension, case insensitive.
if [[ `echo $ORIGINAL|sed -e 's/.*\(\.tex$\)/\1/'|grep -i -c ".tex"` == 0 ]]; then
echo "This doesn't appear to be a LaTeX file."
echo "The check is for a .tex extension"
echo "Exiting."
exit 1
fi
}
function CLEANUP {
echo "func cleanup"
rm $DVI $PS $LOG $AUX $IDX $ILG $TOC $IND
}
function SPELLCHECK {
echo "func Spell"
aspell -c $ORIGINAL # Spell check
}
function SETVARS {
echo "func SETVARS"
DVI=`echo $ORIGINAL | sed 's/tex$/dvi/'` #V
PS=`echo $ORIGINAL | sed 's/tex$/ps/'` #A
PDF=`echo $ORIGINAL | sed 's/tex$/pdf/'` #R
LOG=`echo $ORIGINAL | sed 's/tex$/log/'` #I
AUX=`echo $ORIGINAL | sed 's/tex$/aux/'` #A
IDX=`echo $ORIGINAL | sed 's/tex$/idx/'` #B
ILG=`echo $ORIGINAL | sed 's/tex$/ilg/'` #L
TOC=`echo $ORIGINAL | sed 's/tex$/toc/'` #E
IND=`echo $ORIGINAL | sed 's/tex$/ind/'` #S
}
function COMPILE {
echo "func COMPILE"
if [[ "$Compiler" == "$LATEX" ]]; then
$Compiler $ORIGINAL ## This will give us output if verbose is toggled.
else $Compiler $ORIGINAL 2&>/dev/null ## Otherwise, we will pipe output to null.
fi
echo "here?"
makeindex $IDX 2&>/dev/null ### See the next note. Same reason
bibtex $ORIGINAL 2&>/dev/null ### bibtex will complain every compilation if there is not a bibtex entry
$LATEX -interaction nonstopmode $ORIGINAL 2&>/dev/null ### We don't ever need the output multiple times
$LATEX -interaction nonstopmode $ORIGINAL 2&>/dev/null ### so we can get rid of it on both of these
# dvips -Ppdf -t letter -o $PS $DVI 2&>/dev/null
# ps2pdf $PS $PDF #2&>/dev/null
if [ $? == 1 ]; then
if [[ $RETRY -gt 0 ]]; then
Compiler="$LATEX" ## Force no quiet
echo "Failed to make a usable PDF, retrying with verbose
"
echo "press <Enter> to continue..."
rm $PDF
read null
RETRY=$((${RETRY}-1))
COMPILE
else
echo "Could not produce PDF."
exit 1
fi
fi
}
function DISPLAY {
echo "func DISPLAY"
xpdf $PDF
}
###########
## This is where the program is actually run
############
while getopts hvcdS opt
do
case "$opt" in
S) SpellCheck=0;; #Perform Spell Check = no
d) Display=0;; # Display? = no
c) CleanUp=0;; # Clean up extras = no
v) Verbose=1;;
h) USAGE
exit;;
\?)
echo >&2
USAGE
exit 1;;
esac
done
shift `expr $OPTIND - 1`
ORIGINAL=$1 ## Set filename
CHECK_LATEX
SETVARS
if [[ "$SpellCheck" -eq 1 ]]; then
SPELLCHECK
echo "spellcheck finish"
fi
if [[ "$Verbose" -eq 1 ]]; then
RETRY=0
Compiler="$LATEX "
COMPILE
else
Compiler="$LATEX -interaction nonstopmode"
COMPILE
fi
if [[ "$Display" -eq 1 ]]; then
echo "Display: yes"
DISPLAY
fi
if [[ "$CleanUp" -eq 1 ]]; then
CLEANUP 2&>/dev/null ## I don't care if files dont exist.
fi
On the fly resizing of mounted partitions! Process is:
#lvmextend -L+<number><size> </path/to/node>
#xfs_grow </path/to/node>
kyle@encrypted [09:01:37] /usr/portage/www-client/mozilla-firefox $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/lvm-root 10G 10G 12K 100% /
udev 10M 152K 9.9M 2% /dev
/dev/mapper/lvm-kyle 20G 19G 1.3G 94% /home/kyle
shm 439M 0 439M 0% /dev/shm
encrypted mozilla-firefox # lvextend -h
File descriptor 3 left open
WARNING: Ignoring duplicate config node: filter (seeking filter)
lvextend: Add space to a logical volume
lvextend
[-A|--autobackup y|n]
[--alloc AllocationPolicy]
[-d|--debug]
[-h|--help]
[-i|--stripes Stripes [-I|--stripesize StripeSize]]
{-l|--extents [+]LogicalExtentsNumber[%{VG|PVS|FREE}] |
-L|--size [+]LogicalVolumeSize[kKmMgGtTpPeE]}
[-m|--mirrors Mirrors]
[-n|--nofsck]
[-r|--resizefs]
[-t|--test]
[--type VolumeType]
[-v|--verbose]
[--version]
LogicalVolume[Path] [ PhysicalVolumePath... ]
encrypted mozilla-firefox # lvextend -L+5G /dev/lvm/
kyle root swap
encrypted mozilla-firefox # lvextend -L+5G /dev/lvm/root
File descriptor 3 left open
WARNING: Ignoring duplicate config node: filter (seeking filter)
Extending logical volume root to 15.00 GB
Logical volume root successfully resized
encrypted mozilla-firefox # xfs_growfs /dev/lvm/root
meta-data=/dev/mapper/lvm-root isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2621440 to 3932160
encrypted mozilla-firefox # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/lvm-root 15G 10G 5.1G 67% /
udev 10M 152K 9.9M 2% /dev
/dev/mapper/lvm-kyle 20G 19G 1.3G 94% /home/kyle
shm 439M 0 439M 0% /dev/shm
For more info, man lvextend && man xfs_grow
Modify the setup of the
document heading by using the package fancyhdr.sty. I tried to create a mockup of this sort of modification to a a
document using the wordpress latex plugin, but it seems to only function with equations.
Here is a pdf of what this would look like.
%your preamble goes here
\usepackage{fancyhdr}
...
\begin{document}
\pagenumbering{roman}\setcounter{page}{1} %print the frontmatter in lower case roman numerals; will change this back to arabic later and start with 1 again.
\fancyhead{} %clear default header
\renewcommand\footrulewidth{0.4pt} %add a line at the foot of your document
\fancyhead[RO,LE]{\slshape Section \leftmark} %Make the header on the Right Odd, Left Even what is normally on the top inside of the header. This is the section marking.
\fancyfoot{} %clear default footer
\fancyfoot[CO,CE]{PHI 591 Midterm -- \thepage} %Center Odd, Center Even print "PHI 591 Midterm -- " and pagenumber
\pagenumbering{arabic} \setcounter{page}{1} % Reset page number to 1 using arabic nuerals.
Because I am trying to make as secure of a laptop as possible, I have written this bash script to provide a secure delete function. There are different invocations that result in different sorts of delete algorithms, some more secure than others, as noted. At this point its still pretty slow because it relies on /dev/random in a few places.
Comments would be welcome.
#!/bin/bash
# secure_delete.sh
#
##
# $name is the file that we want to delete.
# We delete by determining file size:
size() {
size=`stat $name|grep Size|sed -e "s/ Size: \(.*\) .*Blocks.*/\1/"`
echo ""
}
# Then fill the file with zeroes. This is effective as long as
# the disk isn't encrypted, otherwise someone doing a data
# analysis of the disk will know where data exists and does not exist.
zero() {
dd bs=$size count=1 if=/dev/zero of=$name
}
# The most secure way to accomplish a deletion is using /dev/random,
# but this process is very slow and hard on the kernel because of the
# way that /dev/random is produced. However, in the event that you MUST
# remove a file and have no trace of it, use this one:
kernel_random() {
dd bs=1 count=$size if=/dev/random of=$name
delete
}
# A more secure way to do this is passing information through an encryption
# algorithm to simulate a random sequence.
repeated_nonzero() {
# Determine size in Kb. Dump /dev/random as many times as possible
# into the container file at 1024B blocks and one more to cover
# any extra data under 1 KB.
echo "Not working yet."
# counts=$(($size/1024))
# dd bs=1024 count=$counts if=/dev/random of=$name
}
algorithm() {
dd bs=1 count=20 if=/dev/random of=.tmp_junk
dd bs=1 count=$size if=/dev/zero | aespipe -P .tmp_junk | dd of=$name
rm .tmp_junk
delete
}
delete() {
rm $name
}
usage() {
echo "Usage: secure_delete.sh [-z][-k][-r][-a] filename"
echo " -z Uses /dev/zero to fill the file container with"
echo " all zeros."
echo " -k Uses /dev/random to fill the container with"
echo " random numbers generated by the kernel."
echo " WARNING: This method is very slow."
echo " -r Uses some output of the kernel and repeats"
echo " the output until the container is filled."
echo " -a Algorithmic fill using file encryption to pipe"
echo " useless data into the container."
echo " "
echo " A final note: Only use one of these switches at"
echo " a time. If more than one is activated, only the"
echo " first switch will be used. The others will be ignored."
}
while getopts "z:k:r:a:" options; do
case $options in
z ) goZero=1
name=$OPTARG;;
k ) goKernel=1
name=$OPTARG;;
r ) goRepeated=1
name=$OPTARG;;
a ) goAlgorithm=1
name=$OPTARG;;
h ) usage
exit;;
\? ) usage
exit;;
esac
done
if [[ -z $name ]]; then
usage
exit
else size
fi
if [[ $goZero == "1" ]]; then
zero
elif [[ $goKernel == 1 ]]; then
kernel_random
elif [[ $goRepeated == 1 ]]; then
repeated_nonzero
elif [[ $goAlgorithm == "1" ]]; then
algorithm
else exit
fi