├── code └── shellscript │ ├── other │ ├── clr │ ├── icq │ ├── another │ ├── destroy │ ├── jclp │ ├── mansec │ ├── mklib │ ├── off │ ├── showjpath │ ├── ytalk │ ├── ddr.sh │ ├── fileurl │ ├── qedit │ ├── astep │ ├── awksecond │ ├── browseurl │ ├── ect │ ├── fileman │ ├── filetoline │ ├── findsetuidroot │ ├── pid.sh │ ├── trackinf │ ├── udestobekdm │ ├── editall │ ├── el │ ├── getminute │ ├── pull │ ├── push │ ├── tdf │ ├── uneject │ ├── browseall │ ├── findfiles │ ├── jwhereis.sh │ ├── reboot │ ├── undosreplace │ ├── runjava │ ├── fortest │ ├── peek │ ├── remdoscr.sh │ ├── rnt │ ├── makeps │ ├── v │ ├── bmptogif │ ├── supath │ ├── url2host │ ├── diffrem.sh │ ├── findclassonly │ ├── hwime │ ├── jbatch │ ├── cls │ ├── gv │ ├── linuxdocsearch │ ├── filetolinespace │ ├── findemptymp3s │ ├── fortunefind │ ├── ctwsql │ ├── hw.c │ ├── rpmlistallfiles │ ├── unarchive │ ├── vimswpdiff.sh │ ├── exploredir │ ├── crontab │ ├── noop.sh │ ├── thread │ ├── verifyexists.sh │ ├── waitforkeypress │ ├── watchforimages │ ├── dejasearch │ ├── recurse │ ├── wakeupsoundcard.c │ ├── automount │ ├── javapath │ ├── mytest.sh │ ├── restartnetwork.c │ ├── xshellindir.sh │ ├── forte │ ├── safetar.pclark-maxx-sync │ ├── visibility.sh │ ├── ttysfor │ ├── jfcres │ ├── li.bat │ ├── makebin │ ├── pargunz │ ├── pargz │ ├── brainwaves │ ├── ensurefilename │ ├── ctwport │ ├── makebintools │ ├── newbookmarks │ ├── searchcddb │ ├── showpingtime │ ├── findshellscripts │ ├── jrep │ ├── javadocs │ ├── nicedate.sh │ ├── uniquejfc.sh │ ├── cmptgz │ ├── fortune │ ├── grabmp3s │ ├── li │ ├── news │ ├── allinone │ ├── revisionchanges │ ├── getsync │ ├── doread │ ├── wakeupsoundcard │ ├── arguments │ ├── majidcansee.sh │ ├── cutcols.sh │ ├── securecp.sh │ ├── before │ ├── checkin │ ├── netbeans │ ├── trimempty │ ├── browseimages │ ├── purgecore │ ├── jooify │ ├── portofloppy │ ├── listusers.sh │ ├── between │ ├── newback │ ├── portcollect │ ├── dobak │ ├── mynewer.sh │ ├── showln │ ├── kde.xinit │ ├── portcode │ ├── afterstep.xinit │ ├── setuid │ ├── hugstest │ ├── comparedirs │ ├── monitornet │ ├── jwatchanddo │ ├── countbytes.sh │ ├── dvi2pdf.sh │ ├── mp3towav │ ├── resistancemailstoweb.sh │ ├── alluptodate │ ├── removeduplicates │ ├── makechat.c │ ├── docheck │ ├── listnums.sh │ ├── aft │ ├── monitorcopy │ ├── cksumall.sh │ ├── getcddbfromweb │ ├── myrenice │ ├── comparedirfilesizes.sh │ ├── crossproduct │ ├── jrun.sh │ └── getwinbookmarks.sh │ ├── modem │ ├── ppp-on │ ├── ppp-getipasroot.c │ ├── ppp-updateipasroot.c │ ├── ppp-off │ ├── showmodemtransfer.sh │ ├── ppp-monitor.sh │ ├── ppp-monitor.c │ ├── makeaphonecall.sh │ └── hwippp │ ├── init.d │ └── preemptive_oom_killer.sh │ ├── file │ ├── findlinks │ ├── exists.sh │ ├── isabsolutepath.sh │ ├── sortpathsbyfilename.sh │ ├── there.sh │ ├── pruneemptydirs.sh │ ├── linksinpath.sh │ ├── lx.sh │ ├── issymlink.sh │ ├── filepath.sh │ ├── diffdirs_with_rsync.sh │ ├── purgelinks.sh │ ├── blocksums.sh │ ├── comparedirscksum.sh │ └── absolutepath.sh │ ├── filetools │ └── pushlink.sh │ ├── ls │ ├── dor │ ├── dar │ ├── dsr │ └── ld.sh │ ├── mail │ ├── sendearly.cron.sh │ ├── sendearly.sh │ ├── mailtofile.sh │ ├── decode_base64.sh │ ├── netscapeAddressBook2Mutt.sh │ ├── separatembox.sh │ ├── vCard2abook.sh │ ├── catintofile.sh │ ├── remove_old_mail.sh │ └── netscape2kmail.sh │ ├── stream │ ├── catslowly.sh │ ├── dog.sh │ ├── sortbydirdepth.sh │ ├── getline.sh │ ├── sortpathsbylastdirname.sh │ ├── tolinesh.sh │ ├── grepor.sh │ ├── grepand.sh │ ├── removeduplicatelinesadj.sh │ ├── takeline.sh │ ├── countcharsinline.sh │ └── headbytes.sh │ ├── unixext │ ├── xtermorhere.sh │ ├── dirnames.sh │ ├── nicels.sh │ ├── awkdrop.sh │ ├── mkdirandmv.sh │ └── splicewith.sh │ ├── pkg │ ├── listallpackages.sh │ ├── list_files_in_package.brew.sh │ ├── tarpkg.sh │ ├── list_installed_packages_chronologically.sh │ ├── list_installed_packages_chronologically.pacman.sh │ ├── sendpkgtoneuralyte.sh │ └── checksecuritypkgs-old.sh │ ├── unixwrap │ ├── grepnodir │ ├── dush.sh │ ├── sshz.sh │ ├── jfind.sh │ ├── lsd.sh │ ├── remount.sh │ ├── locatedir.sh │ ├── locateword.sh │ ├── xtermbg.sh │ ├── psbranch.sh │ ├── grepremove │ ├── greplist │ ├── locateend │ ├── nohup.sh │ ├── vio.sh │ ├── xterm_small.sh │ ├── jinfo.sh │ ├── infcat.sh │ ├── grepcount │ ├── grepgetfilename │ ├── ilocate.sh │ ├── jwhere.sh │ ├── startx.sh │ ├── jindent.sh │ └── top.sh │ ├── microsoft │ └── nickwindowsfonts.sh │ ├── txtstream │ ├── indenteachline.sh │ ├── fromcol.sh │ ├── prepend_each_line.sh │ ├── tocol.sh │ └── droplonglines.sh │ ├── versioning │ ├── svnupdate.sh │ ├── cvslistnewfiles.sh │ ├── cvslog.sh │ ├── svncommit.sh │ ├── svnvimdiff.sh │ ├── cvsstatus.sh │ └── svnstatus.sh │ ├── xwin │ ├── wms │ │ ├── sawmill+panel │ │ ├── wmaker+panel │ │ ├── afterstep+panel │ │ └── enlightenment+panel │ ├── ion+panel.sh │ ├── sloppypaste.sh │ ├── get_current_winid.sh │ ├── run-or-raise.sh │ ├── vlox.sh │ ├── hix.sh │ ├── takesomescreenshots.sh │ ├── copy_to_clipboard.sh │ ├── hugewin.sh │ ├── startgnome.sh │ ├── lox.sh │ ├── xtermindir.sh │ ├── swap_caps_ctrl.sh │ ├── clipboard.sh │ ├── getxwindimensions.sh │ ├── make_caps_lock_control_escape.sh │ ├── getcurrentwindowprop.sh │ ├── xtermsh.sh │ ├── runacommand.sh │ └── sloppycopy.sh │ ├── string │ ├── trimstring.sh │ ├── beforeall.sh │ ├── hashstring.sh │ ├── afterlastall.sh │ ├── stringtrim.sh │ ├── beforefirst.sh │ ├── beforeext.sh │ ├── inquotes.sh │ ├── beforelast.sh │ ├── afterfirstall.sh │ ├── toglob.sh │ ├── removetabs.sh │ ├── replace.sh │ ├── betweenthe.sh │ ├── tostring.sh │ ├── chop.sh │ ├── tolowercase.sh │ ├── touppercase.sh │ ├── fromstring.sh │ ├── reverse.sh │ ├── strlen.sh │ ├── longestline.sh │ ├── contains.sh │ ├── startswith.sh │ └── stripbinary.sh │ ├── web │ ├── fromhtml.sh │ ├── fastestftp.sh │ ├── wikipedia.sh │ ├── urltitle.sh │ ├── searches │ │ ├── freshmeatsearch.sh │ │ └── sourceforgesearch.sh │ ├── fastestfilesearch.sh │ ├── mirrorhwi.sh │ ├── ftpsearch │ ├── extracturls.sh │ └── http_get_pure_bash.sh │ ├── compile │ ├── e │ ├── xct │ ├── xgdb.sh │ ├── xt │ ├── xgprof │ ├── xgcov │ └── x │ ├── monitor │ ├── whatsblockingaudio.sh │ ├── logdf.sh │ ├── whatisaccessing.sh │ ├── onchange-simple.sh │ └── listfilesopenby.sh │ ├── shext │ ├── splitat.sh │ ├── jxargs.sh │ ├── runifexists.sh │ ├── breakonctrlc.sh │ ├── reply.sh │ ├── intseq.sh │ ├── echolines.sh │ ├── requirevars.sh │ └── require_exes.sh │ ├── svn │ └── svndiff.sh │ ├── curses │ ├── curseblack.sh │ ├── curseblue.sh │ ├── cursecyan.sh │ ├── cursegreen.sh │ ├── curseyellow.sh │ ├── cursebold.sh │ ├── cursenorm.sh │ ├── cursemagenta.sh │ ├── cursegrey.sh │ ├── cursewhite.sh │ ├── cursereverse.sh │ └── notes.txt │ ├── cvswrap │ ├── cvsupdateall.sh │ ├── savelinks.sh │ ├── viewcvs.sh │ └── cvsreplaceserver.sh │ ├── math │ ├── chooserandom.sh │ ├── calc.sh │ └── randomnumber.sh │ ├── maths │ ├── getint.sh │ └── getnumber.sh │ ├── proc │ ├── whatsionthistty.sh │ ├── findjob.1 │ ├── wotgobblecpu.sh │ ├── wotgobbleopenfiles.sh │ ├── findjob.2 │ ├── psforkillchild.sh │ ├── benicetome.sh │ ├── getppid.sh │ ├── whenprocesscompletes.sh │ ├── withfewerprocessors.sh │ ├── wotgobblemem.sh │ └── myps.sh │ ├── tex │ ├── watchtex.sh │ ├── texfindimgs.sh │ ├── jdistill.sh │ ├── deltexoutput.sh │ └── dotexfindimgs.sh │ ├── wget │ ├── wget_archive_page.sh │ ├── wget_all_links_with_extension.sh │ └── wget_get_everything_below.sh │ ├── pkg_portage │ ├── list_files_in_package.portage.sh │ ├── emerge_masked_package.sh │ ├── list_installed_packages.portage.sh │ ├── show_versions_for_package.portage.sh │ ├── list_installed_packages_by_size.portage.sh │ ├── list_duplicate_installed_versions-dodgy.portage.sh │ ├── find_package_with_file.portage.sh │ ├── list_available_packages.portage.sh │ ├── list_dependencies.portage.sh │ ├── list_orphaned_packages.portage.sh │ └── get_package_size.portage.sh │ ├── pkg_rpm │ ├── list_installed_packages.rpm.sh │ ├── list_files_in_package.rpm.sh │ └── find_package_with_file.rpm.sh │ ├── streamtools │ ├── escapeslash.sh │ ├── unescapeslash.sh │ ├── takerandom.sh │ └── indent_on_regexp.sh │ ├── audio │ ├── downsamplewav.sh │ ├── volumeup.sh │ ├── resample_wav.sh │ ├── volumedown.sh │ ├── unfadevolume.sh │ ├── agsatellite.sh │ ├── boost_volume.sh │ ├── slow_down_audio.sh │ ├── set_volume.sh │ └── playmp3s.sh │ ├── c │ └── finddeps.sh │ ├── rpm │ ├── findrpm.sh │ ├── pkgusage.sh │ ├── findpkgsunused.sh │ ├── TODO.txt │ ├── whatdepends.sh │ └── dpkgusage.sh │ ├── vnc │ └── myvnc.sh │ ├── apt │ ├── apt-list-residual-config.sh │ ├── apt-get-autoremove-purge.sh │ ├── apt-security-updates.sh │ └── apt-get-security.sh │ ├── emails │ ├── emailfrom │ ├── emailsubject │ ├── emaildate │ └── emailsortall │ ├── music │ ├── candy.sh │ └── soundshorrid.sh │ ├── otherwrap │ └── consolemixer.sh │ ├── pkg_apk │ ├── list_files_in_package.apk.sh │ ├── list_installed_packages.apk.sh │ └── list_available_packages.apk.sh │ ├── posessive │ ├── opentomajid.sh │ ├── joeyowns │ ├── overpossesive │ │ └── ownboxwithip │ ├── shield.sh │ └── spyon.sh │ ├── diffing │ ├── difftwotarballs.sh │ └── prettydiff.sh │ ├── fs │ ├── sortfilesbysize.sh │ ├── nodecount.sh │ ├── truncate_file_at.sh │ ├── makebigemptyfile.sh │ ├── mvpreserve.sh │ ├── nicedf.sh │ └── wheremounted.sh │ ├── image │ ├── imageinfo.sh.save │ ├── imageinfo.sh │ ├── generate_favicon.sh │ └── normalize_image.sh │ ├── init │ ├── ibmjava.sh │ ├── sunjava.sh │ ├── cvsinit.sh │ ├── preventgreperrs.sh │ └── refreshbintoollinks │ ├── pkg_pacman │ ├── find_package_with_file.pacman.sh │ ├── list_installed_packages.pacman.sh │ └── list_files_in_package.pacman.sh │ ├── sys │ └── getsysteminfo.sh │ ├── filestream │ └── dirsonly.sh │ ├── fun │ └── weather.sh │ ├── monitors │ ├── monitorwho.sh │ ├── get_gpu_temperature.sh │ ├── get_cpu_temperature.sh │ ├── monitor_disk_usage.sh │ ├── watchfolderforchanges.sh │ ├── monitorcomusage.sh │ ├── monitorfileaccess.sh │ └── watchforfileaccess.sh │ ├── sh │ ├── countargs.sh │ ├── shtrace.sh │ ├── forx.sh │ ├── findjshrevdeps.sh │ ├── echoargs.sh │ ├── shredirect.sh │ ├── shexamples.sh │ └── addtopaths.sh │ ├── shlib │ ├── filter_list_with.sh │ ├── bounce.sh │ ├── assert.sh │ └── escapeargs.sh │ ├── wrap │ ├── viinxterm.sh │ ├── noescape.sh │ ├── findqt.sh │ ├── links.sh │ ├── lynx.sh │ ├── soffice51 │ ├── jmake.sh │ ├── netscape │ └── japropos.sh │ ├── fsutils │ └── findoldfiles.sh │ ├── mongo │ ├── mongo_show_dbs.sh │ ├── mongo_show_collection_counts.sh │ └── monitor_mongo_collection.sh │ ├── net │ ├── webmintobuggy.sh │ ├── pingtime.sh │ ├── whatismyip.sh │ ├── geturl.sh │ ├── show_dns_records.sh │ ├── pingallips.sh │ ├── ip2country.sh │ ├── downloadurl.sh │ └── pingtest.sh │ ├── quines │ ├── quine4.sh │ ├── quine7.sh │ ├── quine5.sh │ ├── quine2.sh │ ├── quine6.sh │ ├── quine3.sh │ └── quine.sh │ ├── xwinwrap │ └── xpdf.sh │ ├── video │ ├── getvideoresolution.sh │ └── getvideoduration.sh │ ├── hugswrap │ ├── baseconv.sh │ ├── hugswrap.sh │ └── ascii.sh │ ├── jgrm │ ├── editjgrm │ └── jparse │ ├── strings │ └── strrep.sh │ ├── pydev │ └── python_install_dependencies.sh │ ├── wmctrl │ ├── wmctrl_restore_positions.sh │ ├── getcurrentwindowtitle.sh │ └── wmctrl_restore_all.sh │ ├── html │ ├── htmlall │ └── htmlpagewrap.sh │ ├── intl │ ├── cedictbatchlookup.sh │ └── jcedict.sh │ ├── spawn │ ├── browsedir │ └── vncpanic │ ├── java │ ├── quickjavadoc.sh │ └── gcj.sh │ ├── lxde │ └── slaylx.sh │ ├── zip │ ├── tarxfzwithprogress.sh │ ├── tarcfz.sh │ ├── tarxfz.sh │ ├── is_archive.sh │ └── openzipwith.sh │ ├── shutil │ ├── lastarg.sh │ └── list_commands_on_path.sh │ ├── git │ ├── gitinit.sh │ ├── git-ignore.sh │ ├── git-list-untracked.sh │ ├── git-undo-last-commit.sh │ ├── git-remove-merged-branches.sh │ ├── git-init.sh │ ├── git-ignore-local.sh │ ├── git-merge-clean.sh │ └── git-restore-file-dates-from-history.sh │ ├── diff │ ├── jfcdiff.sh │ ├── sortinplace.sh │ ├── sortedvimdiff.sh │ └── sorteddiff.sh │ ├── jsh │ ├── makedebugtooldir.sh │ └── jshupdateallcvs.sh │ ├── wine │ └── slaywine.sh │ ├── nicels │ ├── listfilesbydate.sh │ └── listfilesbyaccessdate.sh │ ├── jshlogging │ ├── jshquestion.sh │ └── jshinfo.sh │ ├── tmpsys │ └── getuniquefile.sh │ ├── duplicates.txt │ ├── edit │ ├── vimkeepdate.sh │ └── vanillavim.sh │ ├── mp3 │ ├── whichmp3 │ ├── downsamplemp3.sh │ ├── wav2mp3 │ └── keepstreamedmp3 │ ├── SCRIPTING_TIPS.txt │ ├── node │ └── npmlist.sh │ ├── scripts_which_override_existing.sh │ ├── oscompat │ ├── unix2dos.sh │ ├── mac2unix.sh │ └── dos2unix.sh │ ├── standin │ └── realpath.sh │ ├── fonts │ └── generate_fontlist_html.sh │ ├── jshlib │ └── jshsuggest.sh │ ├── unix │ └── whichall.sh │ ├── logging │ └── showerrlogall.sh │ ├── find │ ├── findaged.sh │ └── find-typef_avoiding_stale_handle_error.sh │ ├── stub │ └── md5sum.sh │ ├── systemd │ ├── systemd_show_journal_since_boot.sh │ └── systemd_watch_journal.sh │ ├── term │ ├── truncate_columns.sh │ └── striptermchars.sh │ ├── perl │ └── perltrace.sh │ ├── shortcut │ └── indirdo.sh │ ├── fileutil │ └── copyusingtar.sh │ ├── pattern │ └── globtoregexp.sh │ ├── dir │ └── expandthreedots.sh │ ├── cdrw │ └── cdcksum.sh │ ├── lint │ └── add_shebang_to_scripts.sh │ ├── GUI_APP_KEYBOARD_SHORTCUTS.txt │ ├── arch │ └── diffzips.sh │ ├── evolution │ └── oaf-slay.sh │ ├── javadev │ └── tar_java_project.sh │ ├── ui │ └── error.sh │ ├── shtxt │ └── stripcomments.sh │ ├── webdev │ └── beautify_json.sh │ ├── security │ ├── nmap_scan_network.sh │ └── nmap_detailed_scan.sh │ ├── ooo │ ├── openofficeunzip.sh │ └── openofficezip.sh │ ├── text │ └── html2txt.sh │ ├── memo │ └── prepare_for_fast_memoing.sh │ ├── undelext2 │ └── undelext2.sh │ ├── portals │ └── hwiisat.sh │ ├── load_script_config │ ├── progress │ └── watch_progress.sh │ ├── indevelopment │ ├── splitintothreecolumns.sh │ └── splitatendofregexp.sh │ ├── installwrapper │ └── get_imwheel_softmouse.sh │ ├── datetime │ └── geekdate.sh │ ├── ripaudio │ └── ripaudio.sh │ ├── ascii │ └── figletall.sh │ ├── regexp │ └── list2regexp.sh │ ├── REFACTORS_TODO.txt │ ├── j │ └── exportbin.sh │ ├── sync │ └── cksumfindupl.sh │ ├── vscode │ └── vscode-do-not-truncate-types.sh │ ├── HOWTO_USE_bashrc_bash_profile_and_profile.md │ ├── cygwin │ └── cygpkgsizes.sh │ ├── fstools │ └── fasttreeprofile.sh │ └── dirhistory │ └── dirhistorysetup.bash ├── jsh ├── startj ├── startj-simple └── .gitignore /code/shellscript/other/clr: -------------------------------------------------------------------------------- 1 | clear -------------------------------------------------------------------------------- /jsh: -------------------------------------------------------------------------------- 1 | code/shellscript/init/jsh.sh -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-on: -------------------------------------------------------------------------------- 1 | hwippp up -------------------------------------------------------------------------------- /code/shellscript/other/icq: -------------------------------------------------------------------------------- 1 | gtkicq $@ & -------------------------------------------------------------------------------- /startj: -------------------------------------------------------------------------------- 1 | code/shellscript/init/startj-hwi.sh -------------------------------------------------------------------------------- /code/shellscript/init.d/preemptive_oom_killer.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/shellscript/other/another: -------------------------------------------------------------------------------- 1 | konsole & 2 | -------------------------------------------------------------------------------- /code/shellscript/other/destroy: -------------------------------------------------------------------------------- 1 | kill -s 9 $1 2 | -------------------------------------------------------------------------------- /code/shellscript/other/jclp: -------------------------------------------------------------------------------- 1 | java ComLineProg $@ -------------------------------------------------------------------------------- /code/shellscript/other/mansec: -------------------------------------------------------------------------------- 1 | man -S $1 $2 2 | -------------------------------------------------------------------------------- /code/shellscript/other/mklib: -------------------------------------------------------------------------------- 1 | ar rc lib$1.a *.o -------------------------------------------------------------------------------- /code/shellscript/other/off: -------------------------------------------------------------------------------- 1 | shutdown -h now 2 | -------------------------------------------------------------------------------- /code/shellscript/other/showjpath: -------------------------------------------------------------------------------- 1 | echo "$JPATH" -------------------------------------------------------------------------------- /code/shellscript/other/ytalk: -------------------------------------------------------------------------------- 1 | /usr/bin/ytalk -x $@ -------------------------------------------------------------------------------- /code/shellscript/file/findlinks: -------------------------------------------------------------------------------- 1 | find . -type l 2 | -------------------------------------------------------------------------------- /code/shellscript/filetools/pushlink.sh: -------------------------------------------------------------------------------- 1 | mvln "$@" 2 | -------------------------------------------------------------------------------- /code/shellscript/ls/dor: -------------------------------------------------------------------------------- 1 | ls $JM_LS_OPTS -alrth $@ 2 | -------------------------------------------------------------------------------- /code/shellscript/mail/sendearly.cron.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | -------------------------------------------------------------------------------- /code/shellscript/other/ddr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -ld */ -------------------------------------------------------------------------------- /code/shellscript/other/fileurl: -------------------------------------------------------------------------------- 1 | echo "file://$PWD/$@" -------------------------------------------------------------------------------- /code/shellscript/other/qedit: -------------------------------------------------------------------------------- 1 | TERM=linux 2 | edit $@ -------------------------------------------------------------------------------- /code/shellscript/stream/catslowly.sh: -------------------------------------------------------------------------------- 1 | trickle "$@" 2 | -------------------------------------------------------------------------------- /code/shellscript/unixext/xtermorhere.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | -------------------------------------------------------------------------------- /startj-simple: -------------------------------------------------------------------------------- 1 | code/shellscript/init/startj-simple.sh -------------------------------------------------------------------------------- /code/shellscript/other/astep: -------------------------------------------------------------------------------- 1 | astepafter & 2 | xinit 3 | -------------------------------------------------------------------------------- /code/shellscript/other/awksecond: -------------------------------------------------------------------------------- 1 | awk '{printf($2"\n")}' -------------------------------------------------------------------------------- /code/shellscript/other/browseurl: -------------------------------------------------------------------------------- 1 | /usr/bin/netscape "$@" & -------------------------------------------------------------------------------- /code/shellscript/other/ect: -------------------------------------------------------------------------------- 1 | edit $JPATH/code/c/tools/$1/$1.c -------------------------------------------------------------------------------- /code/shellscript/other/fileman: -------------------------------------------------------------------------------- 1 | kfmclient openURL '/' 2 | -------------------------------------------------------------------------------- /code/shellscript/other/filetoline: -------------------------------------------------------------------------------- 1 | filetolinespace $@ " " -------------------------------------------------------------------------------- /code/shellscript/other/findsetuidroot: -------------------------------------------------------------------------------- 1 | find / -perm +a+s -------------------------------------------------------------------------------- /code/shellscript/other/pid.sh: -------------------------------------------------------------------------------- 1 | # noshebang 2 | echo $$ 3 | -------------------------------------------------------------------------------- /code/shellscript/other/trackinf: -------------------------------------------------------------------------------- 1 | cd-discid /dev/cdrom 2 | -------------------------------------------------------------------------------- /code/shellscript/other/udestobekdm: -------------------------------------------------------------------------------- 1 | kfmclient openURL 2 | -------------------------------------------------------------------------------- /code/shellscript/pkg/listallpackages.sh: -------------------------------------------------------------------------------- 1 | pkgman pkglist 2 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/grepnodir: -------------------------------------------------------------------------------- 1 | /bin/grep -d skip $@ -------------------------------------------------------------------------------- /code/shellscript/microsoft/nickwindowsfonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | -------------------------------------------------------------------------------- /code/shellscript/other/editall: -------------------------------------------------------------------------------- 1 | for x in $@; do edit "$x"; done -------------------------------------------------------------------------------- /code/shellscript/other/el: -------------------------------------------------------------------------------- 1 | edit $JPATH/code/c/joeylib/$1.c 2 | -------------------------------------------------------------------------------- /code/shellscript/other/getminute: -------------------------------------------------------------------------------- 1 | echo -n `date | between ":"` -------------------------------------------------------------------------------- /code/shellscript/other/pull: -------------------------------------------------------------------------------- 1 | cd < $JPATH/data/pushdir.txt 2 | -------------------------------------------------------------------------------- /code/shellscript/other/push: -------------------------------------------------------------------------------- 1 | pwd > $JPATH/data/pushdir.txt 2 | -------------------------------------------------------------------------------- /code/shellscript/other/tdf: -------------------------------------------------------------------------------- 1 | /bin/df --block-size=1048576 2 | -------------------------------------------------------------------------------- /code/shellscript/other/uneject: -------------------------------------------------------------------------------- 1 | eject -t $1 2 | # mount $1 3 | -------------------------------------------------------------------------------- /code/shellscript/txtstream/indenteachline.sh: -------------------------------------------------------------------------------- 1 | sed "s+^+$*+" 2 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/dush.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | du -sh "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/sshz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ssh -C "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/versioning/svnupdate.sh: -------------------------------------------------------------------------------- 1 | svn update "$@" 2 | -------------------------------------------------------------------------------- /code/shellscript/xwin/wms/sawmill+panel: -------------------------------------------------------------------------------- 1 | sawmill & 2 | panel 3 | -------------------------------------------------------------------------------- /code/shellscript/xwin/wms/wmaker+panel: -------------------------------------------------------------------------------- 1 | wmaker & 2 | panel 3 | -------------------------------------------------------------------------------- /code/shellscript/other/browseall: -------------------------------------------------------------------------------- 1 | forall $@ do explore "\"%w\"" 2 | -------------------------------------------------------------------------------- /code/shellscript/other/findfiles: -------------------------------------------------------------------------------- 1 | grep $1 * -r -c | grep :0 -v 2 | -------------------------------------------------------------------------------- /code/shellscript/other/jwhereis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jwhere $@ # dufus! -------------------------------------------------------------------------------- /code/shellscript/other/reboot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec shutdown -r now 3 | -------------------------------------------------------------------------------- /code/shellscript/other/undosreplace: -------------------------------------------------------------------------------- 1 | forall -shell *.b4sr do mv %f %s -------------------------------------------------------------------------------- /code/shellscript/string/trimstring.sh: -------------------------------------------------------------------------------- 1 | sed 's+^\s*++ ; s+\s*$++' 2 | -------------------------------------------------------------------------------- /code/shellscript/web/fromhtml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | striphtml "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/xwin/ion+panel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | xterm & 3 | ion 4 | -------------------------------------------------------------------------------- /code/shellscript/xwin/wms/afterstep+panel: -------------------------------------------------------------------------------- 1 | afterstep & 2 | panel 3 | -------------------------------------------------------------------------------- /code/shellscript/compile/e: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | "$JPATH"/tools/edit "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/ls/dar: -------------------------------------------------------------------------------- 1 | # access time 2 | ls -aultr $JM_LS_OPTS "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/monitor/whatsblockingaudio.sh: -------------------------------------------------------------------------------- 1 | fuser -v /dev/snd*/* 2 | -------------------------------------------------------------------------------- /code/shellscript/other/runjava: -------------------------------------------------------------------------------- 1 | echo "java -classpath $CLASSPATH:$2 $1" -------------------------------------------------------------------------------- /code/shellscript/shext/splitat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sed "s+$1+\\ 3 | +g" 4 | -------------------------------------------------------------------------------- /code/shellscript/string/beforeall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sed "s/$@.*//" 3 | -------------------------------------------------------------------------------- /code/shellscript/string/hashstring.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "$@" | cksum 3 | -------------------------------------------------------------------------------- /code/shellscript/svn/svndiff.sh: -------------------------------------------------------------------------------- 1 | svn diff "$@" | diffhighlight | more 2 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/jfind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -name "*$@*" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/curseblack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[00;30m" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/curseblue.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[00;34m" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursecyan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[00;36m" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursegreen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[00;32m" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/curseyellow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[00;33m" 3 | -------------------------------------------------------------------------------- /code/shellscript/cvswrap/cvsupdateall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cvsupdate -d -A 3 | -------------------------------------------------------------------------------- /code/shellscript/file/exists.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | test -f "$1" || test -d "$1" 3 | -------------------------------------------------------------------------------- /code/shellscript/mail/sendearly.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sendat sched early "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/math/chooserandom.sh: -------------------------------------------------------------------------------- 1 | echolines "$@" | chooserandomline 2 | -------------------------------------------------------------------------------- /code/shellscript/maths/getint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | getnumber | sed "s/\..*//" 3 | -------------------------------------------------------------------------------- /code/shellscript/other/fortest: -------------------------------------------------------------------------------- 1 | for x in "$@" ; do 2 | echo $x 3 | done 4 | -------------------------------------------------------------------------------- /code/shellscript/other/peek: -------------------------------------------------------------------------------- 1 | ps -o "(%x %C) %u : %a" -u $USER -U $USER -N 2 | -------------------------------------------------------------------------------- /code/shellscript/other/remdoscr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat "$@" | tr -d "\015" 3 | -------------------------------------------------------------------------------- /code/shellscript/other/rnt: -------------------------------------------------------------------------------- 1 | mv $JPATH/tools/$1 $JPATH/tools/$2 2 | whereis $2 & -------------------------------------------------------------------------------- /code/shellscript/proc/whatsionthistty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ps fl -t "$(tty)" 3 | -------------------------------------------------------------------------------- /code/shellscript/string/afterlastall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sed "s+.*$1++" 4 | -------------------------------------------------------------------------------- /code/shellscript/tex/watchtex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | onchange "*.tex" do dotex 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/lsd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -d -art $JM_LS_OPTS "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/remount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mount -o remount "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/wget/wget_archive_page.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -kpx "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/xwin/wms/enlightenment+panel: -------------------------------------------------------------------------------- 1 | enlightenment & 2 | panel 3 | -------------------------------------------------------------------------------- /code/shellscript/compile/xct: -------------------------------------------------------------------------------- 1 | cd $JPATH/code/c/tools/$1 2 | $JPATH/tools/xt $1 3 | -------------------------------------------------------------------------------- /code/shellscript/other/makeps: -------------------------------------------------------------------------------- 1 | anytopnm $1 > tmp.pnm 2 | pnmtops tmp.pnm $1.eps 3 | -------------------------------------------------------------------------------- /code/shellscript/other/v: -------------------------------------------------------------------------------- 1 | #xv -perfect -8 *.bmp *.jp*g *.gif & 2 | geeqie "$@" & 3 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_files_in_package.portage.sh: -------------------------------------------------------------------------------- 1 | equery files "$1" 2 | -------------------------------------------------------------------------------- /code/shellscript/pkg_rpm/list_installed_packages.rpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rpm -qa 3 | -------------------------------------------------------------------------------- /code/shellscript/stream/dog.sh: -------------------------------------------------------------------------------- 1 | # jsh-depends: pipebackto 2 | pipebackto "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/streamtools/escapeslash.sh: -------------------------------------------------------------------------------- 1 | cat "$@" | sed -u 's+\\+\\\\+g' 2 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/locatedir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | locateleaf "$@" | dirsonly 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/locateword.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | unj locate -r "\<$1\>" 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/xtermbg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | "$JPATH"/tools/xterm "$@" & 3 | -------------------------------------------------------------------------------- /code/shellscript/audio/downsamplewav.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sox "$1" -r 22050 "$2" resample -------------------------------------------------------------------------------- /code/shellscript/c/finddeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | g++ -E -M "$@" -I $JPATH/joeylib/.comp/ 3 | -------------------------------------------------------------------------------- /code/shellscript/other/bmptogif: -------------------------------------------------------------------------------- 1 | bmptoppm $1 > tmp.ppm 2 | ppmtogif tmp.ppm > $1.gif 3 | -------------------------------------------------------------------------------- /code/shellscript/other/supath: -------------------------------------------------------------------------------- 1 | env PATH="${PATH}:/usr/sbin:/sbin" 2 | # export PATH 3 | -------------------------------------------------------------------------------- /code/shellscript/other/url2host: -------------------------------------------------------------------------------- 1 | echo "$@" | awk ' BEGIN { FS="/" } { printf($3"\n") } ' -------------------------------------------------------------------------------- /code/shellscript/pkg_rpm/list_files_in_package.rpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rpm -ql "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/proc/findjob.1: -------------------------------------------------------------------------------- 1 | myps --columns 65535 -A | grep -v $$ | grep "$@" 2 | -------------------------------------------------------------------------------- /code/shellscript/proc/wotgobblecpu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | myps -A | sort -n -k 5 | tail -8 3 | -------------------------------------------------------------------------------- /code/shellscript/rpm/findrpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memo -t "1 hour" rpm -qa | grep "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/rpm/pkgusage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dar -d `dpkg-L "$1"` | grep -v '/$' 3 | -------------------------------------------------------------------------------- /code/shellscript/streamtools/unescapeslash.sh: -------------------------------------------------------------------------------- 1 | cat "$@" | sed -u 's+\\\(.\)+\1+g' 2 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/psbranch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pstree -ap | grep -B 100000 "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/vnc/myvnc.sh: -------------------------------------------------------------------------------- 1 | ps a -U `whoami` | awk '$5 ~ /Xrealvnc/ {print $6}' 2 | -------------------------------------------------------------------------------- /code/shellscript/apt/apt-list-residual-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dpkg --list | grep ^rc 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursebold.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033[01m" 3 | # Or: tput bold 4 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursenorm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: 3 | printf "\033[00m" 4 | -------------------------------------------------------------------------------- /code/shellscript/emails/emailfrom: -------------------------------------------------------------------------------- 1 | grep "^From: " "$1" | head -n 1 | after "From:" | tr -d "\r" -------------------------------------------------------------------------------- /code/shellscript/music/candy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mpg123 -s "$@" | synaesthesia pipe 44100 3 | -------------------------------------------------------------------------------- /code/shellscript/other/diffrem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if diff $1 $2; then 3 | echo "del $1" 4 | fi -------------------------------------------------------------------------------- /code/shellscript/other/findclassonly: -------------------------------------------------------------------------------- 1 | # begins directory, ends .class 2 | findclass "/$@\." -------------------------------------------------------------------------------- /code/shellscript/other/hwime: -------------------------------------------------------------------------------- 1 | cp /home/joey/.bash_profile ~ 2 | cp /home/joey/.bashrc ~ 3 | -------------------------------------------------------------------------------- /code/shellscript/other/jbatch: -------------------------------------------------------------------------------- 1 | editandwait $JPATH/tmp/batch.txt 2 | . $JPATH/tmp/batch.txt 3 | -------------------------------------------------------------------------------- /code/shellscript/otherwrap/consolemixer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | xterm -geometry 76x17 -e rexima 3 | -------------------------------------------------------------------------------- /code/shellscript/pkg_apk/list_files_in_package.apk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apk info -L "$1" 4 | -------------------------------------------------------------------------------- /code/shellscript/pkg_apk/list_installed_packages.apk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apk list -I 4 | -------------------------------------------------------------------------------- /code/shellscript/posessive/opentomajid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | setfacl -f $HOME/wantedfacl "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/streamtools/takerandom.sh: -------------------------------------------------------------------------------- 1 | N="$1" 2 | randomorder | head -n "$N" # | sort 3 | -------------------------------------------------------------------------------- /code/shellscript/string/stringtrim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | tr -d "\r" | tr -d "\n" | tr -d "\015" -------------------------------------------------------------------------------- /code/shellscript/unixext/dirnames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X; do 3 | dirname "$X" 4 | done 5 | -------------------------------------------------------------------------------- /code/shellscript/unixext/nicels.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -artFh --color --block-size="'1" "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursemagenta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: 3 | printf "\033[00;35m" 4 | -------------------------------------------------------------------------------- /code/shellscript/diffing/difftwotarballs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Not written yet." 3 | exit 2 4 | -------------------------------------------------------------------------------- /code/shellscript/fs/sortfilesbysize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SORTBY=size SORTFORM=%s sortfilesbydate 3 | -------------------------------------------------------------------------------- /code/shellscript/image/imageinfo.sh.save: -------------------------------------------------------------------------------- 1 | convert -verbose "$@" $JPATH/tmp/tmp.jpg 2>/dev/null 2 | -------------------------------------------------------------------------------- /code/shellscript/other/cls: -------------------------------------------------------------------------------- 1 | # Does code need to have a logical purpose? 2 | clear || printf " " 3 | -------------------------------------------------------------------------------- /code/shellscript/other/gv: -------------------------------------------------------------------------------- 1 | for X 2 | do 3 | runoneof -notinj "gv ghostview" "$X" & 4 | done 5 | -------------------------------------------------------------------------------- /code/shellscript/other/linuxdocsearch: -------------------------------------------------------------------------------- 1 | echo "http://www.linuxdoc.org/cgi-bin/ldpsrch.cgi?srch=$@" -------------------------------------------------------------------------------- /code/shellscript/pkg_apk/list_available_packages.apk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apk list -a "$1" 4 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/emerge_masked_package.sh: -------------------------------------------------------------------------------- 1 | ACCEPT_KEYWORDS="~x86" emerge -av "$@" 2 | -------------------------------------------------------------------------------- /code/shellscript/string/beforefirst.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends: sed 3 | sed "s|$@.*||" 4 | -------------------------------------------------------------------------------- /code/shellscript/xwin/sloppypaste.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | while uudecode 3 | do echo "ok" 4 | done 5 | -------------------------------------------------------------------------------- /code/shellscript/emails/emailsubject: -------------------------------------------------------------------------------- 1 | grep "^Subject: " "$1" | head -n 1 | after "Subject:" | tr -d "\r" -------------------------------------------------------------------------------- /code/shellscript/init/ibmjava.sh: -------------------------------------------------------------------------------- 1 | # @sourceme 2 | 3 | export PATH=/opt/IBMJava2-13/jre/bin/:$PATH 4 | -------------------------------------------------------------------------------- /code/shellscript/init/sunjava.sh: -------------------------------------------------------------------------------- 1 | # @sourceme 2 | 3 | export PATH=/usr/java/j2re1.4.0/bin:$PATH 4 | -------------------------------------------------------------------------------- /code/shellscript/other/filetolinespace: -------------------------------------------------------------------------------- 1 | for x in `more $1` ; do 2 | echo -n "$x" "$2" ; 3 | done 4 | -------------------------------------------------------------------------------- /code/shellscript/other/findemptymp3s: -------------------------------------------------------------------------------- 1 | du -a . | grep "\.mp3$" | grep "^0" | awk ' { printf($2"\n"); } ' -------------------------------------------------------------------------------- /code/shellscript/other/fortunefind: -------------------------------------------------------------------------------- 1 | while [ true ]; do 2 | fortune 3 | done 4 | 5 | # fortunefind $@ -------------------------------------------------------------------------------- /code/shellscript/pkg_pacman/find_package_with_file.pacman.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | pacman -Qo "$1" 4 | -------------------------------------------------------------------------------- /code/shellscript/sys/getsysteminfo.sh: -------------------------------------------------------------------------------- 1 | inxi -Fxzrc0 2 | 3 | # Also (pretty summary): 4 | #neofetch 5 | -------------------------------------------------------------------------------- /code/shellscript/file/isabsolutepath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: startswith 3 | startswith "$@" "/" 4 | -------------------------------------------------------------------------------- /code/shellscript/filestream/dirsonly.sh: -------------------------------------------------------------------------------- 1 | while read NODE 2 | do [ -d "$NODE" ] && echo "$NODE" 3 | done 4 | -------------------------------------------------------------------------------- /code/shellscript/fun/weather.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -s http://wttr.in/"$*" # | head -7 | tail -5 4 | -------------------------------------------------------------------------------- /code/shellscript/monitors/monitorwho.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jwatch "w | takecols 1 2 3 8 9 10 | drop 1" 3 | 4 | -------------------------------------------------------------------------------- /code/shellscript/other/ctwsql: -------------------------------------------------------------------------------- 1 | echo "$@" > $JPATH/tmp/ctwquery.sql 2 | psql -f $JPATH/tmp/ctwquery.sql ctw -------------------------------------------------------------------------------- /code/shellscript/other/hw.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main() { 4 | printf("Hello world =)\n"); 5 | } -------------------------------------------------------------------------------- /code/shellscript/other/rpmlistallfiles: -------------------------------------------------------------------------------- 1 | for X in `rpm -qa`; do 2 | echo -e "\n$X" 3 | rpm -ql $X 4 | done -------------------------------------------------------------------------------- /code/shellscript/other/unarchive: -------------------------------------------------------------------------------- 1 | # forall -shell $@ do mkdir %s : cd %s : if : cd .. 2 | echo not written! -------------------------------------------------------------------------------- /code/shellscript/other/vimswpdiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | vi -r "$@" "+w tmp.txt" "+q" 3 | jfc "$@" tmp.txt 4 | -------------------------------------------------------------------------------- /code/shellscript/sh/countargs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | N=0 3 | for X 4 | do N=`expr $N + 1` 5 | done 6 | echo $N 7 | -------------------------------------------------------------------------------- /code/shellscript/shlib/filter_list_with.sh: -------------------------------------------------------------------------------- 1 | while read LINE 2 | do "$@" "$LINE" && echo "$LINE" 3 | done 4 | -------------------------------------------------------------------------------- /code/shellscript/wrap/viinxterm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | xterm -bg black -fg white -title "$* - VI" -e vi "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/compile/xgdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | g++ $1.c -w -o $1 -I $JPATH/joeylib -ggdb $2 $3 $4 $5 $6 |more 3 | -------------------------------------------------------------------------------- /code/shellscript/fsutils/findoldfiles.sh: -------------------------------------------------------------------------------- 1 | find "$@" -type f -printf "%AY%Am%Ad-%AH%AM%AS %p\n" | sort -n -k 1 2 | -------------------------------------------------------------------------------- /code/shellscript/mongo/mongo_show_dbs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mongo "$@" << !!! 4 | show dbs; 5 | !!! 6 | -------------------------------------------------------------------------------- /code/shellscript/net/webmintobuggy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ssh -L 8362:localhost:10000 joey@bristoldev.dyndns.org 3 | -------------------------------------------------------------------------------- /code/shellscript/other/exploredir: -------------------------------------------------------------------------------- 1 | kfmclient openURL file:///$1 & 2 | # kfmclient openURL file://$PWD/$1 & 3 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | q='#!/bin/sh\nq=$q;eval "echo \"\$q\""';eval "echo \"$q\"" 3 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine7.sh: -------------------------------------------------------------------------------- 1 | ap=\';q='ap=\\$ap;q=$ap$q$ap;eval \"echo \\\"\$q\\\"\"';eval "echo \"$q\"" 2 | -------------------------------------------------------------------------------- /code/shellscript/string/beforeext.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | EXT="$1" 3 | 4 | 'ls' *".$EXT" | 5 | sed "s+\.$EXT$++" 6 | -------------------------------------------------------------------------------- /code/shellscript/string/inquotes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sed "s+^+\'\"+" | sed "s+$+\"\'+g" 3 | sed 's+^\|$+"+g' 4 | -------------------------------------------------------------------------------- /code/shellscript/txtstream/fromcol.sh: -------------------------------------------------------------------------------- 1 | COLUMN="$1" ; shift 2 | sed 's+ *+ +g' | 3 | cut -d " " -f "$COLUMN"- 4 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/grepremove: -------------------------------------------------------------------------------- 1 | grep -v $1 $2 > $JPATH/tmp/grepremove.txt 2 | mv $JPATH/tmp/grepremove.txt $2 -------------------------------------------------------------------------------- /code/shellscript/xwin/get_current_winid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | xprop -root | grep NET_AC | grep -E -o '0x[0-9a-f]+' 3 | -------------------------------------------------------------------------------- /code/shellscript/xwin/run-or-raise.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # See also: focus-or-run 3 | wmctrl -x -a "$1" || $2 4 | -------------------------------------------------------------------------------- /code/shellscript/xwin/vlox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cp /etc/X11/XF86Config-4.vlowres /etc/X11/XF86Config-4 3 | startx 4 | -------------------------------------------------------------------------------- /code/shellscript/xwinwrap/xpdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # `jwhich xpdf` -freefont aa "$@" 3 | `jwhich xpdf` "$@" 4 | 5 | -------------------------------------------------------------------------------- /code/shellscript/net/pingtime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ping -c 5 -q $@ | awk ' BEGIN { FS="/" } { printf($4) } ' 3 | # echo -------------------------------------------------------------------------------- /code/shellscript/other/crontab: -------------------------------------------------------------------------------- 1 | # env VISUAL=vi /usr/bin/crontab $1 $2 $3 $5 $6 $7 $8 $9 2 | `jwhich crontab` "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/other/noop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # No operation call 3 | # could be improved... 4 | # echo -n "" 5 | : 6 | -------------------------------------------------------------------------------- /code/shellscript/other/thread: -------------------------------------------------------------------------------- 1 | $@ & 2 | sleep 1 3 | export PID=`findjob "$@" | tail -n 1 | awk '{ printf($3"\n") }'` -------------------------------------------------------------------------------- /code/shellscript/other/verifyexists.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test ! -e "$1"; then 3 | echo "$@ does not exist" 4 | fi 5 | -------------------------------------------------------------------------------- /code/shellscript/other/waitforkeypress: -------------------------------------------------------------------------------- 1 | read KEYPRESS 2 | ## Also buffers until : :-( 3 | # dd bs=1 count=1 4 | -------------------------------------------------------------------------------- /code/shellscript/other/watchforimages: -------------------------------------------------------------------------------- 1 | echo "ls *.bmp" > ~/watch.jwatch 2 | echo "xv \$1" > ~/do.jwatch 3 | jwatchanddo -------------------------------------------------------------------------------- /code/shellscript/proc/wotgobbleopenfiles.sh: -------------------------------------------------------------------------------- 1 | lsof -n -S 2 | cut -d ' ' -f 1 | uniq -c | sort -n -k 1 | tail -n 15 2 | -------------------------------------------------------------------------------- /code/shellscript/stream/sortbydirdepth.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | countcharsinline '/' | 3 | sort -n -k 1 | 4 | dropcols 1 5 | -------------------------------------------------------------------------------- /code/shellscript/video/getvideoresolution.sh: -------------------------------------------------------------------------------- 1 | ffmpeg -i "$1" 2>&1 | grep Video | grep -o "[0-9][0-9]*x[0-9][0-9]*" 2 | -------------------------------------------------------------------------------- /code/shellscript/web/fastestftp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in `ftpsearch "$@"`; do 3 | showpingtime "$X" & 4 | done 5 | -------------------------------------------------------------------------------- /code/shellscript/web/wikipedia.sh: -------------------------------------------------------------------------------- 1 | browse 'http://en.wikipedia.org/w/index.php?title=Special:Search'"&search=$*" 2 | -------------------------------------------------------------------------------- /code/shellscript/wrap/noescape.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mykill netscape 3 | mykill commun 4 | 'rm' $HOME/.netscape/lock 5 | -------------------------------------------------------------------------------- /code/shellscript/hugswrap/baseconv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd $JPATH/code/haskell 3 | hugswrap Base "baseconv $1 $2 \"$3\"" 4 | -------------------------------------------------------------------------------- /code/shellscript/stream/getline.sh: -------------------------------------------------------------------------------- 1 | ## See also: takeline 2 | LINENUMBER="$1" 3 | shift 4 | sed -n "$LINENUMBER"p "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/greplist: -------------------------------------------------------------------------------- 1 | # grepcount $@ | awk ' BEGIN { FS=":" }; { printf($1"\n"); } ' 2 | grep -l "$@" 3 | 4 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/locateend: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # unj locate "$1" | grep "$1\$" 3 | unj locate -r "`toregexp "$1"`$" 4 | -------------------------------------------------------------------------------- /code/shellscript/file/sortpathsbyfilename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sed 's+\(.*\)/\(.*\)+"\2" \1/\2+' | sort -f -k 1 | sed 's+.*" ++' 3 | -------------------------------------------------------------------------------- /code/shellscript/jgrm/editjgrm: -------------------------------------------------------------------------------- 1 | editandwait ~/j/code/java/parser/$1.grm 2 | cd ~/j/code/java/parser/ 3 | . ./creategrammar c 4 | -------------------------------------------------------------------------------- /code/shellscript/other/dejasearch: -------------------------------------------------------------------------------- 1 | echo "http://www.deja.com/dnquery.xp?QRY=java+code+examples&ST=MS&svcclass=dncurrent&DBS=2" -------------------------------------------------------------------------------- /code/shellscript/other/recurse: -------------------------------------------------------------------------------- 1 | echo recurse: $PWD 2 | $@ 3 | forall -stealth * -dirsonly do "cd \"%w\" && recurse $@ && cd .." -------------------------------------------------------------------------------- /code/shellscript/other/wakeupsoundcard.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() { 3 | system("/usr/sbin/sndconfig"); 4 | } 5 | -------------------------------------------------------------------------------- /code/shellscript/string/beforelast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends: sed 3 | SRCH="$@" 4 | sed ";s+\(.*\)$SRCH.*+\1+;" 5 | -------------------------------------------------------------------------------- /code/shellscript/strings/strrep.sh: -------------------------------------------------------------------------------- 1 | STR="$1" 2 | NUM="$2" 3 | 4 | for X in `seq 1 "$NUM"` 5 | do echo -n "$STR" 6 | done 7 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/nohup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Having this shell running can help tracing calls 3 | `jwhich nohup` "$@" 4 | -------------------------------------------------------------------------------- /code/shellscript/wrap/findqt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find "$@" | sed "s| |\\\\\ |" | sed "s|^|\"|" | sed "s|$|\"|" | tr "\n" " " 3 | -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-getipasroot.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() { 3 | system("/home/joey/j/tools/ppp-getip"); 4 | } 5 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_installed_packages.portage.sh: -------------------------------------------------------------------------------- 1 | cd /var/db/pkg 2 | find -mindepth 2 -maxdepth 2 | sed 's+^./++' 3 | -------------------------------------------------------------------------------- /code/shellscript/pydev/python_install_dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | pip install -r requirements.txt 5 | -------------------------------------------------------------------------------- /code/shellscript/string/afterfirstall.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joeytwiddle/jsh/HEAD/code/shellscript/string/afterfirstall.sh -------------------------------------------------------------------------------- /code/shellscript/unixwrap/vio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Redundant; use vim - 3 | "$@" > $JPATH/tmp/tmp.txt 4 | vim $JPATH/tmp/tmp.txt 5 | -------------------------------------------------------------------------------- /code/shellscript/wmctrl/wmctrl_restore_positions.sh: -------------------------------------------------------------------------------- 1 | [ -f "$HOME"/.wmctrl_stored_positions ] && . "$HOME"/.wmctrl_stored_positions 2 | -------------------------------------------------------------------------------- /code/shellscript/file/there.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$JM_UNAME" = "linux"; then 3 | test -e "$1" 4 | else 5 | exists "$1" 6 | fi 7 | -------------------------------------------------------------------------------- /code/shellscript/html/htmlall: -------------------------------------------------------------------------------- 1 | forall -dirsonly . * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/* do "cd \"%w\" && htmlimages %p Index.html" 2 | -------------------------------------------------------------------------------- /code/shellscript/intl/cedictbatchlookup.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joeytwiddle/jsh/HEAD/code/shellscript/intl/cedictbatchlookup.sh -------------------------------------------------------------------------------- /code/shellscript/monitor/logdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ( 3 | printf "TIME=" 4 | date "+%s" 5 | df 2>/dev/null 6 | ) >> $JPATH/logs/df.log 7 | -------------------------------------------------------------------------------- /code/shellscript/net/whatismyip.sh: -------------------------------------------------------------------------------- 1 | # See also: ppp-getip 2 | 3 | curl -fsSL ipinfo.io/ip ; echo 4 | 5 | #curl ifconfig.me/ip ; echo 6 | -------------------------------------------------------------------------------- /code/shellscript/other/automount: -------------------------------------------------------------------------------- 1 | umount /mnt/filfirin 2 | cp /etc/fstab.noexec /etc/fstab 3 | mount /mnt/filfirin/ 4 | mount /mnt/stig 5 | -------------------------------------------------------------------------------- /code/shellscript/other/javapath: -------------------------------------------------------------------------------- 1 | CLASSPATH="$CLASSPATH:$1"; 2 | CLASS="$2"; 3 | 4 | java -cp "$CLASSPATH" "$CLASS" $3 $4 $5 $6 $7 $8 $9 -------------------------------------------------------------------------------- /code/shellscript/other/mytest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if "$@"; then 3 | echo "yes" 4 | exit 0 5 | else 6 | echo "no" 7 | exit 1 8 | fi 9 | -------------------------------------------------------------------------------- /code/shellscript/other/restartnetwork.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() { 3 | system("/etc/rc.d/init.d/network restart"); 4 | } 5 | -------------------------------------------------------------------------------- /code/shellscript/other/xshellindir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # echo `resolvedir "$@"` 3 | gnome-terminal -e "bash -c 'cd `resolvedir "$@"` && bash'" -------------------------------------------------------------------------------- /code/shellscript/pkg/list_files_in_package.brew.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | pkg_name="$1" 4 | 5 | brew list --verbose "$pkg_name" 6 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/show_versions_for_package.portage.sh: -------------------------------------------------------------------------------- 1 | PACKAGE="$1" 2 | emerge -s "$PACKAGE" | grep -A2 "^.*/$PACKAGE$" 3 | -------------------------------------------------------------------------------- /code/shellscript/proc/findjob.2: -------------------------------------------------------------------------------- 1 | # --cols 65535 2 | env COLUMNS=65535 myps -A | grep -v "grep $@" | grep -v "findjob $@" | grep "$@" 3 | -------------------------------------------------------------------------------- /code/shellscript/spawn/browsedir: -------------------------------------------------------------------------------- 1 | echo "browsedir deprecated ?" 2 | browse "$@" 3 | # exploredir "$@" & 4 | #/usr/bin/netscape "$@" & 5 | -------------------------------------------------------------------------------- /code/shellscript/unixext/awkdrop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LINES="$1" 3 | shift 4 | 5 | awk ' { if ( NR > '$LINES' ) { print $LN } } ' "$@" 6 | -------------------------------------------------------------------------------- /code/shellscript/file/pruneemptydirs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type d -size 0 | 3 | withalldo rmdir --ignore-fail-on-non-empty --parents 4 | -------------------------------------------------------------------------------- /code/shellscript/java/quickjavadoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DESTDIR=javadoc 3 | mkdir -p $DESTDIR 4 | javadoc -d $DESTDIR `find . -name "*.java"` 5 | -------------------------------------------------------------------------------- /code/shellscript/lxde/slaylx.sh: -------------------------------------------------------------------------------- 1 | killall lxsession lxpanel openbox pcmanfm 2 | sleep 2 3 | killall -KILL lxsession lxpanel openbox pcmanfm 4 | -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-updateipasroot.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main() { 4 | system("/home/joey/j/tools/ppp-updateip"); 5 | } -------------------------------------------------------------------------------- /code/shellscript/other/forte: -------------------------------------------------------------------------------- 1 | export JDK_HOME=/usr/lib/j2sdk1.3/ 2 | runide "$@" & 3 | # forte4j -jdkhome /usr/local$JPATHdk1.2.2 & 4 | 5 | -------------------------------------------------------------------------------- /code/shellscript/other/safetar.pclark-maxx-sync: -------------------------------------------------------------------------------- 1 | cd $1 2 | echo "Compressing \"$1\" into \"$2\"" 3 | /bin/tar cfz /mnt/stig/backups/$2.tgz * 4 | -------------------------------------------------------------------------------- /code/shellscript/other/visibility.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "One day this will tell you the full path, http: URL and whatever of the given files" -------------------------------------------------------------------------------- /code/shellscript/posessive/joeyowns: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | sudo chown joey:joey "$@" -R 5 | 6 | sudo chmod u+rw "$@" -R 7 | -------------------------------------------------------------------------------- /code/shellscript/proc/psforkillchild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this-script-does-not-depend-on-jsh: pid 3 | ps --no-headers -o ppid,pid,args "$@" 4 | -------------------------------------------------------------------------------- /code/shellscript/stream/sortpathsbylastdirname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sed 's+\(.*\)/\(.*/.*\)+"\2" \1/\2+' "$@" | sort -f -k 1 | sed 's+.*" ++' 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/xterm_small.sh: -------------------------------------------------------------------------------- 1 | $JPATH/tools/xterm -font '-b&h-lucidatypewriter-medium-r-normal-*-*-80-*-*-m-*-iso8859-1' "$@" & 2 | -------------------------------------------------------------------------------- /code/shellscript/diffing/prettydiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Not to be confused with the npm prettydiff package 3 | diff "$@" | diffhighlight | more 4 | -------------------------------------------------------------------------------- /code/shellscript/java/gcj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export CLASSPATH=/usr/share/java/libgcj.jar:$CLASSPATH 3 | `jwhich gcj` --CLASSPATH "$CLASSPATH" "$@" 4 | -------------------------------------------------------------------------------- /code/shellscript/net/geturl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -nv "$@" -O - 3 | 4 | ## TODO: use lynx -source or netcat or telnet if wget not available 5 | -------------------------------------------------------------------------------- /code/shellscript/other/ttysfor: -------------------------------------------------------------------------------- 1 | # Reports the ttys in use by a user 2 | utmpdump | grep joey | awk ' BEGIN { FS="]" } { printf($5"\n") } ' | after "[" -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_installed_packages_by_size.portage.sh: -------------------------------------------------------------------------------- 1 | list_installed_packages.portage | withalldo get_package_size.portage 2 | -------------------------------------------------------------------------------- /code/shellscript/string/toglob.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$*" ] 3 | then printf "%s" "$*" | toglob 4 | else sed ' s+\[+\\[+g ; s+\]+\\]+g ' 5 | fi 6 | -------------------------------------------------------------------------------- /code/shellscript/unixext/mkdirandmv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET_FOLDER=`lastarg "$@"` 4 | 5 | mkdir -p "$TARGET_FOLDER" && 6 | 7 | mv "$@" 8 | -------------------------------------------------------------------------------- /code/shellscript/web/urltitle.sh: -------------------------------------------------------------------------------- 1 | URL="$1" 2 | cat_from_url "$URL" | 3 | tr -d '\n' | grep -i -o "]*>++' | 4 | fromhtml 5 | -------------------------------------------------------------------------------- /code/shellscript/zip/tarxfzwithprogress.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TARGETARCHIVE="$1" 3 | shift 4 | 5 | catwithprogress "$TARGETARCHIVE" | 6 | tar xz 7 | -------------------------------------------------------------------------------- /code/shellscript/audio/volumeup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | HOWMUCH="$1" 3 | if [ -z "$HOWMUCH" ] 4 | then HOWMUCH=7 5 | fi 6 | 7 | adjustvolumeby "$HOWMUCH" 8 | -------------------------------------------------------------------------------- /code/shellscript/other/jfcres: -------------------------------------------------------------------------------- 1 | $1 > $JPATH/tmp/jfc1.txt 2 | $2 > $JPATH/tmp/jfc2.txt 3 | jfc $JPATH/tmp/jfc1.txt $JPATH/tmp/jfc2.txt $3 $4 $5 $6 $7 $8 $9 -------------------------------------------------------------------------------- /code/shellscript/other/li.bat: -------------------------------------------------------------------------------- 1 | @call cp \joey\code\c\phd\images\%1.bmp image.bmp 2 | @call cp \joey\code\c\phd\images\original\%1.bmp original.bmp 3 | -------------------------------------------------------------------------------- /code/shellscript/other/makebin: -------------------------------------------------------------------------------- 1 | rm binned.bmp 2 | getbin $JPATH/images/$1.bmp $JPATH/images/regs/$1top.bmp 3 | mv binned.bmp $JPATH/images/bin/$1.bmp 4 | -------------------------------------------------------------------------------- /code/shellscript/other/pargunz: -------------------------------------------------------------------------------- 1 | FILES=$@; 2 | if [ "$FILES" = "" ]; then 3 | FILES=*; 4 | fi 5 | for x in $FILES; do 6 | gunzip "$x" & 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/other/pargz: -------------------------------------------------------------------------------- 1 | FILES=$@; 2 | if [ "$FILES" = "" ]; then 3 | FILES="*"; 4 | fi 5 | for x in $FILES; do 6 | gzip "$x" & 7 | done 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | data="echo -e \"#!/bin/sh\ndata=\"\$data\"\"\\n\$data" 3 | echo -e "#!/bin/sh\ndata=\"$data\"\n$data" 4 | -------------------------------------------------------------------------------- /code/shellscript/shlib/bounce.sh: -------------------------------------------------------------------------------- 1 | ## Not sure whether echo \"$*" or printf "%s" "$*" give exact replication, but bounce does! 2 | printf "%s\n" "$*" 3 | -------------------------------------------------------------------------------- /code/shellscript/shutil/lastarg.sh: -------------------------------------------------------------------------------- 1 | ## Simply returns the last argument in the list you provide 2 | while [ "$2" ] 3 | do shift 4 | done 5 | echo "$1" 6 | -------------------------------------------------------------------------------- /code/shellscript/wrap/links.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if test $1; then 3 | `jwhich links` "$@" 4 | else 5 | `jwhich links` $JPATH/org/jumpgate.html 6 | fi 7 | -------------------------------------------------------------------------------- /code/shellscript/zip/tarcfz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # For unix tar lacking the z option 3 | ZIPFILE="$1" 4 | shift 5 | tar cf - "$@" | gzip > "$ZIPFILE" 6 | -------------------------------------------------------------------------------- /code/shellscript/zip/tarxfz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # For unix tar lacking the z option 3 | ZIPFILE="$1" 4 | shift 5 | gunzip -c "$ZIPFILE" | tar xf - "$@" 6 | -------------------------------------------------------------------------------- /code/shellscript/audio/resample_wav.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sox badrate.wav -r 44100 goodrate.wav resample 3 | # sox badrate.wav -r 32000 goodrate.wav resample 4 | -------------------------------------------------------------------------------- /code/shellscript/audio/volumedown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | HOWMUCH="$1" 3 | if [ -z "$HOWMUCH" ] 4 | then HOWMUCH=7 5 | fi 6 | 7 | adjustvolumeby -"$HOWMUCH" 8 | -------------------------------------------------------------------------------- /code/shellscript/cvswrap/savelinks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type l | while read X; do 3 | Y=`justlinks "$X"` 4 | echo "ln -s \"$Y\" \"$X\"" 5 | done 6 | -------------------------------------------------------------------------------- /code/shellscript/git/gitinit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | verbosely git init 5 | 6 | verbosely git commit --allow-empty -m 'Initial empty commit' 7 | -------------------------------------------------------------------------------- /code/shellscript/monitors/get_gpu_temperature.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sensors | grep '^temp1:' | takecols 2 | sort -n | tail -n 1 | sed 's/^+\([0-9]*\)\..*$/\1/' 3 | -------------------------------------------------------------------------------- /code/shellscript/other/brainwaves: -------------------------------------------------------------------------------- 1 | kpm & 2 | ktop & 3 | konsole -nowelcome -caption "monitorps: Watching for new processes" -e sh $JPATH/tools/monitorps & 4 | -------------------------------------------------------------------------------- /code/shellscript/other/ensurefilename: -------------------------------------------------------------------------------- 1 | echo "$@" | sed "s///g" | sed "s/\///g" | sed "s/\\\\//g" | sed "s/\"//g" | sed "s/\?//g" | tr -d "\r" -------------------------------------------------------------------------------- /code/shellscript/stream/tolinesh.sh: -------------------------------------------------------------------------------- 1 | while read LINE 2 | do 3 | if [ "$LINE" = "$*" ] 4 | then break 5 | else printf "%s\n" "$LINE" 6 | fi 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/tex/texfindimgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | grep 'images/' *.tex | 3 | after ':' | before '%' | 4 | after 'images/' | before ',' | 5 | trimempty 6 | -------------------------------------------------------------------------------- /code/shellscript/audio/unfadevolume.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in `seq 1 1 90` 3 | do 4 | set_volume "$X"% # added % for Alsa 5 | sleep 20 # slowly 6 | done 7 | -------------------------------------------------------------------------------- /code/shellscript/file/linksinpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Unfinished 3 | while ! "$PWD" = "/"; do 4 | echo "$pwd=$PWD" 5 | ls -ld "$PWD" 6 | cd .. 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/mail/mailtofile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # TMPFILE=`jgettmp "mail.tmp"` 3 | # 4 | # cat > "$TMPFILE" 5 | # 6 | # echo "s 1 $1" | mail -f "$TMPFILE" 7 | -------------------------------------------------------------------------------- /code/shellscript/net/show_dns_records.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # On Windows: dnslook -type=txt "$domain" 4 | 5 | for domain 6 | do dig any -q "$domain" 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/other/ctwport: -------------------------------------------------------------------------------- 1 | cd /home/httpd/servlets 2 | tar cfzh $JPATH/out/ctwport.tgz */*.java data/* ../html/*.html ../html/*/*.html ../html/*/*/*.html 3 | -------------------------------------------------------------------------------- /code/shellscript/other/makebintools: -------------------------------------------------------------------------------- 1 | cd $JPATH/code/c/tools 2 | cd forall 3 | xt forall 4 | cd .. 5 | forall -shell -stealth -dirsonly * do cd %f : xt %f : cd .. -------------------------------------------------------------------------------- /code/shellscript/other/newbookmarks: -------------------------------------------------------------------------------- 1 | jfc ~/.netscape/bookmarks.html.old ~/.netscape/bookmarks.html 2 | # cp ~/.netscape/bookmarks.html ~/.netscape/bookmarks.html.old -------------------------------------------------------------------------------- /code/shellscript/other/searchcddb: -------------------------------------------------------------------------------- 1 | QUERY=`echo $@ | sed "s/ /+/g"` 2 | browseurl "http://www.cddb.com/php/search1.php3?f=artist&f=disc&f=track&q=$QUERY&image=Search" -------------------------------------------------------------------------------- /code/shellscript/other/showpingtime: -------------------------------------------------------------------------------- 1 | HOST=`url2host "$@"` 2 | TIME=`pingtime $HOST` 3 | if [ "$TIME" = "" ]; then 4 | TIME=" inf" 5 | fi 6 | echo "$TIME $@" 7 | -------------------------------------------------------------------------------- /code/shellscript/pkg/tarpkg.sh: -------------------------------------------------------------------------------- 1 | for PKG 2 | do 3 | dpkg -L "$PKG" | 4 | filesonly -inclinks | 5 | withalldo verbosely tar cfz /tmp/"$PKG".tgz 6 | done 7 | 8 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_duplicate_installed_versions-dodgy.portage.sh: -------------------------------------------------------------------------------- 1 | sh ./list_installed_packages.portage | beforelast -[0-9] | keepduplicatelines 2 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | a="#!/bin/sh\na=;echo \"\$q\""; 3 | b=$(echo "$a" | sed "s++$a+") 4 | echo -e "#!/bin/sh\na=\"$a\"\n$b" 5 | -------------------------------------------------------------------------------- /code/shellscript/web/searches/freshmeatsearch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CGI=`echo "$@" | tr ' ' '+'` 3 | echo "http://www.freshmeat.net/search?section=projects&q=$CGI" 4 | -------------------------------------------------------------------------------- /code/shellscript/wmctrl/getcurrentwindowtitle.sh: -------------------------------------------------------------------------------- 1 | winid=`xdotool getwindowfocus` 2 | xwininfo -id "$winid" | grep "^xwininfo: " | sed 's+^[^"]*"++ ; s+"$++' 3 | -------------------------------------------------------------------------------- /code/shellscript/xwin/hix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # newback 3 | cp /etc/X11/XF86Config-4.highres /etc/X11/XF86Config-4 4 | startx 5 | # xinit $JPATH/tools/kde.xinit 6 | -------------------------------------------------------------------------------- /code/shellscript/xwin/takesomescreenshots.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ "$1" ] && export DISPLAY="$1" 3 | for X in `seq 1 10` 4 | do 5 | xsnapshot 6 | sleep 10 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/diff/jfcdiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILEA="$1" 3 | FILEB="$2" 4 | 5 | jfc diff "$FILEA" "$FILEB" 6 | 7 | vim "$FILEA.diff" "$FILEB.diff" -c '/@@>>' 8 | -------------------------------------------------------------------------------- /code/shellscript/jsh/makedebugtooldir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## TODO 3 | # for X in *; do echo 'sh -x $JPATH/tools2/`echo "$0" | sed "s+.*/++"` "$@"' > ../tools/$X; done 4 | -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-off: -------------------------------------------------------------------------------- 1 | # jsh-depends: hwippp findjob 2 | findjob pppd 3 | 4 | hwippp down 5 | 6 | # killall -KILL pppd > /dev/null 2>&1 7 | findjob pppd 8 | -------------------------------------------------------------------------------- /code/shellscript/monitors/get_cpu_temperature.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sensors | grep '^Core [0-9]*:' | takecols 3 | sort -n | tail -n 1 | sed 's/^+\([0-9]*\)\..*$/\1/' 3 | -------------------------------------------------------------------------------- /code/shellscript/net/pingallips.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # echo "" > ping.tmp 3 | forall -stealth in "$@" do "showpingtime %w" # " >> ping.tmp &" 4 | # tail -f ping.tmp 5 | -------------------------------------------------------------------------------- /code/shellscript/other/findshellscripts: -------------------------------------------------------------------------------- 1 | find /bin /sbin /etc /usr /home -follow -size 1 -perm -a+x # > $JPATH/tmp/ss.txt 2 | # forall in $JPATH/tmp/ss.txt do grepcount -------------------------------------------------------------------------------- /code/shellscript/other/jrep: -------------------------------------------------------------------------------- 1 | DELAY=1 2 | [ "$1" = -delay ] && DELAY="$2" && shift && shift 3 | 4 | while true 5 | do 6 | eval "$@" 7 | sleep "$DELAY" 8 | done 9 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/find_package_with_file.portage.sh: -------------------------------------------------------------------------------- 1 | equery belongs "$1" 2 | 3 | ## Or for files you don't have installed: http://portagefilelist.de/ 4 | -------------------------------------------------------------------------------- /code/shellscript/string/removetabs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | X="$@" 3 | cp "$X" "$X.b4rt" 4 | cat "$X.b4rt" | sed "s+ + +g" > "$X" 5 | # cat "$X.b4rt" | tr "\t" " " > "$X" 6 | -------------------------------------------------------------------------------- /code/shellscript/string/replace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SEARCHRE=`toregexp "$1"` 3 | REPLACERE="$2" 4 | shift ; shift 5 | 6 | sed "s$SEARCHRE$REPLACEREg" "$@" 7 | 8 | -------------------------------------------------------------------------------- /code/shellscript/versioning/cvslistnewfiles.sh: -------------------------------------------------------------------------------- 1 | cvsdiff -all . | grep " add " | takecols 3 | grep -v "\.sw.$" | filesonly | sortfilesbydate | 2 | sed 's+^+cvs add +' 3 | -------------------------------------------------------------------------------- /code/shellscript/wrap/lynx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: unj 3 | if [ ! "$*" ] 4 | then unj lynx http://hwi.ath.cx/jumpgate.html 5 | else unj lynx "$@" 6 | fi 7 | -------------------------------------------------------------------------------- /code/shellscript/compile/xt: -------------------------------------------------------------------------------- 1 | # x $1 2 | jmake $1 && 3 | # jwhere $1 & 4 | mv $1 $JPATH/bin && 5 | chmod a+x $JPATH/bin/$1 && 6 | cd $JPATH/tools && 7 | ln -sf ../bin/$1 . 8 | -------------------------------------------------------------------------------- /code/shellscript/file/lx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | file * | while read X; do Y=`echo "$X" | sed "s/:.*//"`; Z=`echo "$X" | afterfirst :`; ls -d "$Y" | tr -d "\n"; echo "$Z"; done 3 | -------------------------------------------------------------------------------- /code/shellscript/maths/getnumber.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ "$1" ] && echo "$*" | getnumber || 3 | # Takes a number from the front of the stream. 4 | sed 's/[^0123456789\.].*//' 5 | -------------------------------------------------------------------------------- /code/shellscript/modem/showmodemtransfer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jwatch ls -l $JPATH/logs/packetdata.ppp # | awk ' { newsofar = $5; print (newsofar-sofar); sofar=newsofar; } ' 3 | -------------------------------------------------------------------------------- /code/shellscript/other/javadocs: -------------------------------------------------------------------------------- 1 | netscape "file:/usr/local/jdk1.2.2/docs/index.html" & 2 | # sleep 1m 3 | netscape "file:/usr/local/jdk1.2.2/docs/tutorial/index.html" & 4 | -------------------------------------------------------------------------------- /code/shellscript/other/nicedate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends-ignore: apm 3 | # date +"%d/%m/%Y %H:%M%p" "$@" 4 | date +"%H:%M%p %d/%m/%Y" "$@" | tr "APM" "apm" 5 | -------------------------------------------------------------------------------- /code/shellscript/other/uniquejfc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jfc simple oneway $1 $2 $3 $4 $5 $6 $7 $8 $9 > $1.unique 3 | jfc simple oneway $2 $1 $3 $4 $5 $6 $7 $8 $9 > $2.unique -------------------------------------------------------------------------------- /code/shellscript/shext/jxargs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | error jxargs "You are recommended to use foreachdo or withalldo" 3 | # while read LINE 4 | # do "$@" "$LINE" 5 | # done 6 | -------------------------------------------------------------------------------- /code/shellscript/shext/runifexists.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | COMMAND=`which "$1"` 3 | shift 4 | 5 | if [ "$COMMAND" ] && [ -x "$COMMAND" ] 6 | then "$COMMAND" "$@" 7 | fi 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/wine/slaywine.sh: -------------------------------------------------------------------------------- 1 | mykill -x '.*\.exe' '.*\.EXE' wineserver # 'C:\\.*\.exe' 2 | 3 | # winedbg sometimes has a useful error message 4 | mykill -x winedbg 5 | -------------------------------------------------------------------------------- /code/shellscript/nicels/listfilesbydate.sh: -------------------------------------------------------------------------------- 1 | if [ -n "$*" ] 2 | then sortfilesbydate "$@" 3 | else sortfilesbydate * 4 | fi | 5 | foreachdo ls --color -ld --block-size="'1" 6 | -------------------------------------------------------------------------------- /code/shellscript/rpm/findpkgsunused.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 'ls' -aultr /usr/bin | takecols 9 | head -n 100 | while read X; do dlocate -S /usr/bin/$X | grep "/usr/bin/$X$"; done 3 | -------------------------------------------------------------------------------- /code/shellscript/sh/shtrace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "DOESN'T WORK (yet)" 3 | export PS4=`printf "\033[00;31m"`'#dpkg-buildpackage'`printf "\033[00m"`'% ' 4 | /bin/sh +x -c "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/zip/is_archive.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grep -E '\.(gz|tar|tar.gz|tar.bz2|tgz|tgj|arj|taz|lzh|zip|z|Z|rar|jar|lha|7z|xz|zst)$' <<< "$1" >/dev/null 4 | -------------------------------------------------------------------------------- /code/shellscript/emails/emaildate: -------------------------------------------------------------------------------- 1 | #grep "^Date: " "$1" | head -n 1 | after "Date:" 2 | DATESTR=`grep "^Date: " "$1" | head -n 1 | after "Date:"` 3 | date --date="$DATESTR" +%Y%m%d%H%M -------------------------------------------------------------------------------- /code/shellscript/emails/emailsortall: -------------------------------------------------------------------------------- 1 | del "$HOME/mailsort" 2 | START="$PWD"; 3 | forall * */* */*/* */*/*/* */*/*/*/* -dirsonly do -shell cd '"%w"' : emailsort "*" : cd '"$START"' 4 | -------------------------------------------------------------------------------- /code/shellscript/jshlogging/jshquestion.sh: -------------------------------------------------------------------------------- 1 | ## Usage: jshquestion "What is your name ["anon"/your name] ? " 2 | echo -n "`curseyellow;cursebold`[QUESTION]`cursenorm` $*`cursenorm`" 3 | -------------------------------------------------------------------------------- /code/shellscript/other/cmptgz: -------------------------------------------------------------------------------- 1 | tar tfz $1.tgz > $JPATH/tmp/cmptgz1.txt 2 | tar tfz $2.tgz > $JPATH/tmp/cmptgz2.txt 3 | jfc $JPATH/tmp/cmptgz?.txt 4 | # rm -f $JPATH/tmp/cmptgz?.txt 5 | -------------------------------------------------------------------------------- /code/shellscript/tmpsys/getuniquefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILE="$@" 3 | X=$$; 4 | while test -f "$FILE""$X"; do 5 | X=$[$X+1]; 6 | done 7 | touch "$FILE""$X" 8 | echo "$FILE""$X" 9 | -------------------------------------------------------------------------------- /code/shellscript/web/searches/sourceforgesearch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CGI=`echo "$@" | tr ' ' '+'` 3 | echo "http://www.sourceforge.net/search?type_of_search=soft&exact=1&words=$CGI" 4 | -------------------------------------------------------------------------------- /code/shellscript/wrap/soffice51: -------------------------------------------------------------------------------- 1 | /stuff/install/StarOffice5.1/bin/soffice & 2 | # `jwhich soffice` file://$PWD/$@ & 3 | # $JPATH/install/other/Office51/bin/soffice file://$PWD/$@ & 4 | -------------------------------------------------------------------------------- /code/shellscript/apt/apt-get-autoremove-purge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script is just a reminder to myself that I often want to --purge config files 3 | apt-get autoremove --purge "$@" 4 | -------------------------------------------------------------------------------- /code/shellscript/duplicates.txt: -------------------------------------------------------------------------------- 1 | find . -type f | grep -v /CVS/ | afterlast / | beforefirst \\\. | keepduplicatelines | while read X; do find . -name "$X*" | grep -v "/CVS/"; echo; done 2 | -------------------------------------------------------------------------------- /code/shellscript/git/git-ignore.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | git_root_folder="$(git rev-parse --show-toplevel)" 5 | 6 | echolines "$@" >> "$git_root_folder"/.gitignore 7 | -------------------------------------------------------------------------------- /code/shellscript/monitors/monitor_disk_usage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jwatch -delay 10 "listopenfiles -mergethreads '\(gtk-gnu\|mute\|apache\|xmms\|mpg123\|mp3gain\)' -u joey,www-data,oddjob" 3 | -------------------------------------------------------------------------------- /code/shellscript/other/fortune: -------------------------------------------------------------------------------- 1 | ## This used to log fortunes, but directories for it no longer exist, so it was broken, and I don't want it anymore anyway. 2 | unj /usr/games/fortune $@ 3 | -------------------------------------------------------------------------------- /code/shellscript/other/grabmp3s: -------------------------------------------------------------------------------- 1 | mount /mnt/cdrom 2 | cd /mnt/cdrom 3 | MP3S=`find . -name "*.mp3*"`; 4 | MP3S="$MP3S "`find . -name "*.MP3*"`; 5 | nice -n 20 'cp -P $MP3S $JPATH/tracks/' -------------------------------------------------------------------------------- /code/shellscript/pkg/list_installed_packages_chronologically.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jzcat /var/log/dpkg.log* | grep "^[^ ]* *[^ ]* *\<\(install\|remove\|purge\|upgrade\)\>" | sort -k 1,2 3 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_available_packages.portage.sh: -------------------------------------------------------------------------------- 1 | # cd /usr/portage/metadata/cache 2 | cd /var/cache/edb/dep/usr/portage 3 | find -mindepth 2 -maxdepth 2 | sed 's+^./++' 4 | -------------------------------------------------------------------------------- /code/shellscript/xwin/copy_to_clipboard.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ "$(uname)" = Darwin ] 4 | then 5 | cat "$@" | pbcopy 6 | else 7 | cat "$@" | xclip -selection c 8 | fi 9 | -------------------------------------------------------------------------------- /code/shellscript/xwin/hugewin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Rubbish atm 3 | xterm -bg '#600000' -geometry 200x50 -font '-b&h-lucidatypewriter-medium-r-normal-*-*-60-*-*-m-*-iso8859-1' -e "$@" & 4 | -------------------------------------------------------------------------------- /code/shellscript/zip/openzipwith.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TMPDIR=`jgettmp unzip` 3 | rm -f "$TMPDIR" 4 | mkdir -p "$TMPDIR" 5 | cp "$@" "$TMPDIR" 6 | cd "$TMPDIR" 7 | gunzip * 8 | konqueror * 9 | -------------------------------------------------------------------------------- /code/shellscript/audio/agsatellite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | du -sh /stuff/mp3s/audiogalaxy > $JPATH/tmp/ag-start 3 | `jwhich agsatellite` "$@" 4 | du -sh /stuff/mp3s/audiogalaxy > $JPATH/tmp/ag-end 5 | -------------------------------------------------------------------------------- /code/shellscript/edit/vimkeepdate.sh: -------------------------------------------------------------------------------- 1 | file="$1" 2 | [ -f "$file" ] || ( echo "Not a file: $f" ; exit 1 ) 3 | oldDate="`LC_TIME=C date -r "$file"`" 4 | vim "$@" 5 | date -d "$oldDate" "$file" 6 | -------------------------------------------------------------------------------- /code/shellscript/mp3/whichmp3: -------------------------------------------------------------------------------- 1 | if test "x$1" = "xcurrent"; then 2 | tail -n 2 $JPATH/tmp/xmms-output.txt | head -n 1 3 | else 4 | tail -n 5 $JPATH/tmp/xmms-output.txt | head -n 1 5 | fi 6 | -------------------------------------------------------------------------------- /code/shellscript/sh/forx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LIST="" 3 | while test ! "x$2" = "x"; do 4 | LIST=$LIST" ""$1" 5 | shift 6 | done 7 | 8 | for X in $LIST; do 9 | $1 "$X" 10 | done 11 | -------------------------------------------------------------------------------- /code/shellscript/shext/breakonctrlc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Execute as `breakonctrlc` 3 | # Don't know why it works really 4 | # Not ideal solution 5 | printf "" # to allow compilating into fn 6 | -------------------------------------------------------------------------------- /code/shellscript/shext/reply.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## returns imeediately with the error code provided 3 | ## I'm sure there is already a way to do this, but I forgot what it was! 4 | exit "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/xwin/startgnome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gnome/lib 3 | # /opt/gnome/bin/sawmill & 4 | /opt/gnome/bin/panel & 5 | # /opt/gnome-1.4/bin/panel & 6 | -------------------------------------------------------------------------------- /code/shellscript/SCRIPTING_TIPS.txt: -------------------------------------------------------------------------------- 1 | I often do: 2 | 3 | PASS=`cat /path/to/pwdfile` 4 | 5 | But someone has pointed out that this is prettier: 6 | 7 | read PASS < /path/to/pwdfile 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursegrey.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Invisible on Mdk xterm: 3 | # printf "\033[00;37m" 4 | printf "\033[00;90m" 5 | # Visible: 6 | # printf "\033[01;37m" 7 | # printf "\033[00m" 8 | -------------------------------------------------------------------------------- /code/shellscript/cvswrap/viewcvs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | REPOSANDDIR=`cat CVS/Repository` 3 | HOSTNAME=`hostname -f` 4 | browse "http://$HOSTNAME/cgi-bin/viewcvs.cgi/$REPOSANDDIR?sortby=date#dirlist" 5 | -------------------------------------------------------------------------------- /code/shellscript/mail/decode_base64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat > /tmp/xyz 3 | 4 | perl -e ' 5 | use MIME::Base64; 6 | $str = decode_base64("'`cat /tmp/xyz | tr -d '\n'`'"); 7 | printf($str); 8 | ' 9 | -------------------------------------------------------------------------------- /code/shellscript/mp3/downsamplemp3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Defaults 48khz out 3 | mpg123 -w - "$1" | 4 | ## Defaults 48khz in 5 | ## But only MPEG layer 2 6 | toolame -b 128 /dev/stdin "LOWER_$1" 7 | -------------------------------------------------------------------------------- /code/shellscript/node/npmlist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Like `npm list` but only shows the top level of packages 4 | 5 | npm list --depth=0 "$@" 6 | 7 | #| grep "^[^\b][^\b][^\b][^\b]\b" 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/other/li: -------------------------------------------------------------------------------- 1 | #cp /mnt/filfirin/joey/code/c/phd/images/small/$1.bmp image.bmp 2 | cp /mnt/filfirin/joey/code/c/phd/images/$1.bmp original.bmp 3 | scale original.bmp image.bmp -s 0.5 4 | -------------------------------------------------------------------------------- /code/shellscript/other/news: -------------------------------------------------------------------------------- 1 | READALL="-n" 2 | if [ "$1" = "all" ]; then 3 | READALL="" 4 | fi 5 | # tin -n -g news.care4free.net 6 | # tin $READALL -g news.cableinet.net 7 | tin -g localhost 8 | -------------------------------------------------------------------------------- /code/shellscript/pkg_pacman/list_installed_packages.pacman.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | pacman -Qn | grep -e "$*" 4 | 5 | # To list packages by searching descriptions: 6 | #pacman -Qs "$*" 7 | -------------------------------------------------------------------------------- /code/shellscript/scripts_which_override_existing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## See listoverrides 3 | cd $JPATH/tools 4 | find . -type l | sed 's+\.\/++' | while read X; do jwhich "$X" && echo "$X"; done 5 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursewhite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # On xterm with white bg, this comes out as black! Or does it? It seems to be better to use cursenorm than cursewhite. 3 | printf "\033[01;37m" 4 | -------------------------------------------------------------------------------- /code/shellscript/other/allinone: -------------------------------------------------------------------------------- 1 | # forall $@ do echo %f 2 | # From file: 3 | forall -shell in "$1" -stealth do echo -en "\"%w \"" 4 | # forall -shell in "$1" -stealth do echo -en "\"\\\"%w\\\" \"" 5 | -------------------------------------------------------------------------------- /code/shellscript/other/revisionchanges: -------------------------------------------------------------------------------- 1 | cd /home/joey/j/code/c/joeylib 2 | forall *.c *.h do rcs -i -t-autostart %f : rcs -ajoey,root %f : ci -q -t-autochangeerror -mautochange %f : co -q %f -stealth 3 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/jinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Colours don't work! 3 | # whitewin -geometry 80x50 -title "info $*" -e vim "+:Info $*" 4 | whitewin -geometry 80x50 -title "info $*" -e info "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/fs/nodecount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## e.g.: nodecount ./* | sort -n -k 2 | columnise 3 | 4 | for DIR 5 | do 6 | COUNT=`find "$DIR" | wc -l` 7 | printf "%s\t%s\n" "$COUNT" "$DIR" 8 | done 9 | -------------------------------------------------------------------------------- /code/shellscript/oscompat/unix2dos.sh: -------------------------------------------------------------------------------- 1 | if [ "$*" ] 2 | then 3 | for FILE 4 | do cat "$FILE" | unix2dos | pipebackto "$FILE" 5 | done 6 | else 7 | CL=`printf "\r"` 8 | sed "s+$+$CL+" 9 | fi 10 | -------------------------------------------------------------------------------- /code/shellscript/other/getsync: -------------------------------------------------------------------------------- 1 | jsync $@ 2 | cat $JPATH/tmp/sync-summary.txt 3 | FILES=`allinone $JPATH/tmp/sync-keeping.txt` 4 | tar cfz sync.tgz $FILES 5 | # echo `allinone $JPATH/tmp/sync-keeping.txt` 6 | -------------------------------------------------------------------------------- /code/shellscript/standin/realpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: resolvedir jwhich 3 | RP=`jwhich realpath 2> /dev/null` 4 | if test "$?" = "0"; then 5 | $RP "$@" 6 | else 7 | resolvedir "$@" 8 | fi 9 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/infcat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # It's an infinite cat, because it never stops catting 3 | # You can add stuff to the bottom of the file and it will get catted 4 | tail -100000000f "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/web/fastestfilesearch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | lynx -dump "http://www.filesearch.ru/cgi-bin/s?q=$@&t=f" | 3 | grep "$@" | grep "^ " | afterfirstall " " 4 | # grep "q=" | afterfirstall "q=" 5 | -------------------------------------------------------------------------------- /code/shellscript/html/htmlpagewrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "" 3 | echo "" 4 | echo "$*" 5 | echo "" 6 | echo "" 7 | cat 8 | echo "" 9 | echo "" 10 | -------------------------------------------------------------------------------- /code/shellscript/image/imageinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # for FILE 3 | # do convert -verbose "$FILE" /tmp/imageinfo-$$.jpg 4 | # done 5 | # rm -f /tmp/imageinfo-$$.jpg 6 | for FILE 7 | do identify "$FILE" 8 | done 9 | -------------------------------------------------------------------------------- /code/shellscript/other/doread: -------------------------------------------------------------------------------- 1 | forall *.ps do gv \"%f\" 2 | forall *.ps.gz *.ps.Z do ghostview \"%f\" 3 | forall *.pdf do acroread \"%f\" 4 | forall *.html do exploredir \"%f\" 5 | forall *.txt do editandwait \"%f\" -------------------------------------------------------------------------------- /code/shellscript/unixwrap/grepcount: -------------------------------------------------------------------------------- 1 | grep -c "$@" | grep -v ":0" | sort -n -t : -k 2 2 | # grep -c $@ | grep -v ":0" 3 | # grep $1 * -r -c > /tmp/tmp.grep 4 | # grep ":0" -v /tmp/tmp.grep 5 | # rm /tmp/tmp.grep 6 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/grepgetfilename: -------------------------------------------------------------------------------- 1 | grep $@ -c | grep ":0" -v | awk ' BEGIN { FS=":" }; { printf($1"\n"); } ' 2 | #grep $1 * -r -c > /tmp/tmp.grep 3 | #grep ":0" -v /tmp/tmp.grep 4 | #rm /tmp/tmp.grep 5 | -------------------------------------------------------------------------------- /code/shellscript/fonts/generate_fontlist_html.sh: -------------------------------------------------------------------------------- 1 | ( 2 | echo '' 3 | fc-list | 4 | sed 's/\(.*\):.*/\1<\/font>
/' | 5 | sort | uniq 6 | echo '' 7 | ) > fonts.html 8 | -------------------------------------------------------------------------------- /code/shellscript/git/git-list-untracked.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | git clean -dn | sed 's+^Would remove ++' 4 | 5 | # This will give many more results. Why? 6 | #git status --porcelain -uall | grep '^?? ' 7 | -------------------------------------------------------------------------------- /code/shellscript/git/git-undo-last-commit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | echo "Undoing last commit and index, leaving files alone" 3 | git reset 'HEAD~' 4 | echo "The \"lost\" commit will remain for a while in git reflog" 5 | -------------------------------------------------------------------------------- /code/shellscript/jshlib/jshsuggest.sh: -------------------------------------------------------------------------------- 1 | if [ "$DO" ] 2 | then verbosely "$@" 3 | else echo "`cursegreen;cursebold`[Suggestion]`cursebold` % `cursecyan`$* `curseyellow;cursebold`(rerun with DO=1)`cursenorm`" 4 | fi 5 | -------------------------------------------------------------------------------- /code/shellscript/ls/dsr: -------------------------------------------------------------------------------- 1 | ## Show size in bytes, not human readable size. 2 | 3 | ## For Linux: 4 | ls -alrSF --color --block-size="'1" "$@" 5 | 6 | ## For other ixes: 7 | # ls $JM_LS_OPTS -al "$@" | sort -n -k 5 8 | -------------------------------------------------------------------------------- /code/shellscript/other/wakeupsoundcard: -------------------------------------------------------------------------------- 1 | ## A hack to initialise my soundcard (when I was using RedHat6.0!) 2 | aumix -v0 3 | # so that sndconfig can find insmod 4 | # cd /sbin 5 | /usr/sbin/sndconfig 6 | aumix -v100 7 | -------------------------------------------------------------------------------- /code/shellscript/proc/benicetome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "x$1" = "x"; then 3 | echo "benicetome \$\$" 4 | exit 1 5 | fi 6 | 7 | PID="$1" 8 | requestsudo ". $JPATH/startj 9 | myrenice -15 '$PID'" 10 | -------------------------------------------------------------------------------- /code/shellscript/spawn/vncpanic: -------------------------------------------------------------------------------- 1 | ( TMP=`jgettmp` 2 | echo 'runoneof "xvncviewer vncviewer" -bgr233 panic.cs.bris.ac.uk:1' > $TMP 3 | chmod a+x $TMP 4 | xterm -geometry 80x5 -e $TMP & 5 | sleep 5 6 | jdeltmp $TMP ) & 7 | -------------------------------------------------------------------------------- /code/shellscript/stream/grepor.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | args=("$@") 5 | for (( i = 0; i < ${#args[@]}; i++ )) 6 | do args[$i]="-e${args[$i]}" 7 | done 8 | 9 | exec grep "${args[@]}" 10 | -------------------------------------------------------------------------------- /code/shellscript/unix/whichall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | file="$1" 5 | 6 | echo "$PATH" | tr ':' '\n' | 7 | 8 | while read dir 9 | do [ -x "${dir}/${file}" ] && echo "${dir}/${file}" 10 | done 11 | -------------------------------------------------------------------------------- /code/shellscript/xwin/lox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # startx -- -bpp 24 3 | 4 | #newback 5 | cp /etc/X11/XF86Config-4.lowres /etc/X11/XF86Config-4 6 | startx 2>&1 | tee $JPATH/logs/X.log 7 | #xinit $JPATH/tools/kde.xinit 8 | -------------------------------------------------------------------------------- /code/shellscript/audio/boost_volume.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also: pavucontrol 3 | 4 | volume="$1" 5 | [ -z "$volume" ] && volume="150" 6 | 7 | pactl -- set-sink-volume 0 "$volume"% 8 | 9 | # or +1dB or -10% 10 | -------------------------------------------------------------------------------- /code/shellscript/logging/showerrlogall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # From: http://unix.stackexchange.com/questions/91779/what-is-the-name-of-the-shell-feature-tee-copyerror-txt-2 3 | "$@" 1> stdout.log 2> >(tee stderr.log >&2) 4 | -------------------------------------------------------------------------------- /code/shellscript/other/arguments: -------------------------------------------------------------------------------- 1 | # set -b -k $HELLO 2 | echo "[arguments] \$#: $#" 3 | echo "$HELLO" 4 | echo "$ARGUMENTS" 5 | echo "$1" 6 | echo "$-" 7 | echo "$" 8 | echo "$N" 9 | echo "$1-$9" 10 | echo $@ 11 | -------------------------------------------------------------------------------- /code/shellscript/other/majidcansee.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in "$@"; do 3 | if test -f $X; then 4 | setfacl -f $HOME/facl.file $X 5 | elif test -d $X; then 6 | setfacl -f $HOME/facl.dir $X 7 | fi 8 | done 9 | -------------------------------------------------------------------------------- /code/shellscript/rpm/TODO.txt: -------------------------------------------------------------------------------- 1 | this directory should be called pkg or something because it does debs, rpms and urpmi-confs 2 | also, it would be nice to expose a flavour-independent interface 3 | to package management 4 | -------------------------------------------------------------------------------- /code/shellscript/tex/jdistill.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | distill -compresstext on -colorres 1200 -grayres 1200 -monores 1200 "$@" 3 | # distill -compresstext on -colorres 600 -grayres 600 -monores 600 "$@" 4 | # ps2pdf -r600 "$@" 5 | -------------------------------------------------------------------------------- /code/shellscript/txtstream/prepend_each_line.sh: -------------------------------------------------------------------------------- 1 | PREPEND_STRING="$1" 2 | 3 | sed "s^$1g" 4 | 5 | # while IFS= read LINE 6 | # # do echo "$PREPEND_STRING$LINE" 7 | # do printf "%s\n" "$PREPEND_STRING$LINE" 8 | # done 9 | -------------------------------------------------------------------------------- /code/shellscript/xwin/xtermindir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # xtermsh "cd \"$1\"; jsh" 3 | 4 | TODIR="$1" 5 | shift 6 | TODO="$@" 7 | if [ ! "$TODO" ] 8 | then TODO="bash" 9 | fi 10 | xtermsh "cd \"$TODIR\"; $TODO" 11 | -------------------------------------------------------------------------------- /code/shellscript/find/findaged.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | AGEFILE=`jgettmp findaged` 3 | 4 | AGE="$1" 5 | shift 6 | 7 | touch -d "$AGE ago" $AGEFILE 8 | 9 | find . -not -newer $AGEFILE "$@" 10 | 11 | jdeltmp $AGEFILE 12 | -------------------------------------------------------------------------------- /code/shellscript/nicels/listfilesbyaccessdate.sh: -------------------------------------------------------------------------------- 1 | ## Useful in scripts: 2 | find . -type f -printf "%A@ %p\n" | sort -n -k 1 | 3 | dropcols 1 | 4 | 5 | ## Pretty-print (change format!) for user: 6 | foreachdo dar -ld 7 | 8 | -------------------------------------------------------------------------------- /code/shellscript/other/cutcols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "$1" ] 4 | then 5 | numcols="$1" 6 | shift 7 | else 8 | #numcols="$COLUMNS" 9 | numcols="$(tput cols)" 10 | fi 11 | 12 | cut -c 1-"${numcols}" "$@" 13 | -------------------------------------------------------------------------------- /code/shellscript/other/securecp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in $1; do 3 | echo scp -B $X $2 $3 4 | scp $X $2 5 | if test "$?" = "0"; then 6 | echo "Copied OK" 7 | else 8 | echo "Error" 9 | fi 10 | done 11 | -------------------------------------------------------------------------------- /code/shellscript/compile/xgprof: -------------------------------------------------------------------------------- 1 | echo "" 2 | echo "The compiler is your friend (gcov-ing) ------------------------------" 3 | echo "" 4 | g++ $1.c -w -o $1 -fconserve-space -I $JPATH/joeylib -g -pg $2 $3 $4 $5 $6 5 | chmod g+x $1 6 | -------------------------------------------------------------------------------- /code/shellscript/git/git-remove-merged-branches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # But I really want to remove the merged branches on remote too 4 | verbosely git branch --delete $(git branch --merged | grep -v '^\*' | grep -v '\smaster$') 5 | -------------------------------------------------------------------------------- /code/shellscript/other/before: -------------------------------------------------------------------------------- 1 | ## Since neither beforefirst or beforelast, could carry the assertion that only one instance of the search pattern exists. 2 | sed "s+$@.*$++" 3 | # awk ' BEGIN { FS="'$1'" } { printf($1"\n") } ' 4 | -------------------------------------------------------------------------------- /code/shellscript/other/checkin: -------------------------------------------------------------------------------- 1 | if [ -x -f RCS ]; then 2 | mkdir RCS 3 | fi 4 | 5 | if [ ! -f RCS/$1,v ]; then 6 | rcs -i -t-checkinstart $1 7 | rcs -ajoey,root $1 8 | fi 9 | 10 | ci -mcheckinchange $1 11 | co $1 12 | -------------------------------------------------------------------------------- /code/shellscript/stream/grepand.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | next_pattern="$1" 4 | shift 5 | 6 | if [ "$#" -gt 0 ] 7 | then exec grep -e "$next_pattern" | grepand "$@" 8 | else exec grep -e "$next_pattern" 9 | fi 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tools/* 2 | /trash 3 | /code/c 4 | /code/code 5 | /code/dosbats 6 | /code/haskell 7 | /code/irc 8 | /code/java 9 | /code/other 10 | /code/prolog 11 | /code/servlets 12 | /code/tex 13 | /local.conf 14 | /config 15 | -------------------------------------------------------------------------------- /code/shellscript/diff/sortinplace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for FILE 3 | do 4 | 5 | TMPFILE=`jgettmp "$FILE"` 6 | 7 | cat "$FILE" | sort > "$TMPFILE" && 8 | mv -f "$TMPFILE" "$FILE" 9 | 10 | jdeltmp "$TMPFILE" 11 | 12 | done 13 | -------------------------------------------------------------------------------- /code/shellscript/oscompat/mac2unix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | if [ "$*" ] 4 | then 5 | for FILE 6 | do cat "$FILE" | dos2unix | pipebackto "$FILE" 7 | done 8 | else 9 | tr '\r' '\n' 10 | fi 11 | -------------------------------------------------------------------------------- /code/shellscript/other/netbeans: -------------------------------------------------------------------------------- 1 | # $JPATH/install/netbeans/bin/runide.sh -jdkhome /usr/local/jdk1.2.2 "$@" & 2 | 3 | ## --fontsize 10 4 | ## (default appears to be 11) 5 | /mnt/space/stuff/install/java/netbeans/bin/netbeans "$@" & 6 | -------------------------------------------------------------------------------- /code/shellscript/other/trimempty: -------------------------------------------------------------------------------- 1 | ## Removes any empty (blank) lines from the stream (or indeed lines containing only spaces/tabs, although it's less often used this way). 2 | # jsh-ext-depends: sed 3 | sed "s/^[ ]*$//" | grep -v "^$" 4 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ap=\' 3 | data='echo "#!/bin/sh"\necho "ap=\\\\$ap"\necho "data=$ap$data$ap"\necho -e "$data"' 4 | echo "#!/bin/sh" 5 | echo "ap=\\$ap" 6 | echo "data=$ap$data$ap" 7 | echo -e "$data" 8 | -------------------------------------------------------------------------------- /code/shellscript/stream/removeduplicatelinesadj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | lastline="thisString_willNEVERex1st" 4 | 5 | while read line 6 | do 7 | [ "$line" = "$lastline" ] || echo "$line" 8 | lastline="$line" 9 | done 10 | 11 | -------------------------------------------------------------------------------- /code/shellscript/stub/md5sum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends-ignore: cksum 3 | # jsh-depends: jwhich cksum 4 | MD5SUM=`jwhich md5sum` 5 | if test -x "$MD5SUM" 6 | then 7 | "$MD5SUM" "$@" 8 | else 9 | cksum "$@" 10 | fi 11 | -------------------------------------------------------------------------------- /code/shellscript/systemd/systemd_show_journal_since_boot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # If you want to list a previous boot, provide a different `-b` from this list: journalctl --list-boots 4 | 5 | echo "Try: journalctl -x -b 0" 6 | -------------------------------------------------------------------------------- /code/shellscript/term/truncate_columns.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -n "$1" ] 4 | then COLUMNS="$1"; shift 5 | fi 6 | 7 | if [ -z "$COLUMNS" ] 8 | then COLUMNS="$(tput cols)" 9 | fi 10 | 11 | cut -c1-"$COLUMNS" 12 | -------------------------------------------------------------------------------- /code/shellscript/audio/slow_down_audio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . require_exes ffmpeg 3 | 4 | set -e 5 | 6 | infile="$1" 7 | outfile="$1.mp3" 8 | 9 | # -vn - drop audio 10 | ffmpeg -i "$infile" -filter:a "atempo=0.75" "$outfile" 11 | -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-monitor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Monitoring ppp connection:" 3 | # grep ensures secure information does not pass 4 | /bin/su -c "tail -f /var/log/messages | grep -E \"pppd|PPP|chat\"" 5 | # "tail -f /var/log/messages" -------------------------------------------------------------------------------- /code/shellscript/other/browseimages: -------------------------------------------------------------------------------- 1 | browsepics $@ 2 | 3 | #echo "" > images.html 4 | #forall -stealth $@ do echo "\\" >> images.html 5 | #echo "" >> images.html 6 | #browse images.html & 7 | -------------------------------------------------------------------------------- /code/shellscript/other/purgecore: -------------------------------------------------------------------------------- 1 | 'rm' -i `locate --existing core | grep "/core$" | grep -v "/dev/core$"` 2 | 3 | # locate core | grep "/core$" > ~/purge.tmp 4 | # forall -shell in ~/purge.tmp do "/bin/rm" %w 5 | # "/bin/rm" ~/purge.tmp 6 | -------------------------------------------------------------------------------- /code/shellscript/pkg_rpm/find_package_with_file.rpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #rpm -qa | 4 | #while read X 5 | #do 6 | # rpm -ql "$X" | 7 | # grep "$@" && 8 | # printf "%s\n\n" " was found in $X" 9 | #done 10 | 11 | rpm -qf "$@" 12 | -------------------------------------------------------------------------------- /code/shellscript/wrap/jmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | g++ -w -g -I "$JPATH/code/c/joeylib/.comp/" "$1.c" -o "$1" "$JPATH/code/c/joeylib/.comp/joeylib.o" 3 | # -O3 4 | # g++ -I $JPATH/joeylib/.comp/ $1.c -w -o $1 $JPATH/joeylib/.comp/joeylib.o 5 | 6 | -------------------------------------------------------------------------------- /code/shellscript/xwin/swap_caps_ctrl.sh: -------------------------------------------------------------------------------- 1 | xmodmap - << ! 2 | remove Lock = Caps_Lock 3 | remove Control = Control_L 4 | keysym Control_L = Caps_Lock 5 | keysym Caps_Lock = Control_L 6 | add Lock = Caps_Lock 7 | add Control = Control_L 8 | ! 9 | -------------------------------------------------------------------------------- /code/shellscript/stream/takeline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## See also: getline (better+faster with sed) 3 | 4 | LINENUM=`expr "$1" - 1` 5 | shift 6 | 7 | cat "$@" | 8 | 9 | drop $LINENUM | 10 | 11 | head -n 1 12 | 13 | # cat > /dev/null 14 | -------------------------------------------------------------------------------- /code/shellscript/string/betweenthe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Strangely, betweenthe implies there are >2 "$@"s 4 | # and the output should be multiple answers, on consecutive lines 5 | 6 | #sed "s/\n/\\\n/g" | tr "$@" "\n" 7 | sed "s+$*+\n+g" 8 | -------------------------------------------------------------------------------- /code/shellscript/versioning/cvslog.sh: -------------------------------------------------------------------------------- 1 | cvs log "$@" 2>&1 | 2 | grep -v "^cvs log: Logging " | 3 | 4 | highlight "^[-]*$" magenta | 5 | highlight "^[=]*$" magenta | 6 | highlight "^\(date:\|revision \).*" yellow | 7 | 8 | more 9 | 10 | -------------------------------------------------------------------------------- /code/shellscript/music/soundshorrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in "$@"; do 3 | DIR=`dirname "$X"` 4 | FILE=`filename "$X"` 5 | cd "$DIR" 6 | mkdir -p horrid 7 | echo "\"$DIR/$FILE\" -> $DIR/horrid/" 8 | mv "$FILE" horrid 9 | done 10 | -------------------------------------------------------------------------------- /code/shellscript/other/jooify: -------------------------------------------------------------------------------- 1 | rm open/* 2 | mkdir open 3 | java -cp $JPATH/code/java/joo/ Main $1 $2 $3 $4 $5 $6 $7 $8 $9 4 | cp $JPATH/code/java/joo/Field.* open/ 5 | cp $JPATH/code/java/joo/Joo.* open/ 6 | cp $JPATH/code/java/joo/JooFrame* open/ 7 | -------------------------------------------------------------------------------- /code/shellscript/perl/perltrace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "t to trace, c to run, b to set breakpoint, h h for help" 3 | echo "Also see: http://perl.plover.com/Trace/" 4 | echo " perl -d:Trace .." 5 | perl -dS "$@" 6 | -------------------------------------------------------------------------------- /code/shellscript/compile/xgcov: -------------------------------------------------------------------------------- 1 | echo "" 2 | echo "The compiler is your friend (gcov-ing) ------------------------------" 3 | echo "" 4 | g++ $1.c -w -o $1 -fconserve-space -I $JPATH/joeylib -g -fprofile-arcs -ftest-coverage $2 $3 $4 $5 $6 5 | chmod g+x $1 6 | -------------------------------------------------------------------------------- /code/shellscript/diff/sortedvimdiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | A="$1" 3 | B="$2" 4 | TMPA=`jgettmp "$A"` 5 | TMPB=`jgettmp "$B"` 6 | cat "$A" | sort > "$TMPA" 7 | cat "$B" | sort > "$TMPB" 8 | vimdiff "$TMPA" "$TMPB" 9 | wait 10 | jdeltmp "$TMPA" "$TMPB" 11 | -------------------------------------------------------------------------------- /code/shellscript/edit/vanillavim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Alternative: vim -u NONE --noplugin "$@" 4 | 5 | vanillaVimHome="$HOME/.vanilla_vim_home" 6 | 7 | mkdir -p "$vanillaVimHome" 8 | 9 | export HOME="$vanillaVimHome" 10 | 11 | vim "$@" 12 | -------------------------------------------------------------------------------- /code/shellscript/shortcut/indirdo.sh: -------------------------------------------------------------------------------- 1 | ## indirdo .. 2 | ## goes to dir and runs cmd, but does not change cwd after it exits. 3 | ## Also makes the operation atomic, so no need for a ; 4 | ( 5 | cd "$1" || exit 7 6 | shift 7 | "$@" 8 | ) 9 | -------------------------------------------------------------------------------- /code/shellscript/txtstream/tocol.sh: -------------------------------------------------------------------------------- 1 | ## tocol 9 will stream the first 8 columns, stripping all after 2 | COLUMN="$1" ; shift 3 | COLUMN=$((COLUMN-1)) 4 | sed 's+ *+ +g' | ## CONSIDER: Is this any different from tr -s ' '? 5 | cut -d " " -f "-$COLUMN" 6 | -------------------------------------------------------------------------------- /code/shellscript/fileutil/copyusingtar.sh: -------------------------------------------------------------------------------- 1 | SRC="$1" 2 | DEST="$2" 3 | 4 | if [ ! "$SRC" ] || [ ! "$DEST" ] 5 | then 6 | echo "copyusingtar " 7 | exit 1 8 | fi 9 | 10 | ( cd "$SRC" ; tar c . ) | 11 | ( cd "$DEST" ; tar x ) 12 | -------------------------------------------------------------------------------- /code/shellscript/shext/intseq.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## jsh-help: Unlike seq's default mode, this will print huge integers in full. 3 | ## jsh-help: e.g.: diffcoms "seq 9999996 9999999" "intseq 9999996 9999999" 4 | 5 | seq --format="%f" "$@" | 6 | sed 's+\..*++' 7 | -------------------------------------------------------------------------------- /code/shellscript/versioning/svncommit.sh: -------------------------------------------------------------------------------- 1 | if [ "$*" ] 2 | then svn commit "$@" 3 | else 4 | svn status 5 | jshinfo "Will perform \"svn commit -m ''\" in 5 seconds - press Ctrl+C to abort." 6 | sleep 5 7 | verbosely svn commit -m "" 8 | fi 9 | 10 | -------------------------------------------------------------------------------- /code/shellscript/git/git-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # I like to initialise the repo with an empty commit, so that I can fixup the 3 | # first real commit later, or rewind and cherry-pick from scratch. 4 | git init && 5 | git commit --allow-empty -m "-- empty commit --" 6 | -------------------------------------------------------------------------------- /code/shellscript/wrap/netscape: -------------------------------------------------------------------------------- 1 | if jwhich netscape quietly 2 | then `jwhich netscape` -install -no-about-splash -geometry =550x550+10+10 "$@" & 3 | # Cannot do this, because browse tries to call netscape => infloop! 4 | #else browse "$@" & 5 | else exit 1 6 | fi 7 | -------------------------------------------------------------------------------- /code/shellscript/other/portofloppy: -------------------------------------------------------------------------------- 1 | echo Creating ports in $JPATH/out 2 | jport 3 | 4 | echo Copying ports to floppy 5 | mount /mnt/floppy/ 6 | cd $JPATH/out 7 | # cp hwiport.tgz ctwport.tgz org.tgz tools.tgz /mnt/floppy/ 8 | cp * /mnt/floppy/ 9 | 10 | alluptodate -------------------------------------------------------------------------------- /code/shellscript/pattern/globtoregexp.sh: -------------------------------------------------------------------------------- 1 | # Newline to newline-match-char? 2 | sed ' 3 | 4 | # \ -> \\ (new) 5 | s+\\+\\\\+g 6 | 7 | # . -> \. 8 | s+\.+\\.+g 9 | 10 | # * -> .* 11 | s+\*+.*+g 12 | 13 | # ? -> . 14 | s+\?+.+g 15 | 16 | ' 17 | -------------------------------------------------------------------------------- /code/shellscript/web/mirrorhwi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "x$1" = "x"; then 3 | DESTDIR="/home/pgrad/pclark/public_html/hwimirror" 4 | else 5 | DESTDIR="$1" 6 | fi 7 | mkdir -p $DESTDIR 8 | cd $DESTDIR 9 | wget -A html -l 2 -r -N http://hwi.dyn.dhs.org/ 10 | -------------------------------------------------------------------------------- /code/shellscript/curses/cursereverse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # None of these work on macOS 3 | #setterm -reverse 4 | #tput -rev 5 | #tput smso 6 | # smso is "stand-out mode" which actually performs reverse (swaps fg/bg colors) 7 | # This one works on Linux and macOS 8 | echo ^[[7m 9 | -------------------------------------------------------------------------------- /code/shellscript/dir/expandthreedots.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Converts: .../hello/../goodbye/..../end (win9x+) 3 | ## into: ./../..//hello/..//goodbye/../../..//end (unix) 4 | echo "$*" | 5 | sed ' 6 | s+\(\/\)\.+\1+g 7 | s+\.+\.\./+g 8 | s+^\.\.\/+\.\/+ 9 | ' 10 | -------------------------------------------------------------------------------- /code/shellscript/posessive/overpossesive/ownboxwithip: -------------------------------------------------------------------------------- 1 | # Not implemented yet, but it would be fun to write. 2 | # Repeated use incorporating previously-owned boxes into the search 3 | # means performance will improve with use! 4 | 5 | echo "I'll get back to you on that one..." -------------------------------------------------------------------------------- /code/shellscript/sh/findjshrevdeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | EXPR="\(" 3 | for X 4 | do EXPR="$EXPR\<$X\>\|" 5 | done 6 | EXPR=`echo "$EXPR" | sed 's+\\\|$++'` 7 | EXPR="$EXPR\)" 8 | # echo "$EXPR" 9 | cd $JPATH/code/shellscript 10 | higrep "$EXPR" * -r | 11 | notindir CVS 12 | -------------------------------------------------------------------------------- /code/shellscript/cdrw/cdcksum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## ls preferable to find because former gives physical order, latter alphabetical 3 | 'ls' -R | ls-Rtofilelist | 4 | # find . -type f | 5 | sedreplace "^\./" "" | 6 | while read FILE 7 | do 8 | qkcksum "$FILE" 9 | done 10 | -------------------------------------------------------------------------------- /code/shellscript/lint/add_shebang_to_scripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f -name "*.sh" | grep -v /CVS/ | 3 | while read f 4 | do 5 | if ! head -n 1 "$f" | grep '^#!/' 6 | then 7 | ( 8 | echo '#!/bin/sh' 9 | cat "$f" 10 | ) | dog "$f" 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /code/shellscript/other/listusers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #! /bin/sh 3 | count=0 4 | exec 3<&0 $IREG<" 6 | # `jwhich locate` -r $IREG 7 | unj locate -r "$IREG[^/]*$" 8 | -------------------------------------------------------------------------------- /code/shellscript/arch/diffzips.sh: -------------------------------------------------------------------------------- 1 | ## No need to unpack them, we can check the file hashes in the index. 2 | diffcoms -vimdiff "unzip -v \"$1\" | grep -v '\.svn'" "unzip -v \"$2\" | grep -v '\.svn'" 3 | # diffcoms -color "unzip -v \"$1\" | grep -v '\.svn'" "unzip -v \"$2\" | grep -v '\.svn'" 4 | -------------------------------------------------------------------------------- /code/shellscript/pkg/list_installed_packages_chronologically.pacman.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This lists all attempted installs, and some other things, with no consideration for whether the install succeeded or the package even existed! 4 | grep "Running 'pacman -S" /var/log/pacman.log 5 | -------------------------------------------------------------------------------- /code/shellscript/stream/countcharsinline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Give or take a few characters ... ! 3 | ## Counts the number of characters on each line 4 | ## If you provide a character, counts the number of occurrences of that character 5 | 6 | awk ' BEGIN { FS="'"$1"'" } { print NF " " $0 } ' 7 | -------------------------------------------------------------------------------- /code/shellscript/xwin/clipboard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$1" = -2 ] 3 | then 4 | 5 | cat > /dev/null 6 | 7 | # while true 8 | # do echo; sleep 5 9 | # done & 10 | 11 | # while read LINE 12 | # do ( sleep 1; echo ) & 13 | # done 14 | 15 | else bigwin "clipboard -2" 16 | fi 17 | -------------------------------------------------------------------------------- /code/shellscript/wmctrl/wmctrl_restore_all.sh: -------------------------------------------------------------------------------- 1 | ## Raises all minimized windows 2 | wmctrl -l -p -G -x | 3 | while read ID DESKTOP PID X Y WIN_WIDTH WIN_HEIGHT WM_CLASS TITLE 4 | do wmctrl -i -a "$ID" 5 | # wmctrl -i -r "$ID" -b remove,hidden 6 | # wmctrl -i -r "$ID" -b remove,shade 7 | done 8 | -------------------------------------------------------------------------------- /code/shellscript/wrap/japropos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Adds colour highlight to apropos; also runs aproposjsh 3 | ## Script intended to be aliased to apropos in user's shell. 4 | ( 5 | # `jwhich apropos` "$@" 6 | aproposjsh "$@" | highlight "\" 7 | ) | highlight "`caseinsensitiveregex "$@"`" 8 | -------------------------------------------------------------------------------- /code/shellscript/evolution/oaf-slay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if jwhich oaf-slay 3 | then jshwarn "TODO: Should really call unj oaf-slay" 4 | fi 5 | 6 | ## TODO: check with mykillps ; I think lines were truncated; do we need env COLUMNS=huge ? 7 | mykill evolution wombat bonobo 8 | 9 | findjob evol 10 | -------------------------------------------------------------------------------- /code/shellscript/other/portcollect: -------------------------------------------------------------------------------- 1 | echo portcollect: $1 2 | mkdir -p ~/portmp/$1 3 | cp *.c *.h *.java *.class *.hs *.pl ~/portmp/$1 4 | # The rmdir cleans up the directory if it's empty 5 | forall -stealth -dirsonly * do cd %f %a%a portcollect $1%f/ %a%a cd .. %a%a rmdir --ignore-fail-on-non-empty %f 6 | -------------------------------------------------------------------------------- /code/shellscript/proc/getppid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$1" = ""; then 3 | echo 'getppid $$' 4 | echo ' gets parent id of current shell' 5 | echo 'getppid ' 6 | echo ' gets parent id of process ' 7 | exit 1 8 | fi 9 | 10 | myps -A | takecols 2 3 | grep " $1$" | takecols 1 11 | 12 | -------------------------------------------------------------------------------- /code/shellscript/git/git-ignore-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # From: https://stackoverflow.com/questions/1753070/how-do-i-configure-git-to-ignore-some-files-locally 5 | 6 | git_root_folder="$(git rev-parse --show-toplevel)" 7 | 8 | echolines "$@" >> "$git_root_folder"/.git/info/exclude 9 | -------------------------------------------------------------------------------- /code/shellscript/other/dobak: -------------------------------------------------------------------------------- 1 | domount 2 | cd /mnt/filfirin 3 | mkdir hwibak 4 | cd hwibak 5 | mkdir root 6 | cp /root/.* root 7 | cp /root/* root 8 | mkdir joey 9 | cp /home/joey/.* joey 10 | cp /home/joey/* joey 11 | mkdir etc 12 | cp /etc/fstab etc 13 | cp /etc/hosts etc 14 | cp /etc/lilo.conf etc 15 | -------------------------------------------------------------------------------- /code/shellscript/other/mynewer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends: find 3 | # FOUND=`find "$1" -newer "$2" -maxdepth 0` 4 | # [ "$FOUND" ] 5 | ## Changed to make behaviour same as the newer binary: 6 | ## returns true if files are the same age 7 | FOUND=`find "$2" -maxdepth 0 -newer "$1"` 8 | [ ! "$FOUND" ] 9 | -------------------------------------------------------------------------------- /code/shellscript/other/showln: -------------------------------------------------------------------------------- 1 | # Displays all symbolic links in current directory 2 | 3 | forall * -shell -stealth -followdirs do echo %f > $JPATH/tmp/showln1.txt 4 | forall * -shell -stealth -nofollowfiles do echo %f > $JPATH/tmp/showln2.txt 5 | jfc simple oneway $JPATH/tmp/showln1.txt $JPATH/tmp/showln2.txt -------------------------------------------------------------------------------- /code/shellscript/stream/headbytes.sh: -------------------------------------------------------------------------------- 1 | NUMBYTES="$1" 2 | 3 | dd bs=1 count="$NUMBYTES" 2>/dev/null 4 | ## TODO: should check specified number were successfully copies; exit with error if not. (Or maybe not?! What does head (lines) do?) 5 | 6 | ## TODO: bs=1 is inefficient for any long stream (see optimdd) 7 | -------------------------------------------------------------------------------- /code/shellscript/string/tostring.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | EXCLUDE= 3 | if [ "$1" = -x ] 4 | then EXCLUDE=true; shift 5 | fi 6 | STRING="$*" 7 | 8 | while read LINE && 9 | [ ! "$LINE" = "$STRING" ] 10 | do echo "$LINE" 11 | done 12 | 13 | [ ! $EXCLUDE ] && echo "$LINE" 14 | 15 | cat > /dev/null 16 | -------------------------------------------------------------------------------- /code/shellscript/diff/sorteddiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILEA="$1" 3 | FILEB="$2" 4 | 5 | TMPA=`jgettmp "$FILEA"` 6 | TMPB=`jgettmp "$FILEB"` 7 | shift 8 | shift 9 | 10 | cat "$FILEA" | sort > "$TMPA" 11 | cat "$FILEB" | sort > "$TMPB" 12 | 13 | diff "$TMPA" "$TMPB" "$@" 14 | 15 | jdeltmp "$TMPA" "$TMPB" 16 | -------------------------------------------------------------------------------- /code/shellscript/javadev/tar_java_project.sh: -------------------------------------------------------------------------------- 1 | PROJECT_NAME=`basename "$PWD"` 2 | cd .. 3 | verbosely tar cfz /tmp/"$PROJECT_NAME"-`geekdate -fine`.tgz --exclude=.svn --exclude=classes "$PROJECT_NAME"/ 4 | find "$PROJECT_NAME"/ -name .svn | withalldo verbosely tar cfz /tmp/"$PROJECT_NAME"-svn-`geekdate -fine`.tgz 5 | -------------------------------------------------------------------------------- /code/shellscript/ui/error.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: cursebold cursered curseyellow cursenorm 3 | # echo "`cursered;cursebold`$@`cursenorm`" >&2 4 | # beep # preferably don't beep on subsequent errors for 10s / 10m / ... 5 | [ "$NOERROR" ] || echo "`cursered;cursebold`ERROR: `curseyellow`$@`cursenorm`" >&2 6 | -------------------------------------------------------------------------------- /code/shellscript/mongo/mongo_show_collection_counts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # E.g.: mongo_show_collection_counts localhost/MyDB 4 | 5 | mongo "$@" << !!! | 6 | db.getCollectionNames().forEach(collectionName => print(collectionName + ": " + db.getCollection(collectionName).count())); 7 | !!! 8 | sort -n -k 2 9 | -------------------------------------------------------------------------------- /code/shellscript/other/kde.xinit: -------------------------------------------------------------------------------- 1 | #xrdb -load $HOME/.Xresources 2 | #xsetroot -solid gray & 3 | #xclock -g 50x50-0+0 -bw 0 & 4 | #xload -g 50x50-50+0 -bw 0 & 5 | #xterm -g 80x24+0+0 & 6 | #xterm -g 80x24+0-0 & 7 | #twm 8 | 9 | #konsole & 10 | 11 | kfm & 12 | xscreensaver & 13 | 14 | #afterstep 15 | kde 16 | -------------------------------------------------------------------------------- /code/shellscript/other/portcode: -------------------------------------------------------------------------------- 1 | rm -r ~/portmp 2 | cd $JPATH/code/c 3 | portcollect c/ 4 | cd $JPATH/code/java 5 | portcollect java/ 6 | cd /home/httpd/servlets 7 | rm changetheworld 8 | portcollect servlets/ 9 | ln -s . changetheworld 10 | cd ~/portmp 11 | mkdir -p ~/out 12 | tar cfz ~/out/codeport.tgz * 13 | -------------------------------------------------------------------------------- /code/shellscript/shutil/list_commands_on_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "$PATH" | tr ':' '\n' | 4 | while read dir 5 | do 6 | [ -r "$dir" ] && find "$dir"/ -maxdepth 1 -type f -or -type l | 7 | while read executable 8 | do [ -x "$executable" ] && echo "$executable" 9 | done 10 | done | 11 | afterlast / 12 | -------------------------------------------------------------------------------- /code/shellscript/cvswrap/cvsreplaceserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$2" = "" ] 3 | then 4 | echo "cvsreplaceserver " 5 | echo " e.g.: cvsreplaceserver `cat CVS/Root` :ext:joey@hwi.ath.cx:/stuff/cvsroot" 6 | exit 1 7 | fi 8 | 9 | sedreplace "$1" "$2" `find . -name "Root"` 10 | -------------------------------------------------------------------------------- /code/shellscript/monitors/watchfolderforchanges.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also: watchforfileaccess 3 | [ "$DELAY" ] || DELAY=15 4 | TARGET_DIRS="$*" ## BUG: Fails on dirs with spaces. Could fix with: for X in "$@"; do ... 5 | jwatch -oneway "find $TARGET_DIRS -maxdepth 4 -type f | withalldo nicels -ld" 2>&1 | dateeachline 6 | -------------------------------------------------------------------------------- /code/shellscript/other/afterstep.xinit: -------------------------------------------------------------------------------- 1 | #xrdb -load $HOME/.Xresources 2 | #xsetroot -solid gray & 3 | #xclock -g 50x50-0+0 -bw 0 & 4 | #xload -g 50x50-50+0 -bw 0 & 5 | #xterm -g 80x24+0+0 & 6 | #xterm -g 80x24+0-0 & 7 | #twm 8 | 9 | #konsole & 10 | 11 | kfm & 12 | xscreensaver & 13 | 14 | afterstep 15 | #kde 16 | -------------------------------------------------------------------------------- /code/shellscript/other/setuid: -------------------------------------------------------------------------------- 1 | ARGS="$@" 2 | if [ "$ARGS" = "" ]; then 3 | echo "setuid " 4 | echo " Provides 's group permission to execute as root." 5 | echo " Only use this on secure and predictable programs!" 6 | exit 1 7 | fi 8 | chown root $@ 9 | chmod a-wrxs $@ 10 | chmod ug+sx $@ -------------------------------------------------------------------------------- /code/shellscript/shtxt/stripcomments.sh: -------------------------------------------------------------------------------- 1 | LANG="$1" 2 | shift 3 | 4 | case "$LANG" in 5 | 6 | -sh) 7 | sed 's+#.*++' "$@" 8 | ;; 9 | 10 | -c|-java) 11 | sed 's+//.*++' "$@" 12 | ;; 13 | 14 | *) 15 | error "Do not know how to strip comments from language: $LANG" 16 | exit 1 17 | ;; 18 | 19 | esac 20 | -------------------------------------------------------------------------------- /code/shellscript/string/chop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Skips N lines from the end of a stream 3 | ## See also: tail -n +5 4 | 5 | # jsh-depends: countlines jgettmp 6 | 7 | TF=`jgettmp $$` 8 | NUMLINES=`tee "$TF" | countlines` 9 | KEEPLINES=`expr $NUMLINES - $1` 10 | cat "$TF" | head -n "$KEEPLINES" 11 | jdeltmp "$TF" 12 | -------------------------------------------------------------------------------- /code/shellscript/string/tolowercase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## TODO: shouldn't these progs by default, if provided with an arg, echo it and conver the case? 3 | ## of course this would mean tolowercase can never truly stand in for a proper piping prog like cat 4 | tr "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" 5 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/jwhere.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Also of interest: type -a, where, which 3 | # All of which will report aliases and functions if present (at least in zsh) 4 | if jwhich whereis quietly; then 5 | WHERE=`jwhich whereis` 6 | else 7 | WHERE="where" # shell builtin 8 | fi 9 | $WHERE $@ 10 | 11 | -------------------------------------------------------------------------------- /code/shellscript/xwin/getxwindimensions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # xdpyinfo | grep dimensions: | takecols 2 3 | # xdpyinfo | grep dimensions: | grep -o "[0-9]*x[0-9]*" | head -n 1 4 | # xdpyinfo | grep dimensions: | sed 's+.*dimensions:[ ]*++ ; s+ .*++' 5 | xdpyinfo | grep dimensions: | sed 's+.*dimensions:[ ]*\([^ ]*\) .*+\1+' 6 | -------------------------------------------------------------------------------- /code/shellscript/modem/ppp-monitor.c: -------------------------------------------------------------------------------- 1 | // Please let Joey know if this is a security risk! 2 | // Shell scripts are illegal under Linux. 3 | // This requires trusting tail and grep I suppose. 4 | 5 | #include 6 | void main() { 7 | system("/usr/bin/tail -f /var/log/messages | /bin/grep -E \"pppd|PPP|chat\""); 8 | } 9 | -------------------------------------------------------------------------------- /code/shellscript/string/touppercase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## TODO: shouldn't these progs by default, if provided with an arg, echo it and conver the case? 3 | ## of course this would mean tolowercase can never truly stand in for a proper piping prog like cat 4 | tr "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 5 | 6 | -------------------------------------------------------------------------------- /code/shellscript/webdev/beautify_json.sh: -------------------------------------------------------------------------------- 1 | cat "$@" | 2 | python -m json.tool | 3 | sed 's+ $++' 4 | 5 | # See also: prettycat (jsh) 6 | 7 | # See also: js-beautify (npm) which also provides css-beautify and html-beautify 8 | 9 | # One disadvantage: it sorts the keys, rather than keeping them in the original order 10 | -------------------------------------------------------------------------------- /code/shellscript/xwin/make_caps_lock_control_escape.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pkill -u "$UID" xcape 4 | setxkbmap -option 'caps:ctrl_modifier' 5 | xcape -t 150 -e 'Caps_Lock=Escape' 6 | #xcape -e 'Caps_Lock=Escape;Control_L=Escape;Control_R=Escape' 7 | 8 | # To undo: 9 | # killall xcape 10 | # setxkbmap -option 11 | -------------------------------------------------------------------------------- /code/shellscript/mail/separatembox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "not written" 3 | exit 0 4 | 5 | MBOX=`jgettmp mbox.working` 6 | 7 | cp "$1" "$MBOX" 8 | 9 | while test ! `fileize "$MBOX"` = 0 10 | do 11 | grep "Content-Length" ## Dammit not always there (for evolution mboxes anyway - maybe some processing cld put length in)! 12 | -------------------------------------------------------------------------------- /code/shellscript/net/ip2country.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # There is geoiplookup in the geoip-bin package, but its static database is out of date. (I tried it on two DigitalOcean servers, and it was wrong in both cases.) 4 | 5 | ip="$1" 6 | 7 | # This returns a whole JSON record, more than we actually need. 8 | curl ipinfo.io/"$ip" 9 | -------------------------------------------------------------------------------- /code/shellscript/security/nmap_scan_network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "$1" ] 4 | then network="$1" 5 | else network="192.168.1.0" # TODO: Guess from ifconfig / ip 6 | fi 7 | 8 | # Search for hosts we can ping 9 | nmap -sn "${network}/24" 10 | 11 | # Search for hosts with port 22 open 12 | #nmap -p 22 "${network}/24" 13 | -------------------------------------------------------------------------------- /code/shellscript/unixext/splicewith.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TMPA=`jgettmp splicewith` 3 | TMPB=`jgettmp splicewith` 4 | 5 | ORDER="$TMPA $TMPB" 6 | if test "$1" = "-after"; then 7 | shift 8 | ORDER="$TMPB $TMPA" 9 | fi 10 | 11 | cat > $TMPA 12 | 13 | "$@" > $TMPB 14 | 15 | paste -d "" $ORDER 16 | 17 | jdeltmp $TMPA $TMPB 18 | -------------------------------------------------------------------------------- /code/shellscript/fs/truncate_file_at.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Can also be used to expand a file with zero-bytes (possibly creating a sparse file) 3 | 4 | FILE="$1" 5 | POSITION="$2" 6 | 7 | ## TODO: If position ends in [GgMmKkBb] multiply it by 1024^n respectively. 8 | 9 | dd if=/dev/zero of="$FILE" bs=1 count=0 seek="$POSITION" 10 | -------------------------------------------------------------------------------- /code/shellscript/other/hugstest: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/runhugs 2 | 3 | module Main where 4 | import System 5 | 6 | myshow [] = "" 7 | myshow (h:t) = h++myshow t 8 | 9 | main = do 10 | args <- getArgs 11 | putStr ("Hello world =)\n"++(show (args))++"\n") 12 | -- myshow args) 13 | 14 | fart = show getArgs 15 | 16 | -------------------------------------------------------------------------------- /code/shellscript/proc/whenprocesscompletes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | process_name="$1" 4 | shift 5 | 6 | if ! pgrep "$process_name" 7 | then 8 | echo "Could not find specified process '$process_name' to begin with!" 9 | exit 3 10 | fi 11 | 12 | while pgrep "$process_name" >/dev/null 13 | do sleep 4 14 | done 15 | 16 | "$@" 17 | -------------------------------------------------------------------------------- /code/shellscript/other/comparedirs: -------------------------------------------------------------------------------- 1 | ( 2 | cd "$1" 3 | # find . -type f > $JPATH/tmp/1.lst 4 | find . > $JPATH/tmp/1.lst 5 | ) 6 | 7 | ( 8 | cd "$2" 9 | # find . -type f > $JPATH/tmp/2.lst 10 | find . > $JPATH/tmp/2.lst 11 | ) 12 | 13 | jfc $JPATH/tmp/1.lst $JPATH/tmp/2.lst 14 | 15 | # jfc common $JPATH/tmp/1.lst $JPATH/tmp/2.lst 16 | -------------------------------------------------------------------------------- /code/shellscript/other/monitornet: -------------------------------------------------------------------------------- 1 | # Shows process names :D 2 | # -l for listening sockets only (usually not listed) 3 | # although I was getting the same output with or without -l :O 4 | # probably because -a shows listening and non-listening :P 5 | # Remove -n for names instead of IP addresses (much slower) 6 | jwatch -oneway netstat -anlp 7 | -------------------------------------------------------------------------------- /code/shellscript/security/nmap_detailed_scan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use -Pn to skip ping "discovery" 4 | # 5 | # Use -sS to scan TCP (with SYN) 6 | # Use -sU to scan UDP 7 | # 8 | # To see what is actually running on each port: 9 | # Use -sV for version detection, and -sC for heavier script interrogation 10 | 11 | nmap -sV -sC "$@" 12 | -------------------------------------------------------------------------------- /code/shellscript/ls/ld.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Um, since aliasing l='ls -l', I have been tending to type 'ld' instead of 'l -d' when looking at directories. 3 | # This is rather dodgy if the first isn't a directory! 4 | 5 | if test "$1" = "" || test -d "$1"; then 6 | ls -lartd $JM_LS_OPTS "$@" 7 | else 8 | echo 2 9 | `jwhich ld` "$@" 10 | fi 11 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_dependencies.portage.sh: -------------------------------------------------------------------------------- 1 | ## Isn't this listing revdeps? We are looking for things which complain when we remove this. 2 | emerge -p --unmerge "$1" # sys-devel/flex-2.5.33-r3 3 | 4 | ## Similarly, shows packages depending on "$1": 5 | equery depends "$1" 6 | 7 | ## But to list packages which "$1" depends on...? 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/list_orphaned_packages.portage.sh: -------------------------------------------------------------------------------- 1 | sh ./list_installed_packages.sh | 2 | beforefirst "-[0-9]" | 3 | 4 | grep font | 5 | 6 | while read PKG 7 | do 8 | verbosely equery depends "$PKG" | 9 | grep -v "^\[ Searching for packages depending on " | 10 | grep . || echo "No Dependencies Found for: $PKG" 11 | done 12 | 13 | -------------------------------------------------------------------------------- /code/shellscript/string/fromstring.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | EXCLUDE= 3 | if [ "$1" = -x ] 4 | then EXCLUDE=true; shift 5 | fi 6 | STRING="$*" 7 | 8 | ## TODO: What about when [ "$LINE" = "-n" ] eh?! 9 | 10 | while read LINE && 11 | [ ! "$LINE" = "$STRING" ] 12 | do [ nothing ] 13 | done 14 | 15 | [ ! $EXCLUDE ] && echo "$LINE" 16 | 17 | cat 18 | -------------------------------------------------------------------------------- /code/shellscript/other/jwatchanddo: -------------------------------------------------------------------------------- 1 | DOCOMMAND=`jgettmp jwatchanddo` 2 | vi "$DOCOMMAND" && 3 | chmod a+x "$DOCOMMAND" || exit 1 4 | 5 | export JWATCHCOMPCOM="jwatchcomp -oneway" 6 | 7 | jwatch -quiet "$@" | 8 | 9 | while read X 10 | do 11 | 12 | echo "Line changed, running:" 13 | echo "$DOCOMMAND \"$X\"" 14 | $DOCOMMAND "$X" 15 | 16 | done 17 | -------------------------------------------------------------------------------- /code/shellscript/pkg_portage/get_package_size.portage.sh: -------------------------------------------------------------------------------- 1 | # echo '1024 * '"$(equery size "$1" | tail -n 1 | takecols 4)" | bc 2 | # echo '1024 * '"$(equery size "$1" | afterfirst "size(" | beforefirst ")")" | bc 3 | for PKG 4 | do 5 | [[ "$PKG" = "$*" ]] || echo -e -n "$PKG:\t" 6 | equery size "$PKG" | afterfirst "size(" | beforefirst ")" 7 | done 8 | 9 | -------------------------------------------------------------------------------- /code/shellscript/sh/echoargs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # omitting in word1 word2 ... from for command means "use 4 | # arg. vector for word list" 5 | 6 | N=0 7 | 8 | for word 9 | do 10 | # Works on Hwi. What about Unix? 11 | N=$(($N+1)); 12 | # echo " $N: >${word}<" 13 | printf ">{$word}< " 14 | done 15 | echo "(total $N)" 16 | -------------------------------------------------------------------------------- /code/shellscript/jsh/jshupdateallcvs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in *; do 3 | if test -d $X/CVS; then 4 | 5 | cd "$X" 6 | 7 | echo 8 | echo "Updating $X:" 9 | cvsupdate 10 | 11 | echo 12 | echo "Diffing $X:" 13 | cvsdiff 14 | 15 | # echo 16 | # echo "Committing $X:" 17 | # cvscommit 18 | 19 | cd .. 20 | 21 | fi 22 | done 23 | 24 | -------------------------------------------------------------------------------- /code/shellscript/monitor/whatisaccessing.sh: -------------------------------------------------------------------------------- 1 | f="$1" 2 | if [ -d "$f" ] || [ -f "$f" ] 3 | then listopenfiles . | grep "`realpath "$f"`" 4 | else 5 | echo "whatsisaccessing lists processes reading or blocking that FS node." 6 | exit 1 7 | fi 8 | 9 | # Alternative, probably faster: 10 | #fuser "$f" 11 | 12 | # See also: monitorfileaccess 13 | -------------------------------------------------------------------------------- /code/shellscript/ooo/openofficeunzip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILE="$1" 3 | DIR="$1.unzipped" 4 | 5 | mkdir -p "$DIR" 6 | unzip -d "$DIR" "$FILE" 7 | 8 | ## Note: sed only really desirable if OOffice XML compression is on (default) 9 | 10 | cd "$DIR" 11 | for X in *.xml; do 12 | cat "$X" | sed 's+><+>\ 13 | <+g' > tmp.xml 14 | mv tmp.xml "$X" 15 | done 16 | -------------------------------------------------------------------------------- /code/shellscript/sh/shredirect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Just an example of redirecting pipes to deal with while shell separation. 3 | ## Or: How to retain a variable outside of a while read loop. 4 | exec 3<&0 5 | exec &2 3 | [ "$NOINFO" ] || echo "`curseyellow;cursebold`[INFO] `cursenorm;cursebold`$*`cursenorm`" >&2 4 | ## I don't know why I don't like the green! 5 | # echo "`cursegreen;cursebold`[INFO] `cursegreen`$*`cursenorm`" >&2 6 | -------------------------------------------------------------------------------- /code/shellscript/other/countbytes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends: sed 3 | # dd of=/dev/null bs=1 2>&1 | head -n 2 | tail -n 1 | sed 's/+.*//' 4 | 5 | # TOEVAL=`dd of=/dev/null bs=1024 2>&1 | head -n 2 | tail -n 1 | sed "s/+/ '*' 1024 + / ; s/ records.*//"` 6 | # eval "expr $TOEVAL" 7 | 8 | # dd of=/dev/null bs=1024 2>&1 | tail -1 | sed 's+ .*++' 9 | wc -c 10 | -------------------------------------------------------------------------------- /code/shellscript/proc/withfewerprocessors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | num_cpus="$(cat /proc/cpuinfo | grep processor | tail -n 1 | cut -d' ' -f 2)" 4 | 5 | num_cpus=$((num_cpus + 1)) 6 | 7 | # Use only the second half of the processors 8 | first_cpu="$((num_cpus / 2))" 9 | last_cpu="$((num_cpus - 1))" 10 | 11 | taskset -c "${first_cpu}-${last_cpu}" "$@" 12 | -------------------------------------------------------------------------------- /code/shellscript/tex/deltexoutput.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OUTPUTEXTS="bbl aux log blg dvi" 3 | 4 | # find 5 | GREPFOR="\.(" 6 | FIRST=true 7 | for X in $OUTPUTEXTS; do 8 | if test $FIRST; then FIRST=; else 9 | GREPFOR="$GREPFOR|" 10 | fi 11 | GREPFOR="$GREPFOR$X" 12 | done 13 | GREPFOR="$GREPFOR)\$" 14 | 15 | find . -type f | grep -E "$GREPFOR" | sed "s/^/rm /" 16 | -------------------------------------------------------------------------------- /code/shellscript/text/html2txt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if false # command -v lynx >/dev/null 2>&1 4 | then 5 | url="$*" 6 | [ -z "$url" ] && url="-stdin" 7 | lynx -dump -nolist "$url" 8 | else 9 | # Strips tags but does not strip CSS and does not unescape text content 10 | cat "$@" | sed -e 's/<[^>]*>//g' | sed 's+^\s*$++' 11 | fi 12 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/startx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Occasionally (in emergencies) I startx from within a screen. 3 | ## In these cases, I want X progs to "escape" the screen. 4 | export STY= 5 | 6 | # `jwhich startx` "$@" > $JPATH/logs/X-out.txt 2> $JPATH/logs/X-err.txt 7 | # `jwhich startx` "$@" > $JPATH/logs/X-out.txt 2>&1 8 | unj startx "$@" 2>&1 | tee /tmp/X.$$.log 9 | -------------------------------------------------------------------------------- /code/shellscript/fs/makebigemptyfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FILENAME="$1" 3 | SIZEINMEGS="$2" 4 | [ "$FILENAME" ] && [ "$SIZEINMEGS" ] || exit 1 5 | 6 | dd if=/dev/zero of="$FILENAME" count="$SIZEINMEGS" ibs=1048576 obs=1048576 7 | 8 | if [ "$MAKESPARSE" ] 9 | then 10 | cp --sparse=always "$FILENAME" "$FILENAME".sparse 11 | du -sk "$FILENAME" "$FILENAME.sparse" 12 | fi 13 | -------------------------------------------------------------------------------- /code/shellscript/memo/prepare_for_fast_memoing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Makes memo-ing faster by importing its scripts as shell functions 3 | ## Also makes memoing possible on functions, e.g. "memo my_function ". 4 | . jgettmpdir -top 5 | . importshfn rememo 6 | . importshfn memo 7 | ## Other niceities: 8 | export IKNOWIDONTHAVEATTY=1 9 | export MEMO_IGNORE_DIR=1 10 | -------------------------------------------------------------------------------- /code/shellscript/other/dvi2pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "x$1" = "x"; then 3 | echo 'dvi2pdf ' 4 | echo 'dvi2pdf .ps .pdf' 5 | exit 1 6 | fi 7 | echo "DVI -> PS" 8 | if test "x$2" = "x"; then 9 | OUTFILE="$1.pdf" 10 | else 11 | OUTFILE="$2" 12 | fi 13 | dvips "$1" -f > tmp.ps 14 | echo "PS -> PDF" 15 | ps2pdf tmp.ps "$OUTFILE" 16 | /bin/rm tmp.ps -------------------------------------------------------------------------------- /code/shellscript/undelext2/undelext2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "x$1" = "x" -o "x$2" = "x"; then 3 | echo "undelext2 | debugfs " 4 | echo "will recover your files" 5 | exit 1 6 | fi 7 | mkdir -p "$2" 8 | N=0; 9 | cut -c1-6 $1 | grep "[0-9]" | tr -d " " | while read X; do echo "dump <$X> $2/undel-$N"; N=$(($N+1)); done 10 | -------------------------------------------------------------------------------- /code/shellscript/hugswrap/hugswrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Usage: hugswrap 3 | 4 | TMPFILE=`jgettmp baseconv` 5 | 6 | cat > $TMPFILE << ! 7 | 8 | module Main where 9 | import System 10 | import $1 11 | 12 | main = do 13 | args <- getArgs 14 | putStrLn ($2) 15 | 16 | ! 17 | 18 | runhugs $TMPFILE 19 | 20 | jdeltmp $TMPFILE 21 | -------------------------------------------------------------------------------- /code/shellscript/mail/vCard2abook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Note: whilst abook entries usually start with [n], 3 | ## the unnumbered generated entries are successfully 4 | ## read by abook=0.4.16-1 5 | cat "$1" | 6 | grep -E "(^FN:|^EMAIL;|nickname:|NICKNAME:)" | 7 | sed " 8 | s+^FN:+\\ 9 | name=+ 10 | s+EMAIL;INTERNET:+email=+ 11 | s+.*\(nickname\|NICKNAME\):[ ]*+nick=+ 12 | " 13 | -------------------------------------------------------------------------------- /code/shellscript/portals/hwiisat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd $JPATH/data 3 | cp jsync.conf.default jsync.conf 4 | sreplace jsync.conf \@maxx \@"$HOST" 5 | sreplace jsync.conf \@tao \@"$HOST" 6 | if test "x$1" = "x"; then 7 | exit 0 # REP="hwi.dyn.dhs.org" 8 | else 9 | REP="$1" 10 | fi 11 | sreplace jsync.conf hwi.dyn.dhs.org $REP 12 | echo "$REP" >> $JPATH/logs/hwiwasat.txt 13 | -------------------------------------------------------------------------------- /code/shellscript/shlib/assert.sh: -------------------------------------------------------------------------------- 1 | # assert (when written) can be used by a develoer to put checks in his scripts that ensure that the stream or arguments meet certain specified characteristics. 2 | # This can be used as a bug-trapping tool, informing someone (eg. by email) when the data is out-of-order. 3 | if "$@" 4 | then : 5 | else 6 | . errorexit "Assertion failed: $@" 7 | fi 8 | -------------------------------------------------------------------------------- /code/shellscript/curses/notes.txt: -------------------------------------------------------------------------------- 1 | 0=white 2 | 1=red 3 | 2=green 4 | 3=yellow 5 | 4=blue 6 | 5=magenta 7 | 6=cyan 8 | 7=white 9 | 10 | Visual brightness goes in the order: 0,4,1,5,2,6,3,7 11 | 12 | todo: LUV conversions 13 | 14 | Hence, it is common for red and blue to be complemented with "bold" (equates to "brighter" on xterm) in order to make them visible to the user. 15 | -------------------------------------------------------------------------------- /code/shellscript/monitor/onchange-simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Still depends on Unix diff! 3 | 4 | TMPFILE=/tmp/onchange.tmp 5 | 6 | "$@" > $TMPFILE 7 | 8 | while true; do 9 | 10 | mv $TMPFILE $TMPFILE.old 11 | sleep 1 12 | 13 | "$@" > $TMPFILE 14 | 15 | cmp $TMPFILE.old $TMPFILE > /dev/null || 16 | diff $TMPFILE.old $TMPFILE | 17 | grep "^\(<\|>\)" 18 | 19 | done 20 | -------------------------------------------------------------------------------- /code/shellscript/ooo/openofficezip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DIR="$1" 3 | FILE=`echo "$1" | sed 's/.unzipped//'` 4 | while test -f "$FILE"; do 5 | FILE=`echo "$FILE" | sed 's+\(.*\)\.\(.*\)+\1.new.\2+'` 6 | done 7 | FILE=`absolutepath "$FILE"` 8 | 9 | cd "$DIR" 10 | for X in *.xml; do 11 | cat "$X" | tr -d "\n\t" > tmp.xml 12 | mv tmp.xml "$X" 13 | done 14 | 15 | zip -r "$FILE" * 16 | -------------------------------------------------------------------------------- /code/shellscript/pkg_pacman/list_files_in_package.pacman.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Note: Before running, we need to download the file indexes, by running: 4 | # sudo pacman -Fy 5 | 6 | pkg_name="$1" 7 | 8 | # Basic 9 | #pacman -Fl "$pkg_name" 10 | 11 | # Fast (memoed) and cleaned up 12 | memo pacman -Fl "$pkg_name" | 13 | dropcols 1 | 14 | prepend_each_line '/' 15 | -------------------------------------------------------------------------------- /code/shellscript/apt/apt-security-updates.sh: -------------------------------------------------------------------------------- 1 | # From: https://help.ubuntu.com/community/AutomaticSecurityUpdates 2 | echo "**************" 3 | date 4 | aptitude update 5 | release=`lsb_release -cs` 6 | #release='precise' 7 | # --assume-yes 8 | aptitude safe-upgrade -o Aptitude::Delete-Unused=false --target-release "${release}-security" 9 | echo "Security updates (if any) installed" 10 | -------------------------------------------------------------------------------- /code/shellscript/git/git-merge-clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Alternative: git config --global mergetool.keepBackup false 4 | 5 | find . -name '*.orig' -or -name '*.rej' \ 6 | -or -name '*.BASE.*' -or -name '*.REMOTE.*' -or -name '*.LOCAL.*' -or -name '*.BACKUP.*' \ 7 | -or -name '*_BASE_*' -or -name '*_REMOTE_*' -or -name '*_LOCAL_*' -or -name '*_BACKUP_*' \ 8 | | foreachdo del 9 | -------------------------------------------------------------------------------- /code/shellscript/load_script_config: -------------------------------------------------------------------------------- 1 | # Source me, and I will guess your name, then load up your syswide config from 2 | # /etc and user-config from home dotfiles. 3 | 4 | scriptName="$0" 5 | 6 | if [ -f /etc/defaults/"$scriptName" ] 7 | then . /etc/defaults/"$scriptName" 8 | fi 9 | 10 | if [ -f "$HOME/.$scriptname/config" ] 11 | then . "$HOME/.$scriptname/config" 12 | fi 13 | 14 | -------------------------------------------------------------------------------- /code/shellscript/modem/makeaphonecall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wall << ! 3 | Killing pppd 4 | ! 5 | 6 | ppp-off 7 | killall pppd 8 | sleep 60 9 | 10 | wall << ! 11 | Making a phone call 12 | ! 13 | 14 | pppd call tmpphonecall & 15 | sleep 30 16 | killall pppd 17 | 18 | wall << ! 19 | Phone call over. Restoring pppd... 20 | ! 21 | 22 | ppp-on 23 | sleep 2 24 | ensure-ip-state | wall 25 | -------------------------------------------------------------------------------- /code/shellscript/monitors/monitorcomusage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$1" = ""; then 3 | echo 4 | fi 5 | 6 | MONPATH=`jgettmpdir monpath` 7 | 8 | echo "$PATH" | tr ":" "\n" | 9 | while read D 10 | do 11 | cd "$D" 12 | 'ls' 13 | done | 14 | while read F 15 | do 16 | ln -s "$JPATH/tools/monitorcomusage" "$MONPATH/$F" 17 | done 18 | 19 | echo "export PATH=\"$MONPATH:\$PATH\"" 20 | -------------------------------------------------------------------------------- /code/shellscript/other/mp3towav: -------------------------------------------------------------------------------- 1 | if [ ! "$2" ] || [ "$1" = --help ] 2 | then 3 | echo "mp3towav " 4 | echo " You can use - in either parameter for stdin/out." 5 | exit 1 6 | fi 7 | 8 | ## Added -t wav on output in case user specified output to "-" and hence no type is suggested. 9 | mpg123 -b 10000 -s "$1" | sox -t raw -r 44100 -s -w -c2 - -t wav "$2" 10 | -------------------------------------------------------------------------------- /code/shellscript/systemd/systemd_watch_journal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #journalctl -x -f -b 0 -n 1000 4 | 5 | # Instead of running the command, we display it, to encourage the user (me) to learn the commands 6 | cat << ! 7 | 8 | Try: journalctl -x -f -b 0 -n 1000 9 | 10 | or to watch output from a particular unit: 11 | 12 | sudo journalctl -f -u earlyoom 13 | 14 | ! 15 | -------------------------------------------------------------------------------- /code/shellscript/other/resistancemailstoweb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd $JPATH/code/c/tools/mail 3 | cp -f $HOME/nsmail/Resistance . 4 | rm -rf Resistance.ems 5 | unpine Resistance 6 | cd Resistance.ems 7 | mkdir titled 8 | export OUTDIR="titled" 9 | emailsort *.txt 10 | ENDUP="$HOME/joey/web/cs/genlove/admin/emails" 11 | rm -rf $ENDUP 12 | mv titled $ENDUP 13 | cd $ENDUP 14 | zip theWholeLot.zip * -------------------------------------------------------------------------------- /code/shellscript/audio/set_volume.sh: -------------------------------------------------------------------------------- 1 | VOL="$1" 2 | if which pulseaudio-ctl >/dev/null 2>&1 3 | then pulseaudio-ctl set "$VOL" 4 | elif which amixer >/dev/null 2>&1 5 | then amixer -c 0 sset "Master" "playback" "$VOL" >/dev/null 6 | elif which aumix >/dev/null 2>&1 7 | # then aumix -d $MIXER -w $VOL 8 | then aumix $AUMIX_OPTS -w "$VOL" 9 | fi 10 | 11 | [ -n "$SHOW_VOLUME" ] && show_volume 12 | -------------------------------------------------------------------------------- /code/shellscript/file/issymlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | RES=`find "$1" -type l` 3 | test "$RES" = "$1" 4 | exit 5 | 6 | ## Another method: 7 | [ -L "$1" ] 8 | exit 9 | 10 | ## Another method: 11 | if test -e "$1" && test ! ""`justlinks "$1"` = ""; then 12 | exit 0 13 | else 14 | exit 1 15 | fi 16 | 17 | # Some alternatives offered by bash (-h, -l) only succeed if the link is non-broken? 18 | 19 | -------------------------------------------------------------------------------- /code/shellscript/init/cvsinit.sh: -------------------------------------------------------------------------------- 1 | # @sourceme 2 | 3 | export PRCS_REPOSITORY=/stuff/PRCS 4 | 5 | export CVSROOT=/stuff/cvsroot 6 | ## OMG why on earth did I set this? It's been a real pain for years! 7 | # export CVSREAD=yes 8 | 9 | # For remote: 10 | # export CVS_RSH=ssh 11 | # export CVSROOT=:ext:joey@hwi.dyn.dhs.org:/stuff/cvsroot 12 | 13 | # export VISUAL=vi 14 | # export EDITOR=vi 15 | -------------------------------------------------------------------------------- /code/shellscript/mail/catintofile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Actually implemented to append an email to a mailbox file 3 | ## Can be changed if joey's /etc/alises is updated accordingly. 4 | while test -f "$*.lock"; do 5 | sleep 1 6 | done 7 | touch "$*.lock" 8 | echo "$USER $?" >> /tmp/catintofile.log 9 | chmod a+w /tmp/catintofile.log 10 | tee -a "$*".bak | 11 | cat >> "$*" 12 | rm -f "$*.lock" 13 | -------------------------------------------------------------------------------- /code/shellscript/fs/mvpreserve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Uses cp -a to preserve the files meta-info (e.g. last-modified date) 3 | 4 | ## Damn it doesn't work; better use touch instead to copy that info 5 | 6 | ## No wait I think the problem is when I try to write to my FAT fs but it has been mounted as root. :P 7 | 8 | cp -a "$@" && 9 | while [ "$2" ] 10 | do 11 | del "$1" 12 | shift 13 | done 14 | -------------------------------------------------------------------------------- /code/shellscript/progress/watch_progress.sh: -------------------------------------------------------------------------------- 1 | ## watch_progress ... 2 | 3 | MAX="$1" 4 | shift 5 | COMMAND="$*" 6 | 7 | while true 8 | do 9 | 10 | CURRENT=`"$@"` 11 | PROPORTION=$((100*CURRENT/MAX)) 12 | 13 | echo -e -n "\r$CURRENT/$MAX = $PROPORTION% " 14 | 15 | [ "$PROPORTION" -gt 99 ] && break 16 | 17 | sleep 5 18 | 19 | done 20 | 21 | echo 22 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/jindent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for X in "$@"; do 3 | cp "$X" "$X".b4jind 4 | if endswith "$X" "\.htm" || endswith "$X" "\.html"; then 5 | # hindent -s -t 1 -i 1 "$X" | trimempty > tmp.txt 6 | hindent -t 1 -i 1 "$X" | sed "s+^[ ]*$++" > tmp.txt 7 | cp tmp.txt "$X" 8 | else 9 | # indent -sob -br -npsl -ce -brs $X 10 | astyle --indent=spaces=2 $X 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /code/shellscript/video/getvideoduration.sh: -------------------------------------------------------------------------------- 1 | ## Outputs seconds as a decimal 2 | mplayer -vo null -ao null -frames 0 -identify "$1" 2>/dev/null | grep "^ID_LENGTH=" | sed 's+^[^=]*=++' 3 | 4 | ## An alternative: 5 | # ffmpeg -i "$1" 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,// 6 | ## This outputs hours:minutes:seconds.centiseconds 7 | ## We should do further processing to produce answer in seconds 8 | -------------------------------------------------------------------------------- /code/shellscript/net/downloadurl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## We try to use Lynx where possible because some sites reject wget requests :-( 3 | ## TODO: Set wget's Agent header. 4 | 5 | if `jwhich lynx -quietly` 6 | then lynx -source "$@" 7 | elif `jwhich wget -quietly` 8 | then wget -nv -O - "$@" 9 | else 10 | error "downloadurl: neither wget nor lynx present, no telnet implemented." 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /code/shellscript/web/ftpsearch: -------------------------------------------------------------------------------- 1 | TEXT="$1" 2 | HITS="20" 3 | # DOMAIN="uk" 4 | DOMAIN="" 5 | lynx -dump "http://ftpsearch.lycos.com/cgi-bin/search?form=medium&query=$TEXT&doit=Search&type=Case+insensitive+multiple+substrings+search&hits=$HITS&matches=&hitsprmatch=&limdom=$DOMAIN&limpath=&f1=Count&f2=Mode&f3=Size&f4=Date&f5=Host&f6=Path&header=none&sort=none&trlen=20" | grep "ftp://ftp." | awk ' { printf($2"\n") } ' -------------------------------------------------------------------------------- /code/shellscript/indevelopment/splitintothreecolumns.sh: -------------------------------------------------------------------------------- 1 | REBEFORE="$1" 2 | RETODO="$2" 3 | REAFTER="$3" 4 | shift 5 | shift 6 | shift 7 | 8 | cat "$@" | 9 | sed "s+\($REBEFORE\)\($RETODO\)\($REAFTER\)+\1+" > /tmp/left.out 10 | 11 | cat "$@" | 12 | sed "s+\($REBEFORE\)\($RETODO\)\($REAFTER\)+\2+" > /tmp/todo.out 13 | 14 | cat "$@" | 15 | sed "s+\($REBEFORE\)\($RETODO\)\($REAFTER\)+\3+" > /tmp/right.out 16 | -------------------------------------------------------------------------------- /code/shellscript/other/alluptodate: -------------------------------------------------------------------------------- 1 | # Records the time at which all files correspond 2 | # with those at HQ. 3 | # Later, we can use findchanges to see which files 4 | # need to be taken back to HQ. 5 | 6 | date > $JPATH/uptodate.txt 7 | echo "All files up to date" >> $JPATH/uptodate.txt 8 | echo "Do not edit this file!" >> $JPATH/uptodate.txt 9 | 10 | echo "Recorded files up to date in $JPATH/uptodate.txt" -------------------------------------------------------------------------------- /code/shellscript/other/removeduplicates: -------------------------------------------------------------------------------- 1 | WORDSIN="$@" 2 | WORDS="" 3 | for WORD in $WORDSIN; do 4 | GOT="false" 5 | for X in $WORDS; do 6 | if [ "$WORD" = "$X" ]; then 7 | GOT="true" 8 | fi 9 | done 10 | if [ "$GOT" = "false" ]; then 11 | WORDS="$WORDS$WORD 12 | " 13 | # echo "Adding $WORD" 14 | # else 15 | # echo "Already got $WORD" 16 | fi 17 | done 18 | echo "$WORDS" -------------------------------------------------------------------------------- /code/shellscript/shext/echolines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Prints each argument provided on a separate line. 3 | ## Essentially converts an argument list to a stream (line-delimited rather than space-delimited). 4 | ## It might be considered the opposite withalldo, which converts a stream/list of arguments into arguments in a shell call. 5 | 6 | for ARG 7 | # do echo "$ARG" 8 | do printf "%s\n" "$ARG" 9 | done 10 | -------------------------------------------------------------------------------- /code/shellscript/find/find-typef_avoiding_stale_handle_error.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## jsh-help: Like find "$1" -type f, but does not bomb when encountering "Stale NFS file handle" 3 | ## jsh-help: I used to get that problem occasionally on a vfat mount I used. 4 | 5 | # cd "$1" || . errorexit "Could not enter directory $1" 6 | # [ -e "$1" ] || . errorexit "Does not exist: $1" 7 | 'ls' "$1" -a -R | ls-Rtofilelist | filesonly 8 | -------------------------------------------------------------------------------- /code/shellscript/net/pingtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | REPORTFILE=`jgettmp "ping$*"` 3 | 4 | printf "" > $REPORTFILE 5 | 6 | ( 7 | ping -c 5 "$@" > /dev/null 8 | echo "$?" > $REPORTFILE 9 | ) & 10 | 11 | sleep 60 12 | REPORT=`cat $REPORTFILE` 13 | 14 | jdeltmp $REPORTFILE 15 | 16 | if test "$REPORT" = "0" 17 | then 18 | echo "ping succeeded" 19 | exit 0 20 | else 21 | echo "ping failed" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /code/shellscript/other/makechat.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main(int argc,char **argv) { 3 | if (argc<=1) 4 | printf("makechat : no provided!\n"); 5 | else { 6 | char *isp=argv[1]; 7 | char com[64]; 8 | int i=sprintf(com,"cp /etc/ppp/chat-script.%s /etc/ppp/chat-script\n",isp); 9 | system(com); 10 | printf("makechat: chat-script.%s\n",isp); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code/shellscript/posessive/shield.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # todo: rename posessive/ sec/ 3 | 4 | ## todo: shield will chmod current directory and all below, then jump to shield user 5 | ## it's a way of programming/running random stuff without danger to your fs 6 | 7 | ## of course he can still open local sockets 8 | 9 | ## unchmod on exit 10 | 11 | ## it would be good to retain as much shell config as possible 12 | -------------------------------------------------------------------------------- /code/shellscript/rpm/whatdepends.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## For when you do an apt-get install but get dependency problems which need resolving. 3 | ## Doesn't deal with or options 4 | 5 | grep " Depends: " | 6 | afterfirst " Depends: " | 7 | takecols 1 | 8 | 9 | ## Formatted for easy insertion 10 | ## The current context is for downgrading to stable: 11 | # sed 's+$+/unstable+' | 12 | tr '\n' ' ' 13 | 14 | echo 15 | -------------------------------------------------------------------------------- /code/shellscript/xwin/getcurrentwindowprop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # E.g.: getcurrentwindowprop WM_CLASS 4 | 5 | winid="$(xdotool getwindowfocus)" 6 | 7 | xprop -id "$winid" "$@" | 8 | if [ -n "$1" ] 9 | then 10 | # A specific prop was requested. Get its value only. 11 | cut -d '"' -f 2 12 | else 13 | # Show all prop keys and values 14 | cat 15 | fi 16 | -------------------------------------------------------------------------------- /code/shellscript/apt/apt-get-security.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | SECURITY_LIST=/tmp/sources-security.list 5 | 6 | if [ ! -f "$SECURITY_LIST" ] 7 | then 8 | echo "Generating $SECURITY_LIST" 9 | cat /etc/apt/sources.list | grep security > "$SECURITY_LIST" 10 | fi 11 | 12 | # apt-get --option Dir::Etc::sourcelist="$SECURITY_LIST" upgrade 13 | aptitude -o Dir::Etc::sourcelist="$SECURITY_LIST" upgrade 14 | 15 | -------------------------------------------------------------------------------- /code/shellscript/installwrapper/get_imwheel_softmouse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p $HOME/bin && 3 | wget -nv "http://hwi.ath.cx/projects/imwheel_softmouse/src/imwheel" -O $HOME/bin/imwheel && 4 | wget -nv "http://hwi.ath.cx/projects/imwheel_softmouse/src/.imwheelrc" -O $HOME/.imwheelrc && 5 | echo "To run imwheel without detaching, type: \$HOME/bin/imwheel -d" && 6 | chmod a+x $HOME/bin/imwheel 7 | xterm -e $HOME/bin/imwheel -d 8 | -------------------------------------------------------------------------------- /code/shellscript/mail/remove_old_mail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # the following line would be "MB=$1", if you wanted to pass the mailbox 3 | # to process as an argument to the script 4 | 5 | # MB=~/debian.mbox 6 | # formail -s bash -c "IFS=''; b=\`cat\`; test \$(date -d \"\$( echo \$b|formail -x Date )\" +%s) -ge \$(date -d \"7 days ago\" +%s) && echo -e \"\$b\n\n\"" <$MB >$MB.new && mv $MB.new $MB 7 | 8 | ## WARNING UNTESTED! 9 | -------------------------------------------------------------------------------- /code/shellscript/shext/requirevars.sh: -------------------------------------------------------------------------------- 1 | ## Source me from a bash-shebanged script (will not work from an sh-shebanged script) 2 | 3 | for VAR in "$@" 4 | do 5 | 6 | VALUE=`eval echo '$'"$VAR"` 7 | # echo "$VAR=$VALUE" 8 | if [ ! "$VALUE" ] 9 | then 10 | 11 | error "Required environment variable $VAR is empty." 12 | jshinfo "In fact all of these are needed: $*" 13 | exit 1 14 | 15 | fi 16 | 17 | done 18 | -------------------------------------------------------------------------------- /code/shellscript/string/reverse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## NOTE BUG: inefficient on long lists 3 | # LIST="" 4 | # while read X; do 5 | # LIST="$X 6 | # $LIST" 7 | # done 8 | # printf "$LIST" 9 | 10 | ## More efficient version; use sort to do reversal for us! 11 | ## jsh-ext-depends: sort 12 | N=0 13 | while read LINE 14 | do 15 | echo "$N $LINE" 16 | N=`expr "$N" + 1` 17 | done | 18 | sort -n -k 1 -r | 19 | dropcols 1 20 | -------------------------------------------------------------------------------- /code/shellscript/wget/wget_all_links_with_extension.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$2" = "" ] || [ "$1" = --help ] 4 | then cat << ! 5 | wget_all_links_with_extension 6 | 7 | will fetch the given HTML page, and then download all links on that page which match the given extension. 8 | ! 9 | exit 10 | fi 11 | 12 | url="$1" 13 | ext="$2" 14 | shift; shift 15 | 16 | wget -r -l 1 -H -A "$ext" "$url" 17 | -------------------------------------------------------------------------------- /code/shellscript/mp3/wav2mp3: -------------------------------------------------------------------------------- 1 | ## I had a wav from TeamSpeak at 22050Hz 2 | ## To prepare it for bladeenc, I first had to: 3 | ## sox blah.wav -r 48000 blah2.wav 4 | 5 | if test "$1" = "" -o "$2" = "" ; then 6 | echo "wav2mp3 " 7 | exit 1 8 | fi 9 | 10 | bladeenc -QUIT "$1" 11 | 12 | ## BUG TODO: output is only tmp.mp3 if input was tmp.wav :P 13 | mv "tmp.mp3" "$2" 14 | 15 | -------------------------------------------------------------------------------- /code/shellscript/string/strlen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ### Bash built-in 3 | echo "${#1}" 4 | exit 5 | 6 | 7 | 8 | ### Alternative 9 | 10 | #!/bin/sh 11 | 12 | printf "%s" "$*" | wc -m 13 | exit 14 | 15 | 16 | 17 | ### Original: 18 | 19 | # jsh-depends: countlines 20 | # if test ! "$1" = ""; then 21 | echo "$@" | 22 | # else 23 | # cat 24 | # fi | 25 | tr -d "\n" | 26 | sed 's/./\ 27 | /g' | 28 | countlines 29 | -------------------------------------------------------------------------------- /code/shellscript/compile/x: -------------------------------------------------------------------------------- 1 | ## This is a very bad use of 'x'. But it is needed to compile some old C packages of mine. 2 | ## I prefer to use 'x' as an alias for xterm& 3 | echo "" 4 | echo The compiler is your friend ---------------------------------------- 5 | echo "" 6 | # -s = no symbols saved (not on debian!) -g = debug data 7 | g++ -w -fconserve-space -g $1.c -o $1 -I $JPATH/code/c/joeylib $2 $3 $4 $5 $6 |more 8 | chmod g+x $1 9 | -------------------------------------------------------------------------------- /code/shellscript/other/docheck: -------------------------------------------------------------------------------- 1 | mv ~/new.check ~/old.check 2 | ps -o "%u : %a" -A > ~/new.check 3 | sleep 1s 4 | while [ true ]; do 5 | mv ~/new.check ~/old.check 6 | # ps -o "%u : %a" -u $USER -U $USER -N > ~/new.check 7 | ps -o "%u : %a" -A > ~/new.check 8 | # jfc ~/new.check ~/old.check simple oneway 9 | jfc ~/new.check ~/old.check simple oneway 10 | sleep 1s 11 | done 12 | #docheck 13 | rm ~/old.check 14 | rm ~/new.check 15 | -------------------------------------------------------------------------------- /code/shellscript/audio/playmp3s.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | WHERE="$@" 3 | ENQUEUE="" # "-e" 4 | if [ "$1" = "fresh" ]; then 5 | WHERE="$2" 6 | ENQUEUE="" 7 | fi 8 | if [ "$WHERE" = "" ]; then 9 | WHERE="$PWD/" # This '/' is vital for find to work if $PWD is a link! 10 | else 11 | WHERE="$PWD/$WHERE" 12 | fi 13 | find "$WHERE" -name "*.mp3" > $JPATH/music/group.m3u 14 | COM="xmms $ENQUEUE $JPATH/music/group.m3u" 15 | echo "$COM" 16 | $COM -------------------------------------------------------------------------------- /code/shellscript/file/filepath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # local path to file/dir 3 | 4 | FILE="$@" 5 | 6 | # Remove trailing '/' if a directory 7 | FILE=`echo "$FILE" | sed 's+/$++'` 8 | 9 | # Remove last '/' and everything after it 10 | STRIPPEDPATH=`echo "$FILE" | beforelast "/"` 11 | 12 | # If no slashes we get the same back 13 | if test "x$STRIPPEDPATH" = "x$FILE"; then 14 | echo "." 15 | else 16 | echo "$STRIPPEDPATH" 17 | fi 18 | -------------------------------------------------------------------------------- /code/shellscript/mail/netscape2kmail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find $HOME/nsmail -type d -name "*.sbd" -follow | 3 | grep -v ".directory" | 4 | while read X; do 5 | Y=`echo "$X" | sed "s-\(.*\)/\(.*\)\.sbd-\1/\.\2\.directory-"`; 6 | if test -d "$Y"; then 7 | echo "already exists: $Y" 8 | else 9 | echo "$Y -> "`filename "$X"` 10 | ln -s "$X" "$Y" 11 | fi 12 | done 13 | ln -sf $HOME/nsmail $HOME/Mail/.nsmail.directory 14 | -------------------------------------------------------------------------------- /code/shellscript/oscompat/dos2unix.sh: -------------------------------------------------------------------------------- 1 | if [ "$*" ] 2 | then 3 | for FILE 4 | do cat "$FILE" | dos2unix | pipebackto "$FILE" 5 | done 6 | else 7 | tr -d '\r' 8 | #perl -pe 's/\r\n/\n/g' 9 | fi 10 | 11 | ## Doesn't seem to work 12 | # for FILE 13 | # do 14 | # TMPFILE=`jgettmp "$FILE"` 15 | # cat "$FILE" | 16 | # sed 's+\r$++' | 17 | # cat > $TMPFILE && 18 | # cp -f $TMPFILE "$FILE" 19 | # jdeltmp $TMPFILE 20 | # done 21 | -------------------------------------------------------------------------------- /code/shellscript/monitors/monitorfileaccess.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also: monitorfolder (efficient, uses inotifywait) 3 | # See also: watchforfileaccess 4 | 5 | #jwatch listopenfiles -mergethreads . 2>/dev/null | grep -v "\" 6 | 7 | jwatch lsof -n -S 2 -V "$@" 2>/dev/null | grep -v "lsof\>" 8 | 9 | # Bad: shows various lines from the jwatch process. 10 | #jwatch eval "lsof -n -S 2 -V | grep -v '\'" 2>/dev/null 11 | -------------------------------------------------------------------------------- /code/shellscript/monitors/watchforfileaccess.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # See also: package/command 'watchdog'. 3 | # See also: watchfolderforchanges, monitorfileaccess 4 | #jwatch ls -ul $@ 5 | # Can add -R but does become slower (and doesn't show full paths)! 6 | #jwatch ls -ulR $@ 7 | #jwatch fasttreeprofile "$@" 8 | # But we aren't really interested when files are access, only changed, so: 9 | jwatch eval "fasttreeprofile $@ | dropcols 2 3" 10 | -------------------------------------------------------------------------------- /code/shellscript/versioning/svnvimdiff.sh: -------------------------------------------------------------------------------- 1 | FILENAME="$1" 2 | 3 | REVISION="$2" 4 | if [ "$REVISION" ] 5 | then EXTRAARGS="-r $REVISION" 6 | fi 7 | 8 | ## Get a copy of the repository version by reversing current diff against repository: 9 | TMPFILE=`jgettmp "$1.repository"` 10 | cp "$FILENAME" $TMPFILE 11 | svn diff $EXTRAARGS "$FILENAME" | patch -R $TMPFILE || exit 1 12 | 13 | vimdiff $TMPFILE "$FILENAME" 14 | 15 | jdeltmp $TMPFILE 16 | -------------------------------------------------------------------------------- /code/shellscript/datetime/geekdate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Returns a fixed-length date string suitable for computer use, because simple string-ordering of these strings will correspond to chronological order. 4 | ## See also: date -I 5 | if [ "$1" = -seconds ] 6 | then shift; date +"%Y%m%d-%H-%M-%S" "$@" 7 | elif [ "$1" = -fine ] || [ "$1" = -minutes ] 8 | then shift; date +"%Y%m%d-%H%M" "$@" 9 | else date +"%Y%m%d" "$@" 10 | fi 11 | -------------------------------------------------------------------------------- /code/shellscript/other/listnums.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # #!/bin/sh 3 | 4 | START=$1 5 | END=$2 6 | INC="1"; 7 | if test "$3" = "by"; then 8 | INC="$4" 9 | fi 10 | 11 | seq $START $INC $END 12 | 13 | # X=$START 14 | # LIST="" 15 | # DONE="" 16 | # while [ ! "$X" = "$END" ]; do 17 | # # LIST="$LIST$X " 18 | # echo "$X" 19 | # X=$[$X+$INC] 20 | # # X=$[$X+1] 21 | # done 22 | # echo $END 23 | # # LIST="$LIST$END" 24 | # # echo "$LIST" 25 | -------------------------------------------------------------------------------- /code/shellscript/shlib/escapeargs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Returns the given arguments as a string, with each arg quoted and with any 3 | ## quotes inside it escaped. Useful when you are forced to pass multiple 4 | ## arguments in one string, and the arguments might contains spaces or other 5 | ## evil chars! 6 | for arg 7 | do 8 | escapedArg=$(printf "%s" "$arg" | sed 's+"+\\"+g') 9 | printf "\"%s\" " "${escapedArg}" 10 | done | sed 's+ $++' 11 | -------------------------------------------------------------------------------- /code/shellscript/versioning/cvsstatus.sh: -------------------------------------------------------------------------------- 1 | ## Only tested on up-to-date checkout :P 2 | 3 | cvs status "$@" 2>&1 | 4 | 5 | ## Positive match for the info we want: 6 | # grep "^File:" | 7 | 8 | ## Match for the data we don't want (allows unrecognised errors through) 9 | grep -v "^cvs status: Examining " | 10 | grep -v "^[ =]" | 11 | grep -v "^$" | 12 | 13 | # takecols 4 2 14 | # dropcols 1 3 15 | sed ' s+^File: ++ ; s+\/dev/null 9 | then indent="$indent"" " 10 | fi 11 | if printf "%s\n" "$line" | grep "$outdent_on_regexp" >/dev/null 12 | then indent=`echo "$indent" | sed 's+ $++'` 13 | fi 14 | printf "%s%s\n" "$indent" "$line" 15 | done 16 | 17 | -------------------------------------------------------------------------------- /code/shellscript/string/longestline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | awk 'BEGIN { max=0 } { if (length($0) > max) max = length($0) } END { print max }' "$@" 3 | # Linux info output is full of '^H's! Used col -bx. 4 | # awk '{ if (length($0) > max) { max = length($0); print length($0) ">"$0"<" } } END { print max }' $* 5 | # if test -f "$*"; then 6 | # awk '{ if (length($0) > max) max = length($0) } END { print max }' $* 7 | # else 8 | # echo 0 9 | # fi 10 | -------------------------------------------------------------------------------- /code/shellscript/wget/wget_get_everything_below.sh: -------------------------------------------------------------------------------- 1 | ## Could be renamed: get_high_fidelity_sub_mirror 2 | echo "Warning: May not be browseable (use -k or wget_get_browseable_copy for that). This kind of backup has more fidelity to the original, but may not work when placed on a different domain, and won't pass checksum comparisons." 3 | echo 4 | sleep 1 5 | wget --mirror --no-parent "$@" 6 | ## Some more useful options: 7 | # -k -e robots=off --wait 1 8 | -------------------------------------------------------------------------------- /code/shellscript/file/diffdirs_with_rsync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | show_colors=1 4 | 5 | dira="$1" 6 | dirb="$2" 7 | 8 | # -a is -rlptgoD but we don't want -t so we leave that out and use --size-only to ignore times 9 | rsync -rlpgoD --size-only --delete -i -n "$dirb/" "$dira" | 10 | if [ -n "$show_colors" ] 11 | then 12 | highlight '^c.*' yellow | 13 | highlight '^>.*' green | 14 | highlight '^\*deleting .*' red 15 | else cat 16 | fi 17 | -------------------------------------------------------------------------------- /code/shellscript/file/purgelinks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Displays what needs to be done to remove all symlinks 3 | # in current / specified directory. 4 | 5 | if test "x$1" = "x"; then 6 | LOOK="." 7 | else 8 | LOOK="$@" 9 | fi 10 | 11 | find "$LOOK" -type l | 12 | # I trust it: 13 | # sed 's/^/rm "/;s/$/"/' 14 | # But here's an ultra-confidence version: 15 | while read X; do 16 | echo "# "`ls -dF --color "$X"` 17 | echo "rm '$X'" 18 | done 19 | -------------------------------------------------------------------------------- /code/shellscript/mongo/monitor_mongo_collection.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | db_name="$1" 4 | collection_name="$2" 5 | 6 | # We use .toArray() to avoid mongo's 20 document limit. It also pretty-prints (each document takes multiple lines). 7 | # Alternatively we can put `DBQuery.shellBatchSize = 300` before the query. It does not persist. 8 | jwatch eval " mongo '${db_name}' <<< 'db.${collection_name}.find({}).toArray()' | grep -v '^Implicit session' " 9 | -------------------------------------------------------------------------------- /code/shellscript/pkg/sendpkgtoneuralyte.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## This is like getpkgfromhwi, but works in the opposite direction. This pushes a package from the current machine to the remote machine, where it may be used via 'includepath'. 4 | 5 | PKGNAME="$1" 6 | DESTFOLDER="myroots_64/$PKGNAME" 7 | 8 | dpkg -L $PKGNAME | filesonly -inclinks | withalldo tar cjv | 9 | ssh joey@neuralyte.org "mkdir '$DESTFOLDER' && cd '$DESTFOLDER' && tar xj" 10 | 11 | -------------------------------------------------------------------------------- /code/shellscript/ripaudio/ripaudio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends: vsound 3 | # jsh-depends: rotate 4 | 5 | FILE=/tmp/ripped_audio.wav 6 | 7 | if [ ! "$1" ] || [ "$1" = --help ] 8 | then 9 | echo 10 | echo "ripaudio ..." 11 | echo 12 | echo " will execute the command, and save audio output to $FILE" 13 | echo 14 | exit 1 15 | fi 16 | 17 | if [ -f "$FILE" ] 18 | then rotate "$FILE" 19 | fi 20 | 21 | vsound -v -d -t -f "$FILE" "$@" 22 | -------------------------------------------------------------------------------- /code/shellscript/ascii/figletall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # /usr/lib/xscreensaver/phosphor -font lucidatypewriter -delay 10 -scale 2 -geometry 1280x1024 -program "figletall joey@hwi.ath.cx" 3 | TXTEXT="" 4 | for FONTFILE in /usr/share/figlet/*.flf /stuff/mirrors/www.figlet.org/fonts/*.flf 5 | do 6 | test "$*" || TXTEXT=`echo "$FONTFILE" | sed 's+.*/++;s+\.flf$++'` 7 | echo "$FONTFILE" | sed 's+.*/++;s+\.flf$++' 8 | figlet -f "$FONTFILE" "$@" "$TXTEXT" 9 | done 10 | -------------------------------------------------------------------------------- /code/shellscript/regexp/list2regexp.sh: -------------------------------------------------------------------------------- 1 | ## Unfortunately grep can be very slow with large regexps. 2 | ## Often a better solution is to pipe the stream to a file 3 | ## and have grep run over it multiple times, once for each argument (to list2regexp). 4 | 5 | echo -n "\(" 6 | FIRST=true 7 | while read LINE 8 | do 9 | [ "$FIRST" ] || echo -n "\|" 10 | # echo "Adding to list: >$LINE<" >&2 11 | echo -n "$LINE" 12 | FIRST= 13 | done 14 | echo -n "\)" 15 | -------------------------------------------------------------------------------- /code/shellscript/REFACTORS_TODO.txt: -------------------------------------------------------------------------------- 1 | # Common patterns which I have used but could be improved 2 | 3 | 4 | 5 | I have been using: 6 | 7 | grep ... ... >/dev/null 8 | 9 | to test for the presence of without creating any output if it is present. However it might be better to do: 10 | 11 | grep ... -q ... 12 | 13 | Or we could even write a script for it: 14 | 15 | contains_regexp ... 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /code/shellscript/j/exportbin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for x in "$@"; do 3 | if isabsolutepath $x; then 4 | SRCDIR=`dirname $x` 5 | else 6 | SRCDIR=`dirname $PWD/$x` 7 | fi 8 | # echo "$SRCDIR" 9 | JCODEDIR=`echo "$SRCDIR" | sed "s:^"$JPATH"/code/::"` 10 | DESTDIR="$JPATH/bin/$JCODEDIR" 11 | echo "$SRCDIR/"`filename $x`" -> $DESTDIR" 12 | mkdir -p "$DESTDIR" 13 | mv $x "$DESTDIR" 14 | if test -d "CVS"; then 15 | cvs remove $x 16 | fi 17 | done 18 | -------------------------------------------------------------------------------- /code/shellscript/jgrm/jparse: -------------------------------------------------------------------------------- 1 | javaTop="$JPATH/code/java" 2 | [ -d "$javaTop" ] || javaTop="$HOME/j/code/java" 3 | export CLASSPATH="$CLASSPATH:$javaTop/jlib/bin:$javaTop/web/CommonUtils/bin:$javaTop/tools/parser/bin" 4 | 5 | # java -cp "$CLASSPATH:$JPATH/code/java/tools/parser/" Parser "$@" 6 | java tools.parser.Parser "$@" 7 | # java -Xdebug -Xrunjdwp:transport=dt_socket,address=8123,server=y,suspend=n tools.parser.Parser "$@" 8 | # ledit jdb tools.parser.Parser "$@" 9 | -------------------------------------------------------------------------------- /code/shellscript/mp3/keepstreamedmp3: -------------------------------------------------------------------------------- 1 | SRCDIR="$JPATH/music/streamed/" 2 | DESTDIR="$JPATH/tracks/streamed/" 3 | 4 | SRCFILENAME=`"ls" -t "$SRCDIR" | head -n 1` 5 | FILENAME="$SRCFILENAME" 6 | echo "$FILENAME" 7 | 8 | mkdir -p "$DESTDIR" 9 | DESTFILE="$DESTDIR/$FILENAME" 10 | while [ -f "$DESTFILE" ]; do 11 | FILENAME="_$FILENAME" 12 | DESTFILE="$DESTDIR/$FILENAME"; 13 | done 14 | echo "$DESTFILE <- $SRCDIR" 15 | 16 | cp "$SRCDIR/$SRCFILENAME" "$DESTFILE" 17 | -------------------------------------------------------------------------------- /code/shellscript/string/contains.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Note now different syntax to endswith. 3 | 4 | if test "$1" = "" || test "$1" = "--help" 5 | then 6 | echo "contains " 7 | echo "stream | contains " 8 | exit 1 9 | fi 10 | 11 | if test "$2" = "" 12 | then grep "$1" > /dev/null 13 | else echo "$1" | grep "$2" > /dev/null 14 | fi 15 | 16 | # RESULT=`echo "$1" | grep "$2"` 17 | # test ! "$RESULT" = "" 18 | -------------------------------------------------------------------------------- /code/shellscript/other/aft: -------------------------------------------------------------------------------- 1 | choosefile $HOME/GNUstep/Library/AfterStep/themes -dest $JPATH/tmp/ast.tgz 2 | 3 | perl /usr/X11R6/bin/installastheme.pl $JPATH/tmp/ast.tgz 4 | 5 | #cd $JPATH/tmp/ 6 | #mkdir tmp2 7 | #cd tmp2 8 | #tar xfz ../ast.tgz 9 | #rm -f $HOME/GNUstep/Library/AfterStep/desktop/themes/* 10 | #cp */* $HOME/GNUstep/Library/AfterStep/desktop/themes/ 11 | #cd .. 12 | #rm -rf tmp2 13 | 14 | rm -f ast.tgz 15 | 16 | xinit $JPATH/tools/afterstep.xinit 17 | -------------------------------------------------------------------------------- /code/shellscript/rpm/dpkgusage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Lists most recent date of access to files of 3 | # each package on a Debian system. 4 | 5 | dpkg -l | drop 5 | sed "s/[^ ]* //" | 6 | while read PKG VER REST; do 7 | FILES=` dlocate -L "$PKG" | 8 | # grep "(/bin/|/lib/)" 9 | cat 10 | ` 11 | LAST=` 12 | dar -d $FILES | 13 | grep -v "/$" | grep -v " -> " | 14 | takecols 6 7 | trimempty | tail -n 1 15 | ` 16 | printf "$PKG\t$LAST\t$REST\n" 17 | done 18 | -------------------------------------------------------------------------------- /code/shellscript/sh/shexamples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## A stream piped in a loop: 3 | (echo 0; sleep 1; tail -f /tmp/looped.stream) | 4 | while read N; do 5 | echo `expr $N + 1` 6 | echo $N >&2 7 | done > /tmp/looped.stream 8 | 9 | # rm -f /tmp/tmpfifo 10 | # mkfifo /tmp/tmpfifo 11 | # echo A 12 | # echo 0 >> /tmp/tmpfifo & 13 | # echo B 14 | # tail -f /tmp/tmpfifo | 15 | # while read N; do 16 | # echo "$N" 17 | # echo `expr "$N" + 1` >> /tmp/tmpfifo & 18 | # done 19 | -------------------------------------------------------------------------------- /code/shellscript/sync/cksumfindupl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # cksumall $* > tmp.txt 3 | 4 | cat tmp.txt | grep -v "/CVS/" | grep -v "\.b4sr$" > tmp2.txt 5 | mv tmp2.txt tmp.txt 6 | 7 | cat tmp.txt | while read X; do 8 | KEY=`echo $X | sed "s/ \..*//"` 9 | RES=`grep "$KEY" tmp.txt` 10 | if test "$RES" = "$X"; then 11 | noop 12 | else 13 | echo "------------------" 14 | echo "$RES" 15 | # cmp $RES returns 0 if they really are duplicates =) 16 | fi 17 | done 18 | -------------------------------------------------------------------------------- /code/shellscript/init/preventgreperrs.sh: -------------------------------------------------------------------------------- 1 | # @sourceme 2 | 3 | ## Avoid "cannot grep directory" errors: 4 | 5 | if [ "$JM_UNAME" = "sunos" ] 6 | then 7 | 8 | function mygrep () { 9 | REALGREP=`jwhich grep` 10 | # $REALGREP "$@" 1>&3 2>&1 | $REALGREP -v "^grep: .*: Is a directory$" 11 | $REALGREP "$@" 2> /dev/null 12 | } 13 | alias grep='mygrep' 14 | 15 | else 16 | 17 | ## Linux grep can avoid directory errors: 18 | alias grep='grep -d skip' 19 | 20 | fi 21 | -------------------------------------------------------------------------------- /code/shellscript/monitor/listfilesopenby.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | if [ -z "$1" ] || [ "$1" = --help ] 4 | then cat << ! 5 | 6 | listfilesopenby [...] 7 | 8 | ! 9 | exit 1 10 | fi 11 | 12 | pgrep -l "$@" | 13 | 14 | while read pid pname 15 | do 16 | readlink /proc/"${pid}"/fd/* | 17 | grep -E -v "^/(dev|proc)/" | 18 | grep -E -v "^(socket|pipe|anon_inode):" | 19 | sed "s/^/${pid} ${pname} /" 20 | done | 21 | sort -n -k 1 22 | -------------------------------------------------------------------------------- /code/shellscript/other/monitorcopy: -------------------------------------------------------------------------------- 1 | SIZE=`du -sk "$1" | awk ' { printf($1) } '` 2 | SOFAR=`du -sk "$2" | awk ' { printf($1) } '` 3 | 4 | echo "So far, $SOFAR out of $SIZE has been copied" 5 | echo "Now showing progress:" 6 | 7 | OPTIONS= 8 | if awk -W version 2>&1 | grep "^mawk" > /dev/null 9 | then OPTIONS="-W interactive" 10 | fi 11 | 12 | while true 13 | do 14 | du -sk "$2" 15 | sleep 2 16 | done | 17 | awk $OPTIONS ' { printf("\r"100*$1/'$SIZE'" %% ") } ' >&2 18 | -------------------------------------------------------------------------------- /code/shellscript/file/blocksums.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | BLOCKSIZE=`expr 1024 '*' 1024 '*' 4` 3 | 4 | BLOCKNUM=0 5 | 6 | FILE="$1" 7 | 8 | FILESIZE=`filesize "$FILE"` 9 | 10 | NUMBLOCKS=`expr $FILESIZE / $BLOCKSIZE` 11 | 12 | for BLOCKNUM in `seq -w 0 $NUMBLOCKS` 13 | do 14 | 15 | BLOCKOFF=`expr $BLOCKNUM '*' $BLOCKSIZE` 16 | # echo -n "$BLOCKNUM " 17 | echo -n "$BLOCKOFF " 18 | dd if="$FILE" ibs=$BLOCKSIZE skip=$BLOCKNUM count=1 2>/dev/null | 19 | md5sum 20 | 21 | done 22 | -------------------------------------------------------------------------------- /code/shellscript/posessive/spyon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## TODO: disclaimer 3 | LASTFILE=/tmp/$1.spy 4 | if test ! -f "$LASTFILE" 5 | then 6 | touch -r /home/$1/.bash_history "$LASTFILE" 7 | else 8 | if find /home/$1/.bash_history -newer "$LASTFILE" | grep history > /dev/null 9 | then 10 | touch -d "1 hour" "$LASTFILE" 11 | ( date ; echo "$1 has started a shell on $HOSTNAME" ) | mail joey@hwi.ath.cx 12 | fi 13 | fi 14 | -------------------------------------------------------------------------------- /code/shellscript/proc/myps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends-ignore: time 3 | # this-script-does-not-depend-on-jsh: pid 4 | ## pcpu and pmem are used by wotgobblecpu and wotgobblemem, but are variable, so are not useful for watching! 5 | if [ "$1" = -novars ] 6 | then 7 | shift 8 | ps -o time,ppid,pid,nice,user,args $@ 9 | else 10 | ps -o time,ppid,pid,nice,pcpu,pmem,user,args $@ 11 | fi 12 | # ps -o time,pcpu,pmem,pid,user,comm $@ 13 | # ps -o "(%x %C) %p %u : %a" $@ 14 | -------------------------------------------------------------------------------- /code/shellscript/unixwrap/top.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## well we want to unexport it cos jsh exports it (useful for some apps, but not top, if you change term size whilst it's running) 3 | unset COLUMNS 4 | 5 | ## The problem with top c, is if the user writes c mode to their .toprc with W, then this will undo that! 6 | unj top -n 200 "$@" 7 | # unj top "$@" 8 | ## They can get round it by saving the default non-c mode to their .toprc again. 9 | 10 | # jwatchchanges top c n 1 "$@" 11 | -------------------------------------------------------------------------------- /code/shellscript/versioning/svnstatus.sh: -------------------------------------------------------------------------------- 1 | ## Not quite. ls knows how (at least where newliens are concerned.) 2 | inUserMode() { 3 | [ "`tty`" ] 4 | } 5 | 6 | svn status "$@" | 7 | 8 | # grep -v "^\?" | 9 | 10 | if inUserMode 11 | then 12 | 13 | highlight "^\?.*" magenta | 14 | highlight "^A.*" green | 15 | highlight "^C.*" red | 16 | highlight "^M.*" yellow | 17 | highlight "^\!.*" red | 18 | highlight "^D.*" blue 19 | 20 | else 21 | 22 | cat 23 | 24 | fi 25 | -------------------------------------------------------------------------------- /code/shellscript/web/extracturls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## The final '+' (instead of '*') in each expression means we won't match the empty url "xyz://". 3 | 4 | ## From plain text: 5 | extractregex -atom "([A-Za-z]+:\/\/[^'\"> \n]+)" 6 | 7 | ## From HTML (absolute links only): 8 | # extractregex -atom "[Hh][Rr][Ee][Ff]=['\"]{0,1}([A-Za-z]+:\/\/[^'\"> \n]+)" 9 | 10 | ## From HTML (absolute and relative links): 11 | # extractregex -atom "[Hh][Rr][Ee][Ff]=['\"]{0,1}([^'\"> \n]+)" 12 | -------------------------------------------------------------------------------- /code/shellscript/fs/wheremounted.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## See also: /bin/mountpoint -d (not available in morphix) 3 | # jsh-depends: takecols drop flatdf 4 | # jsh-ext-depends: sort realpath 5 | 6 | DIR=`realpath "$1"` 7 | 8 | flatdf 2>/dev/null | drop 1 | takecols 6 | 9 | 10 | # Choose the longest matching one (/mnt/foo over /): 11 | sort -r | 12 | while read MOUNTPNT 13 | do 14 | echo "$DIR" | grep "^$MOUNTPNT" > /dev/null && 15 | echo "$MOUNTPNT" 16 | done | head -n 1 17 | 18 | -------------------------------------------------------------------------------- /code/shellscript/web/http_get_pure_bash.sh: -------------------------------------------------------------------------------- 1 | # From: http://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro#44317 2 | 3 | domain="www.stroustrup.com" 4 | path="C++.html" 5 | exec 3<> /dev/tcp/$domain/80 6 | printf "GET /$path HTTP/1.1\r\nhost: %s\r\nConnection: close\r\n\r\n" "$domain" >&3 7 | while read -u3; do 8 | if [[ "$REPLY" =~ http://[^\"]* ]]; then 9 | printf '%s\n' "$BASH_REMATCH" 10 | fi 11 | done 12 | -------------------------------------------------------------------------------- /code/shellscript/git/git-restore-file-dates-from-history.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | #git ls-files | 5 | find . -type f | 6 | grep -v '/.git/' | 7 | while read file 8 | do 9 | # Gemini 10 | #commit_date=$(git log -1 --format="%ad" --date=format:"%Y-%m-%d %H:%M:%S" -- "$file") 11 | # qwen-coder 12 | timestamp=$(git log -n 1 --follow --format=format:%ct -- "$file") 13 | if [[ -n "$timestamp" ]] 14 | then verbosely touch -m -d "@$timestamp" "$file" 15 | fi 16 | done 17 | -------------------------------------------------------------------------------- /code/shellscript/hugswrap/ascii.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd $JPATH/code/haskell 3 | # hugswrap Base 'concat [ "s/%" ++ baseconvpadded 2 decimal hex x ++ "/\\" ++ baseconvpadded 3 decimal octal x ++ "/;" | x <- map show [1..255] ]' 4 | # hugswrap Base 'concat [ "s/%" ++ baseconvpadded 2 decimal hex x ++ "/\\" ++ baseconvpadded 3 decimal octal x ++ "/\n" | x <- map show [1..255] ]' 5 | hugswrap Base 'concat [ "s/%" ++ baseconvpadded 2 decimal hex (show x) ++ "/" ++ [chr x] ++ "/g\n" | x <- [1..255] ]' 6 | -------------------------------------------------------------------------------- /code/shellscript/image/generate_favicon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ] || [ "$1" = --help ] 4 | then 5 | echo 6 | echo "generate_favicon " 7 | echo 8 | echo " will create a multi-layer favicon.ico file in the current folder" 9 | echo 10 | exit 11 | fi 12 | 13 | input_file="$1" ; shift 14 | 15 | convert "$input_file" -define icon:auto-resize=128,64,48,32,16 favicon.ico 16 | 17 | # For other approaches, see https://gist.github.com/pfig/1808188 18 | -------------------------------------------------------------------------------- /code/shellscript/sh/addtopaths.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Could replace (/neaten) includepath and addclasspath 3 | 4 | . parseargs_base_impl << ! 5 | ... description TODO 6 | bool AFTER "add entries at end of pathlist (default at beginning)" 7 | ! 8 | 9 | TOADD="$1" 10 | shift 11 | 12 | for VARNAME 13 | do 14 | 15 | if test ! $AFTER 16 | then EVALSTR="$VARNAME=\"\$TOADD:\$$VARNAME\"" 17 | else EVALSTR="$VARNAME=\"\$$VARNAME:\$TOADD\"" 18 | fi 19 | 20 | eval "$EVALSTR" 21 | 22 | done 23 | -------------------------------------------------------------------------------- /code/shellscript/term/striptermchars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Removes all special terminal characters from stream 3 | ## See also: strings, mimencode 4 | ## (Problem with 'strings', is that it also strips adjacent newlines.) 5 | # jsh-ext-depends: sed 6 | 7 | ## Alternative (didn't try it yet): 8 | # sed 's/\\033\[[0-9;m]*//g' 9 | 10 | ## Remove curses colour codes: 11 | sed -u 's+[^m]*m++g' | 12 | 13 | ## Remove other non-printing characters: 14 | sed -u 's+[^[:print:][:space:]]++g' 15 | 16 | -------------------------------------------------------------------------------- /code/shellscript/xwin/xtermsh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | COM="$@" 3 | 4 | TMPSH=`jgettmp "xtermsh.sh"` 5 | ( 6 | if test "$COM" = "" 7 | then cat 8 | else echo "$COM" 9 | fi 10 | ) > "$TMPSH" 11 | chmod a+x "$TMPSH" 12 | 13 | ## We bg garbage collection, in case the user Ctrl+C's the inline call 14 | (sleep 1m; jdeltmp "$TMPSH") & 15 | 16 | if xisrunning 17 | then 18 | # konsole -vt_sz 120x60 -nowelcome -caption "$1" -e sh "$TMPSH" & 19 | xterm -e "$TMPSH" & 20 | else 21 | "$TMPSH" 22 | fi 23 | -------------------------------------------------------------------------------- /code/shellscript/init/refreshbintoollinks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## DISABLED 4 | ## We now simply add $HOME/bin to their path in startj. 5 | 6 | exit 0 7 | 8 | ## This means all $JPATH/bin should move to $HOME/bin ok? 9 | 10 | ## WARNING: 11 | ## If you re-enable it, the `jwhich jfc` check used by jwatchcomp will fail 12 | 13 | cd "$JPATH/tools/" 14 | # "rm" * 15 | ln -sf ../bin/* . 16 | #FILES=`find "$JPATH/code/shellscript/" -name "*" | tr "\n" " "` 17 | #echo "$FILES" 18 | #ln -sf $FILES . 19 | -------------------------------------------------------------------------------- /code/shellscript/other/cksumall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if test "$1" = "--help"; then 3 | echo "cksumall [ [ ] ]" 4 | exit 1 5 | fi 6 | 7 | if test ! "$CKSUMCOM" 8 | then CKSUMCOM="cksum" 9 | fi 10 | 11 | # 'ls' -R "$@" | ls-Rtofilelist | 12 | find "$@" -type f | 13 | while read X 14 | do 15 | # ls -l "$X" 16 | "$CKSUMCOM" "$X" 17 | done 18 | # | sed 's#\([^ ]*\)[ ]*\([^ ]*\)[ ]*#\1 \2 #' 19 | # tr " " "\t" 20 | # sort -k 3 ## filename 21 | # sort -k 1,2 ## cksum 22 | -------------------------------------------------------------------------------- /code/shellscript/other/getcddbfromweb: -------------------------------------------------------------------------------- 1 | lynx -dump "$@" > $JPATH/tmp/cddb.webdump 2 | 3 | ARTIST=`cat $JPATH/tmp/cddb.webdump | grep "\[13\]" | after "\]" | before "/"` 4 | DTITLE=`cat $JPATH/tmp/cddb.webdump | grep "\[13\]" | after "/" | after "]"` 5 | echo "DTITLE=$ARTIST- $DTITLE" 6 | 7 | for N in `listnums 1 40`; do 8 | TTITLE=`cat $JPATH/tmp/cddb.webdump | grep " $N\. \[" | after "\]"` 9 | if [ ! "$TTITLE" = "" ]; then 10 | M=$[$N-1]; 11 | echo "TTITLE$M=$TTITLE" 12 | fi 13 | done -------------------------------------------------------------------------------- /code/shellscript/pkg/checksecuritypkgs-old.sh: -------------------------------------------------------------------------------- 1 | ## List all packages from Debian's security archive site: 2 | apt-list from security.debian.org | 3 | takecols 1 | 4 | 5 | ## For each of them, list installed version of package: 6 | while read PKG 7 | do verbosely apt-list -installed pkg "\<$PKG\>" 8 | done | 9 | 10 | ## Strip those installed packages which are already at security version (the same package as the security site's) 11 | grep -v "security.debian.org" # | 12 | 13 | # takecols 1 14 | 15 | -------------------------------------------------------------------------------- /code/shellscript/quines/quine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | l0="for n in \$(seq 0 2)" 3 | l1="do" 4 | l2=" val=\"\$(eval \"printf \\\"%s\\\" \\\"\\\$l\${n}\\\"\")\"" 5 | # END DATA 6 | echo '#!/bin/sh' 7 | for n in $(seq 0 2) 8 | do 9 | val="$(eval "printf \"%s\" \"\$l${n}\"" | sed 's+\\+\\\\\\\\+g')" 10 | printf "%s\n" "l${n}=\"$(printf "%s" "$val" | sed 's+\\+\\\\\\\\+g')\"" 11 | done 12 | for n in $(seq 0 2) 13 | do 14 | val="$(eval "printf \"%s\" \"\$l${n}\"")" 15 | printf "%s\n" "$val" 16 | done 17 | -------------------------------------------------------------------------------- /code/shellscript/indevelopment/splitatendofregexp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## Consider: avoid problems with \(s inside REGEXP by changing $RIGHT so that the last .* is only there when the right should be lost. 4 | 5 | if [ "$1" = -left ] 6 | then LEFT="\\1"; RIGHT= 7 | elif [ "$1" = -right ] 8 | then LEFT=; RIGHT="\\2" 9 | else 10 | error "Expects -left or -right" 11 | exit 1 12 | fi 13 | shift 14 | 15 | REGEXP="$1" 16 | shift 17 | 18 | cat "$@" | 19 | sed "s+\($REGEXP\|.*\)\(.*\)+$LEFT$RIGHT+" 20 | 21 | -------------------------------------------------------------------------------- /code/shellscript/other/myrenice: -------------------------------------------------------------------------------- 1 | ## XOL had a cronjob like this: 2 | # */10 * * * * renice -20 -u utserver >/dev/null 3 | ## How does that work? Is myrenice redundant?! 4 | 5 | if [ "$1" = -n ] ## originally not expected 6 | then shift 7 | fi 8 | 9 | PRI="$1" 10 | shift 11 | 12 | for JOB do findjob "$JOB"; done | grep -v renice | 13 | sed 's+^+# +' 14 | 15 | echo -n "renice $PRI -p " 16 | for JOB do findjob "$JOB"; done | grep -v renice | 17 | striptermchars | 18 | awk ' { printf($3" ") } ' 19 | echo 20 | -------------------------------------------------------------------------------- /code/shellscript/shext/require_exes.sh: -------------------------------------------------------------------------------- 1 | ## Source me from a bash-shebanged script (will not work from an sh-shebanged script) 2 | 3 | failed='' 4 | for EXE 5 | do 6 | 7 | if ! which "$EXE" >/dev/null 2>&1 # && [ ! "$OVERRIDE_REQUIRE_EXES" ] ## <-- CONSIDERING 8 | then 9 | 10 | echo "`curseyellow;cursebold`WARNING: `cursenorm`Required executable `cursered;cursebold`$EXE`cursenorm` is missing!" >&2 11 | failed=1 12 | 13 | fi 14 | 15 | done 16 | 17 | if [ "$failed" ] 18 | then exit 1 19 | fi 20 | -------------------------------------------------------------------------------- /code/shellscript/tex/dotexfindimgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ./dotex | tr "<" "\n" | tr ">" "\n" | grep -E "\.[eps|ps]" | grep -v "(" | sed "s+^images/++" 3 | 4 | while true; do echo; done | 5 | 6 | ./dotex 2>&1 | 7 | 8 | grep "Could not find figure file" | 9 | 10 | sed 's+.*Could not find figure file ++;s+; continuing++' | 11 | 12 | afterlast / | 13 | 14 | while read LOSTIMG 15 | do 16 | 17 | echo "### Seeking copy of $LOSTIMG" 18 | find ~/joey/phd/ -name "$LOSTIMG" -printf "%s %p\n" 19 | 20 | done 21 | -------------------------------------------------------------------------------- /code/shellscript/math/randomnumber.sh: -------------------------------------------------------------------------------- 1 | if [ "$2" ] 2 | then 3 | verbosely intseq "$1" 1 "$2" | chooserandomline 4 | else 5 | # verbosely seq 0.0 0.01 1.0 | chooserandomline 6 | NUM="4.0" 7 | for I in 1 2 3 8 | do 9 | # DD="-" 10 | # [ `randomnumber 1 2` = 1 ] && DD="+" 11 | DD=`chooserandom - +` 12 | DN=`chooserandom 0.125 0.5 1.0 1.5 2.0 3.0 2.5 4.0 8.0 16.0 256.0 512.0 640.0` 13 | # NUM=`calc "$NUM" "$D" "$RND" '*' "$M" 14 | NUM=`calc "$NUM" "$DD" "$DN"` 15 | done 16 | echo "$NUM" 17 | fi 18 | -------------------------------------------------------------------------------- /code/shellscript/other/comparedirfilesizes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # echo "Use comparedirsfilesize instead?" 3 | # This one does not recurse into directories, but will show if subdirectory size is different 4 | ( 5 | cd $1 6 | "ls" -l | awk ' { printf($5" "$9"\n") } ' > $JPATH/tmp.cdfs1.txt 7 | ) 8 | ( 9 | cd $2 10 | "ls" -l | awk ' { printf($5" "$9"\n") } ' > $JPATH/tmp.cdfs2.txt 11 | ) 12 | jfc $JPATH/tmp.cdfs1.txt $JPATH/tmp.cdfs2.txt 13 | # echo "COMMON:" 14 | # jfc common $JPATH/tmp.cdfs1.txt $JPATH/tmp.cdfs2.txt 15 | -------------------------------------------------------------------------------- /code/shellscript/vscode/vscode-do-not-truncate-types.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | find node_modules/ -name typescript.js | 5 | xargs -d '\n' grep -l 'var defaultMaximumTruncationLength = [0-9]*;' | 6 | while read file 7 | do sed -i 's/var defaultMaximumTruncationLength = [0-9]*;/var defaultMaximumTruncationLength = 1000;/' "$file" 8 | done 9 | 10 | # Show new version, for verification: 11 | find node_modules/ -name typescript.js | xargs -d '\n' grep 'var defaultMaximumTruncationLength = [0-9]*;' 12 | -------------------------------------------------------------------------------- /code/shellscript/modem/hwippp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-depends: ensure-ip-state 3 | 4 | case $1 in 5 | up) 6 | touch /var/hwi/orders/ensure-ip-up 7 | # chmod a+rw /var/hwi/orders/ensure-ip-up 8 | chown joey:joey /var/hwi/orders/ensure-ip-up 9 | [ "$UID" = 0 ] && ensure-ip-state 10 | ;; 11 | down) 12 | /bin/rm -f /var/hwi/orders/ensure-ip-up 13 | [ "$UID" = 0 ] && ensure-ip-state 14 | # killall -KILL pppd > /dev/null 2>&1 15 | ;; 16 | *) 17 | echo 'Do not know "$1"' 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /code/shellscript/other/crossproduct: -------------------------------------------------------------------------------- 1 | SETX="$1" 2 | SETY="$2" 3 | SEP="$3" 4 | 5 | if [ "$SETX" = "" -o "$SETY" = "" ]; then 6 | echo "crossproduct " 7 | echo " produces \"......\"" 8 | exit 1 9 | fi 10 | 11 | # Use default seperator " " if none specified 12 | if [ "$SEP" = "" ]; then 13 | SEP=" " 14 | fi 15 | 16 | OUTPUT="" 17 | for x in $1 ; do 18 | for y in $2 ; do 19 | OUTPUT="$OUTPUT$x$y$SEP" 20 | done 21 | done 22 | echo "$OUTPUT" -------------------------------------------------------------------------------- /code/shellscript/string/startswith.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$1" = --help ] 4 | then 5 | echo "startswith " 6 | echo " return status 0 means true, 1 means false." 7 | exit 123 8 | fi 9 | 10 | [ "$2" = "" ] || 11 | 12 | [ ! "${1#$2}" = "$1" ] 13 | 14 | ## Old method (actually matched regexps instead of strings): 15 | # RESULT=`echo "$1" | grep "^$2"` 16 | # if test "$RESULT" = ""; then 17 | # # echo "no" 18 | # exit 1 19 | # else 20 | # # echo "yes" 21 | # exit 0 22 | # fi 23 | -------------------------------------------------------------------------------- /code/shellscript/xwin/runacommand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Provides functionality like F2 in KDE and Gnome. 3 | ## I use "Mod1 F2 :ExecCommand runacommand" in my ~/.fluxbox/keys 4 | 5 | if [ ! "$1" = -2 ] 6 | then 7 | xterm -geometry 40x5 -font "-b&h-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-iso8859-1" -e runacommand -2 8 | else 9 | shift 10 | echo "Run what?" 11 | echo 12 | echo -n "% " 13 | cursegreen 14 | read TORUN 15 | cursenorm 16 | # echo "$TORUN" | bash & 17 | bigwin $TORUN 18 | sleep 1 19 | fi 20 | -------------------------------------------------------------------------------- /code/shellscript/other/jrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## Was this here for Solaris? #!/usr/local/bin/zsh 3 | 4 | # Derive j/ path from execution of this script: 5 | POSSJPATH=`dirname \`dirname "$0"\`` 6 | 7 | # Perform the search, with other guesses: 8 | for JPATH in "$JPATH" "$POSSJPATH" "$HOME"/j 9 | do 10 | if [ -x "$JPATH/startj" ] 11 | then 12 | . "$JPATH"/tools/startj-hwi simple 13 | "$@" 14 | exit 15 | fi 16 | done 17 | 18 | echo "jrun: Could not find your JPATH (directory containing startj)" >&2 19 | exit 1 20 | -------------------------------------------------------------------------------- /code/shellscript/HOWTO_USE_bashrc_bash_profile_and_profile.md: -------------------------------------------------------------------------------- 1 | Excellent answer here: https://unix.stackexchange.com/questions/192521/loading-profile-from-bash-profile-or-not-using-bash-profile-at-all#192550 2 | 3 | But here is the executive summary. 4 | 5 | - Put this in `.bash_profile` 6 | 7 | ```sh 8 | . ~/.profile 9 | case $- in *i*) . ~/.bashrc;; esac 10 | ``` 11 | 12 | - Put login-time things like environment variable definitions in `.profile` 13 | 14 | - Put things for interactive shells in `.bashrc` 15 | -------------------------------------------------------------------------------- /code/shellscript/cygwin/cygpkgsizes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd / 3 | 4 | 'ls' /etc/setup/*.lst.gz | sed 's+^/etc/setup/++;s+\.lst\.gz$++' | 5 | 6 | # cygcheck -c | takecols 1 | drop 2 | # chop 2 | 7 | 8 | while read PKG 9 | do 10 | printf "$PKG " 11 | gunzip -c /etc/setup/$PKG.lst.gz 2> /dev/null | 12 | grep -v '/$' | 13 | # while read FILE 14 | # do 15 | # if test -f "$FILE" 2> /dev/null; then 16 | # echo "$FILE" 17 | # fi 18 | # done | 19 | xargs du -S | 20 | takecols 1 | 21 | awksum 22 | done 23 | -------------------------------------------------------------------------------- /code/shellscript/string/stripbinary.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## An alternative to striptermchars, but not as good! 3 | 4 | ## Or is it keepascii.sh?! 5 | 6 | # TOKILL="" 7 | # ## We prolly wanna keep the DOS extra newline - what is it? 8 | # for X in `seq 0 9; seq 10 12; seq 14 31; seq 127 255` 9 | # do TOKILL= 10 | # 11 | # oh fuck it 12 | # 13 | # sed 's+ 14 | 15 | ## Good except for newlines: 16 | hexdump -C | 17 | sed 's+.*|\(.*\)|+\1+' | 18 | tr -d '\n' 19 | 20 | ## Another possibility: 21 | # sed 's+[^A-Za-z0-9_\-!"...]++g' 22 | -------------------------------------------------------------------------------- /code/shellscript/xwin/sloppycopy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## An alternative to scp, sloppycopy and sloppypaste allow you to transfer (small) files via two open xterms and unix copy/paste 3 | ## Files are checksummed in case of transfer-incompatability. 4 | ## But it should work fine because data will be (uu?) encoded to a generic charset. 5 | ## A clever header tells sloppypaste whether we are writing a single or multiple file(s). 6 | 7 | ## Oh of course I can just use uu(en|de)code 8 | 9 | for X 10 | do uuencode "$X" "$X" 11 | done 12 | -------------------------------------------------------------------------------- /code/shellscript/file/comparedirscksum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DIR_A="$1" 3 | DIR_B="$2" 4 | shift 5 | shift 6 | 7 | FILE_A=`jgettmp "$DIR_A"` 8 | FILE_B=`jgettmp "$DIR_B"` 9 | 10 | ( cd "$DIR_A" 11 | cksumall . "$@" 12 | ) > "$FILE_A" 13 | ( cd "$DIR_B" 14 | cksumall . "$@" 15 | ) > "$FILE_B" 16 | 17 | # diff "$FILE_A" "$FILE_B" 18 | 19 | echo "Files that are different:" 20 | jfcsh -bothways "$FILE_A" "$FILE_B" | sed 's+.*\./++' 21 | echo 22 | echo "Files that are the same:" 23 | jfcsh -common "$FILE_A" "$FILE_B" | sed 's+.*\./++' 24 | -------------------------------------------------------------------------------- /code/shellscript/fstools/fasttreeprofile.sh: -------------------------------------------------------------------------------- 1 | # jsh-ext-depends: find 2 | # For each file under given path, shows last-modified, last-accessed, 3 | # last-status-change, ownership, permission, size, path, and link target. 4 | if [ "$1" = -old ] 5 | then 6 | shift 7 | # find "$@" -printf "a=%A@ s=%C@ m=%T@ %u:%g %M %s \"%p\" [%l]\n" 8 | find "$@" -xdev -printf "a=%A@ s=%C@ m=%T@ %u:%g %M %s \"%p\" [%l]\n" 9 | else 10 | find "$@" -printf "m=%TY%Tm%Td-%TH%TM%TS a=%AY%Am%Ad-%AH%AM%AS s=%CY%Cm%Cd-%CH%CM%CS %u:%g %M %s \"%p\" [%l]\n" 11 | fi 12 | -------------------------------------------------------------------------------- /code/shellscript/image/normalize_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | infile="$1" 4 | 5 | outfile="$(printf "%s" "$infile" | sed 's+\(.*\)\.+\1.enhanced.+')" 6 | [ "$infile" = "$outfile" ] && outfile="$infile".enhanced.png 7 | 8 | convert -contrast "$infile" "$outfile" 9 | # Maybe 10 | #convert -enhance -contrast "$infile" "$outfile" 11 | # Unlikely! Even on its own, -equalize will tend to "invent" ugly colours when processing dark images. 12 | #convert -enhance -equalize -contrast "$infile" "$outfile" 13 | 14 | touch -r "$infile" "$outfile" 15 | -------------------------------------------------------------------------------- /code/shellscript/other/getwinbookmarks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "" 3 | echo "" 4 | 5 | find /mnt/filfirin/windows/Favorites -name "*.url" > $JPATH/tmp/getwinbms.tmp 6 | 7 | exec < $JPATH/tmp/getwinbms.tmp 8 | while read FILE; do 9 | NAME=`echo "$FILE" | after "Favorites/" | before ".url$"` 10 | URL=`cat "$FILE" | grep "^URL=" | after "=" | stringtrim` 11 | # echo "NAME=$NAME" 12 | # echo "URL=$URL" 13 | echo ''"$NAME"'' 14 | echo '
' 15 | done 16 | 17 | echo "" 18 | echo "" 19 | -------------------------------------------------------------------------------- /code/shellscript/dirhistory/dirhistorysetup.bash: -------------------------------------------------------------------------------- 1 | # My dirhistory tool 2 | # You need to source this in your ~/.rc 3 | 4 | # For zsh: 5 | # Uses `s instead of source and export 6 | # Does not support searching 'cos I can't pass the argument! 7 | 8 | # NOTE: I actually use dirhistorysetup.zsh for both bash and zsh now. 9 | # TODO: DELETEME 10 | 11 | alias cd='`$JPATH/tools/d.zsh`' 12 | alias d='`$JPATH/tools/d.zsh`' 13 | alias f='`$JPATH/tools/f.zsh`' 14 | alias b='`$JPATH/tools/b.zsh`' 15 | 16 | # Is it possible to use source and cd? 17 | -------------------------------------------------------------------------------- /code/shellscript/file/absolutepath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jsh-ext-depends-ignore: file 3 | # jsh-depends: isabsolutepath 4 | 5 | # Alternative: ( cd "$1" && pwd ) 6 | 7 | if test "$1" = ""; then 8 | echo "absolutepath " 9 | echo " or" 10 | echo "absolutepath " 11 | exit 1 12 | fi 13 | 14 | if test "$2" = ""; then 15 | PARENT="$PWD" 16 | FILE="$1" 17 | else 18 | PARENT="$1" 19 | FILE="$2" 20 | fi 21 | 22 | if isabsolutepath "$FILE"; then 23 | echo "$FILE" 24 | else 25 | echo "$PARENT/$FILE" 26 | fi 27 | --------------------------------------------------------------------------------