User Controls
Shell script thread
-
2015-07-01 at 7:33 AM UTCITT: We post useful shell scripts that we found/wrote, preferably short and simple ones so my dumb brain will know what's going on.
I'll start, here's a 5 min bash script I just made because I got sick of having to fuck with a whole bunch of different settings menus when removing flash cookies.
#!/bin/bash
usage() {
echo "Usage: flash-lso-rm [OPTION]"
echo " -a remove all flash LSOs for current user"
echo " -c remove chromium pepper flash LSOs, excluding settings"
echo " -m remove macromedia flash LSOs, excluding settings"
echo " -p remove pepper flash settings"
echo " -s remove macromedia flash settings"
exit 1
}
if ( ! getopts ":acmps" opt); then
usage
fi
while getopts ":acmps" opt; do
case $opt in
a)
rm -rf ~/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/* > /dev/null 2>&1
rm -rf ~/.macromedia/Flash_Player/#SharedObjects/*/*/ > /dev/null 2>&1
rm -rf ~/.config/chromium/Default/Pepper\ Data/Shockwave\ Flash/WritableRoot/#SharedObjects/*/macromedia.com/support/flashplayer/sys/* > /dev/null 2>&1
;;
c)
rm -rf ~/.config/chromium/Default/Pepper\ Data/Shockwave\ Flash/WritableRoot/#SharedObjects/*/macromedia.com/support/flashplayer/sys/*/ > /dev/null 2>&1
;;
m)
rm -rf ~/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/*/ > /dev/null 2>&1
rm -rf ~/.macromedia/Flash_Player/#SharedObjects/*/*/ > /dev/null 2>&1
;;
p)
rm ~/.config/chromium/Default/Pepper\ Data/Shockwave\ Flash/WritableRoot/#SharedObjects/*/macromedia.com/support/flashplayer/sys/settings.sol > /dev/null 2>&1
;;
s)
rm ~/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol > /dev/null 2>&1
;;
*)
usage
;;
esac
done -
2015-07-02 at 3 AM UTCDon't do a lot of shell scripting, this is the only interesting thing in my .zshrc:
[COLOR=#795DA3]_from_git_root[/COLOR]() {
TOP_LEV=[COLOR=#DF5000]$(git rev-parse --show-toplevel)[/COLOR]
[COLOR=#0086B3] echo[/COLOR] [COLOR=#DF5000]"[COLOR=#333333]$TOP_LEV[/COLOR]/[COLOR=#333333]$1[/COLOR]"[/COLOR]
}
[COLOR=#795DA3]gcd[/COLOR]() {
[COLOR=#969896] #TRGT=$TOP_LEV | tr -d '\r')[/COLOR]
[COLOR=#0086B3] cd[/COLOR] [COLOR=#DF5000]`_from_git_root [COLOR=#333333]$1[/COLOR]`[/COLOR]
}
so you can like `gcd src/foo` and it will traverse up to root of the current git repo and then down into src/foo. -
2015-07-04 at 5:43 PM UTCHere is a shitty script I wrote to help automate my backup process. It's meant to be used in conjunction with rsync. Say you have a folder backup it will make a copy of it called backup_MM_YY for versioning. If it sees that there is no version for the current month one will be created. You specify how many versions and it will trim the old ones.
I did not realize bash functions couldn't handle named parameters and I can't bring myself to care enough to make the pieces more portable.
sortByTimeStampAndPurge () {
dir="/home/macfag/" # dir to work in
folder="gaypr0n" # file / folder base name to work with: baseName_mm_yy
curMonth=$(date +"%m")
curYear=$(date +"%y")
versions=3 # how many revisions to keep
lastMonth=""
lastYear=""
cd $dir
# firsts make array of folder names
i=0
files[0]=""
for f in ${folder}_*
do
files[i]=$f
((i++))
done
# sort them by actual timestamp
for (( i = (${#files[@]}-1); i >= 0; i-- )); do
for (( j = 1; j <= $i; j++ )); do
if [ $(stat -c %Y ${files[$j-1]}) -gt $(stat -c %Y ${files[$j]}) ]
then
tmp=${files[$j-1]}
files[$j-1]=${files[$j]}
files[$j]=$tmp
fi
done
done
# check there is an old copy
if [ ${files[${#files[@]}-1]} != "${folder}_*" ]
then
# if the last copy is labelled more than a month old: copy it
lastMonth=${files[${#files[@]}-1]:${#folder}+1:2}
lastYear=${files[${#files[@]}-1]:${#folder}+4:2}
if [ $curYear -gt $lastYear ]
then
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
elif [ $curMonth -gt $lastMonth ] && [ $curYear -eq $lastYear ]
then
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
fi
else
# there only exists the main backup, no versioning yet, create one
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
fi
# trim extra files that might exist
for (( i = ${#files[@]}-1; i >=0; i--)); do
if [ $versions -le 0 ]
then
rm -r ${files[$i]}
fi
((versions--))
done
}
sortByTimeStampAndPurge
-
2015-07-04 at 9 PM UTC
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript"><!--
function ZOKLock(){var h=new Array(
'<!--*******************************************',
' This page protected by Yomoma ZokLock ',
' Copyright (C) Yomoma Software Co. 2001-2002 ',
' http://www.disney.com/ ',
'********************************************-->',
//Page Begin
'6B',
't!3E 35~U42u"(38$664543GG6533;: :39y,39&.?,3E%65j03+;3813;: :39{~U42uk`tMR4543,3837#,!&$m0A39350D;38"+hq454331@S`x:,3E38+.x3C;?(62MR3544',
'@@S3731&-%:w/36-;38"+`65h1A33 1C32*27;q@SMR3E(38m0A39351A,+!0E)360739/#y}x? $)3637v2739/#62MR4543,3837#,!&$m0A39351F $02)%36`3C38!u`36)$/61',
'y!,3C;#/,343D;`GG"MRhi38(-35*&i62#3C37x07+ (:34p61`q@S3DU4244@:30.3C273E64")%36htj1E -0F!27053D3C.634543GGvou65wGG65o++;#3D-~U4244@q*#',
'*!393Em1501160F1C0B0A1C}z02(3C,0A#*!393Eoy130A0Bth3D+/,66#39og|w;*38$)34664543v39303434-w19"y0D39&30j0F+//;,383Ey1337h05#39-,3Dh1D# 3C|w3C 3E!3C~U42',
'u65%3C!3Cv44@q;/3C31i(,:+?:&?#3D}z.3D:wvo3E3D*!(3Dn3027393E"w/*/66,,32%.!;?3Ew*(/kj/3E#37$&38p{63hxyz}i62U423D/35-}zk0F0C0B1F061Eji&',
'$37+65jjy~ov61qkj;35)36#thnjsn~psoy!34!27!p{63n~7F|{o62664543v+363235h$/3931/3Cuk1A020A14zv44@my`xt39j,35)?&th.3C.,-;hs65)36383C3Em-',
'39(-th0F,34,2727hm*)"-th7Fi62x%(32!3C.?3C!wokunji$,34%65j+3E#18.362730hm/!343D,wo1A,31+"j 3Cnv660Em,31%39,kGGy`xh&$.35);#th,35%*',
'3C61m1A31/+h10%38+`1527$27,66gqs44@;3832x+iwmh{U42?+?y,39un1E%3834+h1E38"3727x0F3C/3E*`19/(##y063727%mvTJ.);j37#:xuim1E-35(!-mvTJ/ ',
'&(qsxn.3Evy#qh323C,+`(htj3D+/35383D62j0E(37h 39m-(3Dh.38(38343D;3Dj193634+-($m3C363D:vj0C-343D%393Emzgs+65jj09323D38(38(y&37:i39 30343Do`q@',
'S)3E`39jp64`"32336336:}kx34j@S%34;,j3630&p38iwp35!q33*w~i3Dx-%39(y#x6362373062)3E`39jp64`"3233633638,3D:3D62j`qiqx{thq7F6134j@S%34;,j3630&',
'p38iwpy,396132+!3C32,`n06181A0B01h0F1F0E12140F011Dm64$`U42,&3E3C`#)%/?-h7F01i-383C33+h30%38y,37;,64m1E/37,+33(y.37?gm6462MR3E(38m3003373D273E(+}hs',
'3E"$35%p3C;?(p3731&-%:w/(-2762j3134,38s6562.37/66/+*3E/,66*% ~i%35rh@S`xhi)?383330!27-or);273C$393C32po3E#)-(65jx66%3C)? 3Dw|u323D; 30',
',;,3Du27%jp{310B&?#-%*63626330$66)3D&3Ev{~64g39t@S|w.&38 gMRt66("3D39664543GG6533;: :39y,39&.?,3E%65j03+;3813;: :39{~U42uk`tMR45433D$37',
'$37?g%3D3C.xui193434123D)%1D$370F(-27q@SMRg66g`gMRt6639.+)(3CwGGTJ64g!3E 35~');
//Page End
var pw='default';
var t='\00\01\02\03\04\05\06\07\010\t\n\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032'+
'\033\034\035\036\037\040!\042#$%&\047()*+,-./0123456789:;\074=\076?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\134]^_`abcdefghijkl'+
'mnopqrstuvwxyz{|}~€Â‚ƒ„…†‡ˆ‰Š‹ŒÂŽÂ‘’“â€â€¢â€“—˜™š›œÂžŸ*¡¢£¤¥¦§¨©ª«¬*®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃ'+
'ÑÒÓÔÕÖ×ØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþÿ';var x='0123456789ABCDEF';var i,j,xs;var c=0;
for(i=0;i<pw.length;i++)c=c^t.indexOf(pw.charAt(i));if(c!=parseInt(h[5].charAt(0)+h[5].charAt(1),16)){
}for(i=0;i<5;i++)document.writeln(h[i]);for(i=0;i<40;i++)document.writeln();
var n=pw.length;var m=0;var s='';for(j=6;j<h.length;j++){for(i=0;i<h[j].length;i++){xs=h[j].charAt(i)
if(x.indexOf(xs)>=0){i++;xs=xs+h[j].charAt(i);c=parseInt(xs,16);}else c=t.indexOf(xs);
c=c^44^t.indexOf(pw.charAt(m));m++;if(m==n)m=0;if(c==13){document.writeln(s);s='';}else if(c==10){;}else s=s+t.charAt(c);}}document.writeln(s);return true;}var ie=0;if(navigator.appName.indexOf('Microsoft')>=0)
{ie=1;ZOKLock();}function ZOKLock2(){if(ie==0)ZOKLock();}
// --></script></head><body onLoad="ZOKLock2();"></body></html> -
2015-07-04 at 9:53 PM UTC
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript"><!--
function ZOKLock(){var h=new Array(
'<!--*******************************************',
' This page protected by Yomoma ZokLock ',
' Copyright (C) Yomoma Software Co. 2001-2002 ',
' http://www.disney.com/ ',
'********************************************-->',
//Page Begin
'6B',
't!3E 35~U42u"(38$664543GG6533;: :39y,39&.?,3E%65j03+;3813;: :39{~U42uk`tMR4543,3837#,!&$m0A39350D;38"+hq454331@S`x:,3E38+.x3C;?(62MR3544',
'@@S3731&-%:w/36-;38"+`65h1A33 1C32*27;q@SMR3E(38m0A39351A,+!0E)360739/#y}x? $)3637v2739/#62MR4543,3837#,!&$m0A39351F $02)%36`3C38!u`36)$/61',
'y!,3C;#/,343D;`GG"MRhi38(-35*&i62#3C37x07+ (:34p61`q@S3DU4244@:30.3C273E64")%36htj1E -0F!27053D3C.634543GGvou65wGG65o++;#3D-~U4244@q*#',
'*!393Em1501160F1C0B0A1C}z02(3C,0A#*!393Eoy130A0Bth3D+/,66#39og|w;*38$)34664543v39303434-w19"y0D39&30j0F+//;,383Ey1337h05#39-,3Dh1D# 3C|w3C 3E!3C~U42',
'u65%3C!3Cv44@q;/3C31i(,:+?:&?#3D}z.3D:wvo3E3D*!(3Dn3027393E"w/*/66,,32%.!;?3Ew*(/kj/3E#37$&38p{63hxyz}i62U423D/35-}zk0F0C0B1F061Eji&',
'$37+65jjy~ov61qkj;35)36#thnjsn~psoy!34!27!p{63n~7F|{o62664543v+363235h$/3931/3Cuk1A020A14zv44@my`xt39j,35)?&th.3C.,-;hs65)36383C3Em-',
'39(-th0F,34,2727hm*)"-th7Fi62x%(32!3C.?3C!wokunji$,34%65j+3E#18.362730hm/!343D,wo1A,31+"j 3Cnv660Em,31%39,kGGy`xh&$.35);#th,35%*',
'3C61m1A31/+h10%38+`1527$27,66gqs44@;3832x+iwmh{U42?+?y,39un1E%3834+h1E38"3727x0F3C/3E*`19/(##y063727%mvTJ.);j37#:xuim1E-35(!-mvTJ/ ',
'&(qsxn.3Evy#qh323C,+`(htj3D+/35383D62j0E(37h 39m-(3Dh.38(38343D;3Dj193634+-($m3C363D:vj0C-343D%393Emzgs+65jj09323D38(38(y&37:i39 30343Do`q@',
'S)3E`39jp64`"32336336:}kx34j@S%34;,j3630&p38iwp35!q33*w~i3Dx-%39(y#x6362373062)3E`39jp64`"3233633638,3D:3D62j`qiqx{thq7F6134j@S%34;,j3630&',
'p38iwpy,396132+!3C32,`n06181A0B01h0F1F0E12140F011Dm64$`U42,&3E3C`#)%/?-h7F01i-383C33+h30%38y,37;,64m1E/37,+33(y.37?gm6462MR3E(38m3003373D273E(+}hs',
'3E"$35%p3C;?(p3731&-%:w/(-2762j3134,38s6562.37/66/+*3E/,66*% ~i%35rh@S`xhi)?383330!27-or);273C$393C32po3E#)-(65jx66%3C)? 3Dw|u323D; 30',
',;,3Du27%jp{310B&?#-%*63626330$66)3D&3Ev{~64g39t@S|w.&38 gMRt66("3D39664543GG6533;: :39y,39&.?,3E%65j03+;3813;: :39{~U42uk`tMR45433D$37',
'$37?g%3D3C.xui193434123D)%1D$370F(-27q@SMRg66g`gMRt6639.+)(3CwGGTJ64g!3E 35~');
//Page End
var pw='default';
var t='\00\01\02\03\04\05\06\07\010\t\n\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032'+
'\033\034\035\036\037\040!\042#$%&\047()*+,-./0123456789:;\074=\076?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\134]^_`abcdefghijkl'+
'mnopqrstuvwxyz{|}~€Â‚ƒ„…†‡ˆ‰Š‹ŒÂŽÂ‘’“â€â€¢â€“—˜™š›œÂžŸ*¡¢£¤¥¦§¨©ª«¬*®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃ'+
'ÑÒÓÔÕÖ×ØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþÿ';var x='0123456789ABCDEF';var i,j,xs;var c=0;
for(i=0;i<pw.length;i++)c=c^t.indexOf(pw.charAt(i));if(c!=parseInt(h[5].charAt(0)+h[5].charAt(1),16)){
}for(i=0;i<5;i++)document.writeln(h[i]);for(i=0;i<40;i++)document.writeln();
var n=pw.length;var m=0;var s='';for(j=6;j<h.length;j++){for(i=0;i<h[j].length;i++){xs=h[j].charAt(i)
if(x.indexOf(xs)>=0){i++;xs=xs+h[j].charAt(i);c=parseInt(xs,16);}else c=t.indexOf(xs);
c=c^44^t.indexOf(pw.charAt(m));m++;if(m==n)m=0;if(c==13){document.writeln(s);s='';}else if(c==10){;}else s=s+t.charAt(c);}}document.writeln(s);return true;}var ie=0;if(navigator.appName.indexOf('Microsoft')>=0)
{ie=1;ZOKLock();}function ZOKLock2(){if(ie==0)ZOKLock();}
// --></script></head><body onLoad="ZOKLock2();"></body></html>
Not a shell script. -
2015-07-04 at 10:35 PM UTC
Not a shell script.
Yes, it is. It's just encrypted. -
2015-07-05 at 4:25 AM UTC
Yes, it is. It's just encrypted.
What kind of shell uses javascript as scripting language? Surely you should be running node.js in that case or something. In general shell scripts are written in bash or csh on Unix at least as far as i know.
#!/bin/bash
directory="./BashScripting"
if [ -d $directory ]; then
echo "Directory not found"
else
echo "Directory found"
fi -
2015-07-05 at 4:44 AM UTC
What kind of shell uses javascript as scripting language? …
The javascript is just an encrypted shell for the shell script.
-
2019-03-04 at 6:37 AM UTC
-
2019-03-04 at 10:38 PM UTCI pretty much exclusively use Python for task automation scripting because it's always more concise (fewer lines of code), and a lot more readable (at least IMO).
For example, converting that backup automation script from Bash to Python:
Originally posted by Merlin
# firsts make array of folder names
i=0
files[0]=""
for f in ${folder}_*
do
files[i]=$f
((i++))
done
# sort them by actual timestamp
for (( i = (${#files[@]}-1); i >= 0; i-- )); do
for (( j = 1; j <= $i; j++ )); do
if [ $(stat -c %Y ${files[$j-1]}) -gt $(stat -c %Y ${files[$j]}) ]
then
tmp=${files[$j-1]}
files[$j-1]=${files[$j]}
files[$j]=$tmp
fi
done
done
The above lines of code can be condensed into the following two lines:
# MAKE ARRAY OF FOLDER NAMES... #
folders = glob.glob(folder+'_*')
# SORT BY TIMESTAMP... #
folders = sorted(folders, key=lambda file: (int(file[-4:]), int(file[-6:-5])))
Originally posted by Merlin
# check there is an old copy
if [ ${files[${#files[@]}-1]} != "${folder}_*" ]
then
# if the last copy is labelled more than a month old: copy it
lastMonth=${files[${#files[@]}-1]:${#folder}+1:2}
lastYear=${files[${#files[@]}-1]:${#folder}+4:2}
if [ $curYear -gt $lastYear ]
then
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
elif [ $curMonth -gt $lastMonth ] && [ $curYear -eq $lastYear ]
then
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
fi
else
# there only exists the main backup, no versioning yet, create one
cp -r $folder ${folder}_${curMonth}_${curYear}
files[${#files}]=${folder}_${curMonth}_${curYear}
fi
This segment of code, well... I'm still trying to fully parse and translate it, because I'm not even totally sure what's different between what's happening in the three different conditions here.
Originally posted by Merlin
# trim extra files that might exist
for (( i = ${#files[@]}-1; i >=0; i--)); do
if [ $versions -le 0 ]
then
rm -r ${files[$i]}
fi
((versions--))
done
This can be reduced to a mere two lines of code:
# TRIM EXTRA FILES THAT MIGHT EXIST... #
for f in folders[:-versions]:
rmtree(f)
I guess it ultimately depends on personal preferences and so on, but I will always prefer Python for shell scripting over Bash. -
2019-03-04 at 11:08 PM UTCPython is very dank to be sure but if you run Linux, specifically debian derived distros on a day to day basis knowing Bash is going to make your life a lot easier. A shell script can be as simple or complex as you desire. Since you can call all the installed system utilities from a shell script you can simply chain the ones together that will do any job you might imagine doing by hand in the shell otherwise. If you know the basic syntax for logic operators and loops in example you can accomplish a lot with Bash with relative ease.
I prefer automating OS tasks with Bash, and when i release an OSS project that has different dependencies i generally tend to use bash as installer scripts too. Also for automating the installation and deployment of tool packages and taking care of all the related dependencies with regards to those of course. -
2019-03-04 at 11:14 PM UTCI am fairly proficient with Bash, but only out of necessity (having to interpret other people's scripts, for example).
But I think one of the biggest reasons I'm so drawn to using Python instead is because I use Windows just as much as I use Linux, and Python scripts will work almost identically on both environments (barring maybe the occasional minor necessary tweak).
And since I have yet to encounter any shell tasks that can't be done with Python, I remain fully sold on Python.
Although one factor I will concede on is that Python is technically an unnecessary dependency (since all Linux kernels incorporate Bash right out of the box). I suppose if I were writing an automation script for a work-related project, I'd probably use Bash. Actually, I pretty much always have to have some kind of init.sh for initializing Docker containers, but they're usually pretty simple scripts for the most part. -
2019-03-04 at 11:26 PM UTC
Originally posted by gadzooks I am fairly proficient with Bash, but only out of necessity (having to interpret other people's scripts, for example).
But I think one of the biggest reasons I'm so drawn to using Python instead is because I use Windows just as much as I use Linux, and Python scripts will work almost identically on both environments (barring maybe the occasional minor necessary tweak).
And since I have yet to encounter any shell tasks that can't be done with Python, I remain fully sold on Python.
Although one factor I will concede on is that Python is technically an unnecessary dependency (since all Linux kernels incorporate Bash right out of the box). I suppose if I were writing an automation script for a work-related project, I'd probably use Bash. Actually, I pretty much always have to have some kind of init.sh for initializing Docker containers, but they're usually pretty simple scripts for the most part.
You're right, python scripts can do pretty much anything shell scripts can too, for Linux or Windows. I generally work with windows in VM, but i always have a Python interpreter installed in those. So i see your point.
Personally, i try to use PowerShell a lot as well, on Windows, it's good for automation and security oriented scripting too.
I do a lot of cross-platform dev stuff as well though, so i got VS Code on my Linux box with PowerShell extensions, so i can test and run PowerShell natively. NSIS, which is a language you can write and compile windows installers with on Linux as well as Windows has a plugin that i use in VS Code too. -
2019-03-04 at 11:40 PM UTC
Originally posted by Sophie Personally, i try to use PowerShell a lot as well, on Windows, it's good for automation and security oriented scripting too.
The funny thing is, as much as I use Windows, I have yet to learn even the basics of PowerShell. It's on my To Do list, but just kinda low priority compared to other things so I haven't made much progress in that regard.
Originally posted by Sophie I do a lot of cross-platform dev stuff as well though
My exact set-up is as follows:
Home computers are all Windows (except for a couple of "headless" Raspberry Pi's that I use for local "web" storage and local git repository storage).
Then, I use a plethora of cloud-based virtual machines (AWS, Digital Ocean, etc) all running Linux.
Then I just use SSH (PuTTY) and SCP (WinSCP), and various python scripts, to interact with the virtual machines (and my local RPi's).
To some it might seem a bit convoluted, but it's what works best for me. -
2019-03-05 at 9:21 AM UTCEvery now and then I think "this would be a good thing to write in bash, I should put in the effort to actually learn how to write a shell script without having to go back to the docs every time". Then I spend 5 times longer writing it than I would have with python, don't touch another bash script for a couple months, forget everything and then some indeterminate amount of time later start the cycle again. I've forgotten more bash than I've ever known at one time.
The last shell script I wrote was a thing for organizing this little git repo I keep with academic papers I read or am planning to read. I pretty regularly have the experience of being like "there was a paper that was relevant to this that I read" but then I can't remember what it was or have to jump through a bazillion faggot hoops to download a copy so I've just started sticking them all in a somewhat organized repo with redundant copies (I can't seem to make a laptop hard drive last more that a few years). Anyway, this is my shitty "look up everything as I write it" bash:
#!/usr/bin/env bash
while getopts 'p:t:y:a:' flag; do
case "${flag}" in
p) ppath="${OPTARG}" ;;
t) title="${OPTARG}" ;;
y) year="${OPTARG}" ;;
a) authorship="${OPTARG}" ;;
*) error "Unexpected option ${flag}" ;;
esac
done
if [ -z "$ppath" ]; then
echo "Enter paper url or path:"; read -e -p ">" ppath;
fi
tmpfile=$(mktemp /tmp/add_paper.XXXXXX)
if [[ $ppath =~ ^http[s]?.*$ ]]; then
curl --silent -o "$tmpfile" "$ppath";
else
cp "$ppath" "$tmpfile";
fi
if [ -z "$title" ]; then
echo "Enter paper title:"; read -e -p ">" title;
fi
if [ -z "$year" ]; then
echo "Enter year of publication:"; read -e -p ">" year;
fi
if [ -z "$authorship" ]; then
echo "Enter author(s), comma deliniated:"; read -e -p ">" authorship;
fi
fname="$title ($year) - $authorship.pdf"
mv "$tmpfile" "resources/$fname"
git add "resources/$fname"
subjects="$(find subjects/* -type d | gawk 'match($0, /subjects\/(.*)/, a) { printf a[1] ":" }')None"
: set -x
echo "Add a subjet?"
export IFS=":"
select subject_name in $subjects;
do
if [[ "$subject_name" == "None" ]]; then
echo "No subject.";
break;
else
relpath=$(echo "$subject_name" | grep -o "/" | awk '/./ { printf "../" }')
ln -s "../../${relpath}resources/$fname" "subjects/$subject_name/$fname";
git add "subjects/$subject_name/$fname"
echo "Added to subject $subject_name";
break;
fi
done
lists="$(find list/* -type d | gawk 'match($0, /list\/(.*)/, a) { printf a[1] ":" }')None"
echo "Add a list?"
export IFS=":"
select list_name in $lists;
do
if [[ "$list_name" == "None" ]]; then
echo "No list.";
break;
else
ln -s "../../resources/$fname" "$(pwd)/list/$list_name/$fname";
git add "list/$list_name/$fname"
echo "Added to list $list_name";
break;
fi
done
git commit -m "Added $authorship, $year" -
2019-03-11 at 3:08 AM UTCThis post has been edited by a bot I made to preserve my privacy.
-
2019-03-11 at 9:42 PM UTC
Originally posted by filtration I have a tendency to format my computer every month, so I created a shell script to get myself back up and running with the shit I use… it's meh, I need to edit and fix some stuff but:
https://github.com/TheDeepNate/deepin-setup
Format your computer? -
2019-03-11 at 10:02 PM UTC
Originally posted by filtration I have a tendency to format my computer every month, so I created a shell script to get myself back up and running with the shit I use… it's meh, I need to edit and fix some stuff but:
https://github.com/TheDeepNate/deepin-setup
How in the fuck have I never thought of writing a full fledged fresh set up script like that...?
I would literally just go through an itemized list of applications and install each one manually, then configure various settings by memory.
Fuck...
Although, I use Windows for my main machine, and I only have experience with command line installation of software on Linux, but I'm sure there's a way to accomplish the same on Windows.
PowerShell might make it feasible.
Worst case scenario, I'll just set up a python script that fetches MSI (Windows install files) from standard URLs and then runs them sequentially.
And modifying Windows OS settings programmatically is definitely feasible via python. -
2019-03-11 at 10:51 PM UTC
-
2019-03-11 at 11:02 PM UTCYeah I understand all of this and more you guys are basically coding babies lol
print("suckmydicklol")