#"BEGINNING" ; placed here for easy search to get to top of the file if #editing using the command-line. Use "LASTLINE" if searching for the #last line. If using 'nano', CTRL+w is used for searching. #IF ANYONE OTHER THAN THE ORIGINAL AUTHOR IS MAKING USE OF THIS PROFILE, #MAKE SURE TO PAY ATTENTION TO ANY NOTES AND FILE LOCATIONS AS YOU MAY #NEED TO MAKE A FEW EDITS. VISIT THEOUTERLINUX WEBSITE FOR LINKS TO #SOFTWARE IF HAVING A HARD TIME FINDING THEM. AND YES, THERE ARE #PACAKGE MANAGERS LIKE 'MACPORTS', BUT THESE SORT OF THINGS EVENTUALLY #FAIL WHILE THE FOLLOWING CAN BE INSTALLED USING A MODERN COMPUTER AND A #PORTABLE HARD DRIVE. TURN BACK THE SYSTEM DATE IF A PKG INSTALLATION #FAILS BEFORE GIVING UP; CHANGE IT BACK AFTERWARDS. #Put together by TheOuterLinux (https://theouterlinux.gitlab.io) #System target: Mac OS X 10.6.8 (Snow Leopard) for 32-bit Intel #Last updated: 2025/06/11 #This file was created for use with 'Terminal.app' that is included with #Mac OS X. Rename this file so as to be installed as "~/.profile" Adding #the dot to the beginning of files hides them from normal view within #the current directory. You can also just copy/paste what appeals to you #to the "~/.profile" that already exists. #HOWEVER, if using 'iTerm', rename this file so as to be installed as #"~/.bashrc"; this file may not already be there as Terminal.app expects #to use "~/.profile" instead. #########################[PATHS AND EXPORTS]############################ #For local binaries... export PATH="~/.local/bin:$PATH" # MacPorts Installer addition on 2023-11-27_at_18:42:11: adding an appropriate PATH variable for use with MacPorts. export PATH="/opt/local/bin:/opt/local/sbin:/Applications/bB:$PATH" # Finished adapting your PATH environment variable for use with MacPorts. # Also, notice the "bB" part; this is if you have the batariBASIC folder ("bB") in your Applications directory. # Setting PATH for Python 2.7 # The original version is saved in .profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export PATH # Setting PATH for Python 3.5 # The original version is saved in .profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}" export PATH # Setting PATHs for ImageMagick export MAGICK_HOME="/Applications/ImageMagick-6.5.5" export PATH="$MAGICK_HOME/bin:${PATH}" export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib" # Add color in manpages for less export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' # Colors for all grep commands such as grep, egrep and zgrep export GREP_OPTIONS='--color=auto' # Git Installer addition: adding an appropriate PATH variable for use with Git. export PATH="/opt/macports-git/bin:/opt/macports-git/sbin:$PATH" # Finished adapting your PATH environment variable for use with Git. ######################################################################## #When using the 'locate' command on modern GNU/Linux systems, #the 'locate' command looks at what is in a database to quickly find #files; 'sudo updatedb' is what is used to update that databse. #It is usually NOT a good idea to include 'sudo' in an alias or function. alias updatedb='/usr/libexec/locate.updatedb' #Install 7zX.app to get the following aliases to work... alias 7z='/Applications/7zX.app/Contents/Resources/7za' alias growlnotify='/Applications/7zX.app/Contents/Resources/growlnotify' #This is just for the GNU/Linux users; do not expect things to work the #same way if supplying arguments. 'afplay' is included with Leopard and #newer. 'arec' will require SoX to be installed; quality lowered to save #hard drive space and this is usually the default for 'arec'. alias aplay=afplay alias arec='rec -c 1 -r 8000 -e unsigned-integer -b 16000' #Install Aquamacs.app to get the following aliases to work... alias ebrowse='/Applications/Aquamacs\ Emacs/Aquamacs.app/Contents/MacOS/bin/ebrowse' #Install Ardour v6.7.0 to get the following aliases to work... #This will give you ffmpeg v3.4.5 (~2018) alias ffmpeg='/Applications/Ardour.app/Contents/MacOS/ffmpeg_harvid' alias ffprobe='/Applications/Ardour.app/Contents/MacOS/ffprobe_harvid' #Install Boxer.app to get the following aliases to work... alias toc2cue='/Applications/Emulation/DOS/Boxer.app/Contents/Resources/toc2cue' #Install Blender 2.79b to get the following aliases to work... alias blender='/Applications/Blender/Blender\ 2.79b/Blender\ 2.79b.app/Contents/MacOS/blender' #Install the Burn.app to get the following aliases to work... alias dvda-author='/Applications/Burn.app/Contents/Resources/dvda-author' alias dvdauthor='/Applications/Burn.app/Contents/Resources/dvdauthor' alias iso8859-1='/Applications/Burn.app/Contents/Resources/iso8859-1' alias mkisofs='/Applications/Burn.app/Contents/Resources/mkisofs' alias movtowav='/Applications/Burn.app/Contents/Resources/movtowav' alias movtoy4m='/Applications/Burn.app/Contents/Resources/movtoy4m' alias spumux='/Applications/Burn.app/Contents/Resources/spumux' alias vcdimager='/Applications/Burn.app/Contents/Resources/vcdimager' #Install Chipmunk Basic to get the following aliases to work... alias basic='/Applications/Chipmunk\ Basic/basic' #Install CMake 2.8-12.app to get the following aliases to work... alias ccmake='/Applications/CMake\ 2.8-12.app/Contents/bin/ccmake' alias cpakc='/Applications/CMake\ 2.8-12.app/Contents/bin/cpack' alias ctest='/Applications/CMake\ 2.8-12.app/Contents/bin/ctest' #Install DCDIB (Dreamcast CDI disc burner) to get these aliases to work... alias btcflash='/Applications/DCDIB.app/bin/btcflash' alias cdda2wav='/Applications/DCDIB.app/bin/cdda2wav' alias cdirip='/Applications/DCDIB.app/bin/cdirip' alias cdrecord='/Applications/DCDIB.app/bin/cdrecord' alias devdump='/Applications/DCDIB.app/bin/devdump' alias isodebug='/Applications/DCDIB.app/bin/isodebug' alias isodump='/Applications/DCDIB.app/bin/isodump' alias isoinfo='/Applications/DCDIB.app/bin/isoinfo' alias isovfy='/Applications/DCDIB.app/bin/isovfy' alias mkhybrid='/Applications/DCDIB.app/bin/mkhybrid' alias readcd='/Applications/DCDIB.app/bin/readcd' alias scgcheck='/Applications/DCDIB.app/bin/scgcheck' alias scgskeleton='/Applications/DCDIB.app/bin/scgskeleton' #Install DVDStyler.app to get the following aliases to work... alias dvdauthor='/Applications/DVDStyler/DVDStyler.app/Contents/MacOS/dvdauthor' alias mkisofs='/Applications/DVDStyler/DVDStyler.app/Contents/MacOS/mkisofs' alias mplex='/Applications/DVDStyler/DVDStyler.app/Contents/MacOS/mplex' alias spumux='/Applications/DVDStyler/DVDStyler.app/Contents/MacOS/spumux' #Install Mednafen CLI to get the following aliases to work... alias mednafen='/Applications/Emulation/All-in-One/Mednafen\ CLI/mednafen' #Install MessMenu.app to get the following aliases to work... alias castool='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/castool' alias chdman='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/chdman' alias floptool='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/floptool' alias imgtool='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/imgtool' alias jedutil='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/jedutil' alias ldresample='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/ldresample' alias ldverify='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/ldverify' alias mess='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/mess' alias regrep='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/regrep' alias romcmp='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/romcmp' alias scr2html='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/src2html' alias srcclean='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/srcclean' alias testkeys='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/testkeys' alias unidasm='/Applications/Emulation/All-in-One/MESS/MessMenu.app/Contents/Resources/unidasm' #Install DOSBox Magebuild 6 for the following aliases to work... alias dosbox='/Applications/Emulation/DOS/DOSBox\ Megabuild\ 6/DOSBox\ MB6.app/Contents/MacOS/DOSBox' #Install Mupen64Plus for the following aliases to work... alias mupen64plsu='/Applications/Emulation/N64/Mupen64Plus/mupen64plus.app/Contents/MacOS/mupen64plus' #Install FileZilla.app for the following aliases to work... alias filezilla='/Applications/FileZilla.app/Contents/MacOS/filezilla' alias fzputtygen='/Applications/FileZilla.app/Contents/MacOS/fzputtygen' alias fzsftp='/Applications/FileZilla.app/Contents/MacOS/fzsftp' #Install Firefox.app for the following aliases to work... alias firefox='/Applications/Firefox.app/Contents/MacOS/firefox-bin' #Install Gnucash for the following aliases to work... alias aqbanking-cli='/Applications/Gnucash/Gnucash.app/Contents/MacOS/aqbanking-cli' alias aqebics-tool='/Applications/Gnucash/Gnucash.app/Contents/MacOS/aqebics-tool' alias aqhbci-tool4='/Applications/Gnucash/Gnucash.app/Contents/MacOS/aqhbci-tool4' alias chipcard-tool='/Applications/Gnucash/Gnucash.app/Contents/MacOS/chipcard-tool' alias gnucash='/Applications/Gnucash/Gnucash.app/Contents/MacOS/Gnucash-bin' #Install Godot.app to get the following aliases to work... alias godot='/Applications/Godot.app/Contents/MacOS/Godot' #Install GrafX2.app to get the following aliases to work... alias grafx2='/Applications/Grafx2.app/Contents/MacOS/Grafx2' #Install Gretl.app to get the following aliases to work... alias gnuplot='/Applications/Gretl.app/Contents/Resources/bin/gnuplot' alias gretlcli='/Applications/Gretl.app/Contents/Resources/bin/gretlcli' #Install Hydrogen.app to get the following aliases to work... alias hydrogen='/Applications/Hydrogen\ 0.9.6.app/Contents/MacOS/hydrogen' #Install Inkscape.app to get the following aliases to work... alias inkscape='/Applications/Inkscape.app/Contents/Resources/bin/inkscape-bin' #Install iSteg.app to get the following aliases to work... alias outguess='/Applications/iSteg.app/Contents/Resources/outguess' #Install Jadeo (comes with Ardour) for the following aliases to work... alias jadeo='/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin' alias xjremote='/Applications/Jadeo.app/Contents/MacOS/xjremote' #Install jpdfbookmarks-2.5.2 to get the following aliases to work... alias jpdfbookmarks='/Applications/jpdfbookmarks-2.5.2/jpdfbookmarks_cli' #Install KBasic to get the following aliases to work... alias kbc='/Applications/KBasic/KBasic.app/Contents/MacOS/kbc' alias krun='/Applications/KBasic/KBasic.app/Contents/MacOS/kbrun' #Install kdiff3.app to get the following aliases to work... alias kdiff3='/Applications/kdiff3.app/Contents/MacOS/kdiff3' #Install KompoZer.app to get the following aliases to work... alias kompozer='/Applications/KompoZer.app/Contents/MacOS/kompozer-bin' #Install Lazarus to get the following aliases to work... alias lazarus='/Developer/lazarus/lazarus' alias lazbuild='/Developer/lazarus/lazbuild' alias startlazarus='/Developer/lazarus/startlazarus' #Install LibreOffice.app to get the following aliases to work... alias gengal='/Applications/LibreOffice.app/Contents/MacOS/gengal' alias senddoc='/Applications/LibreOffice.app/Contents/MacOS/senddoc' alias soffice='/Applications/LibreOffice.app/Contents/MacOS/soffice' function 2abw(){ soffice --headless --convert-to abw "$1" --outdir "$(dirname "$1")" ; } function 2csv(){ soffice --headless --convert-to csv "$1" --outdir "$(dirname "$1")" ; } function 2dbf(){ soffice --headless --convert-to dbf "$1" --outdir "$(dirname "$1")" ; } function 2dif(){ soffice --headless --convert-to dif "$1" --outdir "$(dirname "$1")" ; } function 2doc(){ soffice --headless --convert-to doc "$1" --outdir "$(dirname "$1")" ; } function 2docx(){ soffice --headless --convert-to docx "$1" --outdir "$(dirname "$1")" ; } function 2epub(){ ebook-convert "$1" "${1%.*}.epub" ; } function 2fodg(){ soffice --headless --convert-to fodg "$1" --outdir "$(dirname "$1")" ; } function 2fodp(){ soffice --headless --convert-to fodp "$1" --outdir "$(dirname "$1")" ; } function 2fods(){ soffice --headlesss --convert-to fods "$1" --outdir "$(dirname "$1")" ; } function 2fodt(){ soffice --headless --convert-to fodt "$1" --outdir "$(dirname "$1")" ; } function 2odf(){ soffice --headless --convert-to odf "$1" --outdir "$(dirname "$1")" ; } function 2odg(){ soffice --headless --convert-to odg "$1" --outdir "$(dirname "$1")" ; } function 2odp(){ soffice --headless --convert-to odp "$1" --outdir "$(dirname "$1")" ; } function 2ods(){ soffice --headless --convert-to ods "$1" --outdir "$(dirname "$1")" ; } function 2odt(){ soffice --headless --convert-to odt "$1" --outdir "$(dirname "$1")" ; } function 2html(){ soffice --headless --convert-to html "$1" --outdir "$(dirname "$1")" ; } function topdf(){ ebook-convert "$1" "${1%.*}.pdf" ; } function 2pps(){ soffice --headless --convert-to pps "$1" --outdir "$(dirname "$1")" ; } function 2ppsx(){ soffice --headless --convert-to ppsx "$1" --outdir "$(dirname "$1")" ; } function 2ppt(){ soffice --headless --convert-to ppt "$1" --outdir "$(dirname "$1")" ; } function 2pptx(){ soffice --headless --convert-to pptx "$1" --outdir "$(dirname "$1")" ; } function 2rtf(){ soffice --headless --convert-to rtf "$1" --outdir "$(dirname "$1")" ; } function 2slk(){ soffice --headless --convert-to slk "$1" --outdir "$(dirname "$1")" ; } function 2txt(){ soffice --headless --convert-to txt "$1" --outdir "$(dirname "$1")" ; } function 2uop(){ soffice --headless --convert-to uop "$1" --outdir "$(dirname "$1")" ; } function 2uos(){ soffice --headless --convert-to uos "$1" --outdir "$(dirname "$1")" ; } function 2uot(){ soffice --headless --convert-to uot "$1" --outdir "$(dirname "$1")" ; } function 2xls(){ soffice --headless --convert-to xls "$1" --outdir "$(dirname "$1")" ; } function 2xlsx(){ soffice --headless --convert-to xlsx "$1" --outdir "$(dirname "$1")" ; } function 2xml(){ soffice --headless --convert-to xml "$1" --outdir "$(dirname "$1")" ; } #Install VLC to get the following aliases to work... alias vlc='/Applications/VLC.app/Contents/MacOS/VLC' #Install Love-0.8.0.app to get the following aliases to work... alias love='/Applications/Love-0.8.0.app' #Install LyX to get the following aliases to work... alias lyx='/Applications/LyX.app/Contents/MacOS/lyx' alias tex2lyx='/Applications/LyX.app/Contents/MacOS/tex2lyx' #Install 'MPlayer OSX Extender' for the following alias to work. #This is so far the latest version of an mplayer binary that I could find. alias mplayer='/Applications/MPlayer\ OSX\ Extended.app/Contents/Resources/Binaries/mpextended.mpBinaries/Contents/MacOS/mplayer' #Install Synfig Studio to get the following aliases to work... alias any2djvu='/Applications/SynfigStudio.app/Contents/Resources/bin/any2djvu' alias anytoppm='/Applications/SynfigStudio.app/Contents/Resources/bin/anytopnm' alias dvipdf='/Applications/SynfigStudio.app/Contents/Resources/bin/dvipdf' alias eps2eps='/Applications/SynfigStudio.app/Contents/Resources/bin/eps2eps' alias gettextize='/Applications/SynfigStudio.app/Contents/Resources/bin/gettextize' #Install Octave to get the following aliases to work... alias octave='/Applications/Octave/Octave.app/Contents/Resources/bin/octave' #Install OHRRPGCE to get the following aliases to work... alias madplay='/Applications/OHRRPGCE/Stable\ -\ 2020-05-02\ \(Gargonzola\)/OHRRPGCE-Custom.app/Contents/MacOS/support/madplay' alias oggenc='/Applications/OHRRPGCE/Stable\ -\ 2020-05-02\ \(Gargonzola\)/OHRRPGCE-Custom.app/Contents/MacOS/support/oggenc' #Install qGo to get the following aliases to work... alias gnugo='/Applications/qGo.app/Contents/MacOS/gnugo' #Install SDLJoyTest-osx to get the following aliases to work... alias testjoystick='/Applications/SDLJoyTest-osx/testjoystick' #Install ZDoom to get the following aliases to work... alias zdoom='/Applications/Source-Ports/DOOM/ZDoom.app/Contents/MacOS/zdoom' #ZDoom runs better than the latest GZDoom I could find alias gzdoom='/Applications/Source-Ports/DOOM/ZDoom.app/Contents/MacOS/zdoom' #Install EDuke32 to get the following aliases to work... alias eduke32='/Applications/Source-Ports/Eduke32/Duke\ Nukem\ 3D\ Atomic\ Edition.app/Contents/MacOS/eduke32' alias mapster32='/Applications/Source-Ports/Eduke32/Mapster32.app/Contents/MacOS/mapster32' #Install Wolf4SDL to get the following aliases to work... alias wolf4sdl='/Applications/Source-Ports/Wolfenstein/Wolf4SDL.app/Contents/MacOS/Wolf4SDL' #Install uif2iso to get the following aliases to work... alias nrg2iso='/Applications/uif2iso/uif2iso4mac.app/Contents/Resources/nrg2iso' alias uif2iso='/Applications/uif2iso/uif2iso4mac.app/Contents/Resources/uif2iso' #Install VeraCrypt to get the following aliases to work... alias veracrypt='/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt' #Install Wireshark to get the following aliases to work... #However, Wireshark does also install other command-line tools... alias captype='/Applications/Wireshark.app/Contents/MacOS/captype' alias reordercap='/Applications/Wireshark.app/Contents/MacOS/reordercap' alias tfshark='/Applications/Wireshark.app/Contents/MacOS/tfshark' #Sort directories by size; helps to know what is taking up the most space alias sbs='du -h -d 1 | sort -nr' #File conversion stuff; make sure to have 'ffmpeg' and 'convert' already #setup above this line. The 'convert' command comes from ImageMagick. function 2aac(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.aac" ; } function 2aif(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.aif" ; } function 2avi(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.avi" ; } function 2avi480p() { ffmpeg -hide_banner -threads 0 -i "$1" -vf 'scale=trunc(oh*a/2)*2:480' -b:v 600k -maxrate 600k -ar 22050 -c:a pcm_s16le -passlogfile "/tmp/ffmpeg.log" -pass 1 "${1%.*}.avi"; } function 2doswav() { ffmpeg -hide_banner -threads 0 -i "$1" -ar 11025 -acodec pcm_u8 -ac 1 "${1%.*}_DOS.WAV" ; } function 2doswav8() { ffmpeg -hide_banner -threads 0 -i "$1" -ar 8000 -acodec pcm_u8 -ac 1 "${1%.*}_DOS.WAV" ; } function 2doswav11() { ffmpeg -hide_banner -threads 0 -i "$1" -ar 11025 -acodec pcm_u8 -ac 1 "${1%.*}_DOS.WAV" ; } function 2flac(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.flac" ; } function 2flv(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.flv" ; } function 2h265() { ffmpeg -hide_banner -threads 0 -i "$1" -c:v libx265 "${1%.*}_h265.mp4" ; } function 2mkv(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mkv" ; } function 2mov(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mov" ; } function 2mp3(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mp3" ; } function 2mp4(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mp4" ; } function 2mpg(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mpg" ; } function 2mpeg(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.mpeg" ; } function 2oga(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.oga" ; } function 2ogg(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.ogg" ; } function 2ogv(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.ogv" ; } function 2opus() { ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}_temp.wav" && opusenc --bitrate 2K --hard-cbr --downmix-mono "${1%.*}_temp.wav" "${1%.*}.opus" && rm "${1%.*}_temp.wav" ; } function 2voc(){ ffmpeg -hide_banner -threads 0 -i "$1" -ar 11025 -acodec pcm_u8 -ac 1 "${1%.*}.voc" ; } function 2voc8() { ffmpeg -hide_banner -threads 0 -i "$1" -ar 8000 -acodec pcm_u8 -ac 1 "${1%.*}.voc" ; } function 2voc11() { ffmpeg -hide_banner -threads 0 -i "$1" -ar 11025 -acodec pcm_u8 -ac 1 "${1%.*}.voc" ; } function 2wav(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.wav" ; } function 2webm() { ffmpeg -hide_banner -threads 0 -i "$1" -c:v libvpx "${1%.*}.webm" ; } function 2wma(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.wma" ; } function 2wmv(){ ffmpeg -hide_banner -threads 0 -i "$1" "${1%.*}.wmv" ; } #The following are for converting a video to a DVD-ready MPEG format #for faster use with DVD creation programs. Use the "sub" versions #below to permanently overlay subtitles (*.srt) onto the video. The #output is automatically handled for you by placing the file in the same #directory with the same name but with "_NTSC" or "_PAL" appended to the #end. # # Normal usage example: 2mpgNTSC input.ext # Usage for subtitle overlay example: 2mpgNTSCsub input.ext input.srt # function 2mpgNTSC() { fname="$(basename $1)"; ffmpeg -hide_banner -threads 0 -i "$1" -i "$1" -map 1:0 -map 0:1 -y -target ntsc-dvd -sn -g 12 -bf 2 -strict 1 -ac 2 -aspect 1.7777777777777777 -trellis 0 -mbd 0 -b:a 224k -b:v 9000k -passlogfile "/tmp/$fname.log" -pass 1 "${1%.*}_NTSC.mpg" ; } function 2mpgNTSCsub() { fname="$(basename $1)"; ffmpeg -hide_banner -threads 0 -i "$1" -i "$1" -map 1:0 -map 0:1 -y -vf subtitles="$2" -target ntsc-dvd -sn -g 12 -bf 2 -strict 1 -ac 2 -aspect 1.7777777777777777 -trellis 0 -mbd 0 -b:a 224k -b:v 9000k -passlogfile "/tmp/$fname.log" -pass 1 "${1%.*}_NTSC.mpg" ; } function 2mpgNTSC_VCD(){ fname="$(basename $1)"; ffmpeg -i "$1" -i "$1" -map 1:0 -map 0:1 -vf scale=352:240 -y -c:v mpeg1video -c:a mp2 -b:v 1150000 -b:a 224000 -f vcd -r 30000/1001 -g 18 -s 352x240 -maxrate:v 1150000 -minrate:v 1150000 -bufsize 327680 -packetsize 2324 -muxrate 1411200 -ar 44100 -sn -bf 2 -strict 1 -ac 2 -aspect 1.3333333333333333 -trellis 1 -mbd 2 -passlogfile "/tmp/$fname.log" -pass 1 "${1%.*}.mpg" ; } function 2mpgPAL() { fname="$(basename $1)"; ffmpeg -hide_banner -threads 0 -i "$1" -i "$1" -map 1:0 -map 0:1 -y -target pal-dvd -sn -g 12 -bf 2 -strict 1 -ac 2 -aspect 1.7777777777777777 -trellis 0 -mbd 0 -b:a 224k -b:v 9000k -passlogfile "/tmp/$fname.log" -pass 1 "${1%.*}_PAL.mpg" ; } function 2mpgPALsub() { fname="$(basename $1)"; ffmpeg -hide_banner -threads 0 -i "$1" -i "$1" -map 1:0 -map 0:1 -y -vf subtitles="$2" -target pal-dvd -sn -g 12 -bf 2 -strict 1 -ac 2 -aspect 1.7777777777777777 -trellis 0 -mbd 0 -b:a 224k -b:v 9000k -passlogfile "/tmp/$fname.log" -pass 1 "${1%.*}_NTSC.mpg" ; } function 2bmp(){ convert "$1" BMP:"${1%.*}.bmp" ; } function 2bmp2(){ convert "$1" BMP2:"${1%.*}.bmp" ; } function 2bmp3(){ convert "$1" BMP3:"${1%.*}.bmp" ; } function 2c64(){ convert "$1" "${1%.*}.c64" ; } function 2cel(){ convert "$1" "${1%.*}.cel" ; } function 2cm5(){ convert "$1" "${1%.*}.cm5" ; } function 2cpc(){ convert "$1" "${1%.*}.cpc" ; } function 2dosbmp() { convert "$1" -colors 16 -depth 4 -dither none -resize 640x480 BMP3:"${1%.*}_DOS.bmp" ; } function 2dosgif() { convert "$1" -colors 256 -dither none -resize 320x200\! GIF87:"${1%.*}_DOS.gif" ; } #function 2gif(){ convert "$1" GIF87:"${1%.*}.gif" ; } #87a is not animated function 2ico() { convert -background transparent "$1" -define icon:auto-resize=16,32,48,64,128 "${1%.*}.ico" ; } function 2img(){ convert "$1" "${1%.*}.img" ; } function 2jp2(){ convert "$1" "${1%.*}.jp2" ; } function 2jpg(){ convert "$1" "${1%.*}.jpg" ; } function 2jpeg(){ convert "$1" "${1%.*}.jpeg" ; } function 2kcf(){ convert "$1" "${1%.*}.kcf" ; } function 2lbm(){ convert "$1" "${1%.*}.lbm" ; } function 2neo(){ convert "$1" "${1%.*}.neo" ; } function 2pc1(){ convert "$1" "${1%.*}.pc1" ; } function 2pct(){ convert "$1" "${1%.*}.pct" ; } function 2pcx(){ convert "$1" -colors 256 "${1%.*}.pcx" ; } function 2pdf(){ convert "$1" "${1%.*}.pdf" ; } function 2pgm(){ convert "$1" "${1%.*}.pgm" ; } function 2pi1(){ convert "$1" "${1%.*}.pi1" ; } function 2pict(){ convert "$1" "${1%.*}.pict" ; } function 2pkm(){ convert "$1" "${1%.*}.pkm" ; } function 2png(){ convert "$1" "${1%.*}.png" ; } function 2png8(){ convert "$1" "${1%.*}.png8" && mv -f "${1%.*}.png8" "${1%.*}.png" ; } function 2ppm(){ convert "$1" "${1%.*}.ppm" ; } function 2tif(){ convert "$1" "${1%.*}.tif" ; } function 2tiff(){ convert "$1" "${1%.*}.tiff" ; } function 2xpm(){ convert "$1" "${1%.*}.xpm" ; } #If input is a video, convert use '2gif' to created an animated #(89a) GIF; otherwise, use ImageMagick to create a still (87a) GIF. # # Usage example: 2gif '/path/to/image/or/video.ext' # function 2gif() { if [ ! -d "/tmp/2gif" ]; then mkdir "/tmp/2gif"; fi if [ ${1: -4} == ".mp4" ] || [ ${1: -4} == ".mov" ] || [ ${1: -4} == ".avi" ] || [ ${1: -4} == ".flv" ] || [ ${1: -4} == ".mpg" ] || [ ${1: -5} == ".webm" ] then ffmpeg -hide_banner -threads 0 -i "$1" -r 10 -vf 'scale=trunc(oh*a/2)*2:480' /tmp/2gif/out%04d.png convert -delay 1x10 "/tmp/2gif/*.png" -fuzz 2% +dither -coalesce -layers OptimizeTransparency +map "${1%.*}.gif" else convert "$1" GIF87:"${1%.*}.gif" fi if [ -d "/tmp/2gif" ]; then rm -r "/tmp/2gif"; fi } #Install Midnight Commander to get the following aliases to work... #The version that makes this work is for Leopard PPC but tested on #32-bit Intel Snow Leopard with Rosetta installed. alias mc='/Applications/MC' #Install xACT v2.25 to get the following aliases to work... #Commented aliases means that a newer version was already installed #on my system via some other means but I am placing these versions #just in case. alias AtomicParsley='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/AtomicParsley' alias atomicparsley=AtomicParsley #alias sox='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/sox' #alias cdda2wav='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/cdda2wav' alias dvda='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/dvda' alias flac='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/flac' alias lame='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/lame' alias mac='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/mac' alias metaflac='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/metaflac' alias opusenc='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/opusenc' alias shntool='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/shntool' alias shorten='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/shorten' alias ttaenc='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/ttaenc' alias wavpack='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/wavpack' alias wvunpack='/Applications/xACT\ 2.25/xACT.app/Contents/Resources/wvunpack' #Install PS3 Media Server to get the following aliases to work... #This app also includes ffmpeg, flac, mplayer, and mencoder but are #not the latest versions possible based on this ~/.profile. alias dcraw='/Applications/PS3\ Media\ Server.app/Contents/Resources/Java/osx/dcraw' alias tsmuxer='/Applications/PS3\ Media\ Server.app/Contents/Resources/Java/osx/tsMuxeR' #Install TextWrangler for the following aliases to work... alias readtags='/Applications/TextWrangler.app/Contents/Helpers/readtags' alias twdiff='/Applications/TextWrangler.app/Contents/Helpers/twdiff' alias twfind='/Applications/TextWrangler.app/Contents/Helpers/twfind' #Install 'pyradio' for the following aliases to work... alias pyradio="pyradio -s ~/Music/pyradio.csv" #Use the following aliases to make 'nano' more programmer/writer friendly... alias nano="nano -m -c -E -U -W --tabsize=4 --autoindent" alias writer="nano -b -c -E -m -U -c -W -l --tabsize=4 --fill=72 --autoindent" # Print a word from a certain column of the output when piping. # Example: cat /path/to/file.txt | fawk 2 # This example prints every 2nd word on each line of file.txt function fawk { first="awk '{print " last="}'" cmd="${first}\$${1}${last}" eval $cmd } #Print the last line of all logs within the "/var/log" directory alias logs="find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f" #Expand current directory structure in tree form alias treed="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'" #Use the following for when the boss comes around to look busy... #But remember, as mentioned before, the /dev/urandom may cause some #serious slow-down issues on older/lighter hardware. alias busy="cat /dev/urandom | hexdump -C | grep 'ca fe'" #Grab a pretty ascii forecast picture for anywhere; without arguments, #uses ISP location to print your weather. Example: weather New York, NY function weather() { curl -s http://wttr.in/$1; } #Convert hex data file to a binary function hex2bin() { s=${@^^}; for i in $(seq 0 1 $((${#s}-1))); do printf "%04s" `printf "ibase=16; obase=2; ${s:$i:1};\n" | bc` ; done; printf "\n"; } #Create a randomized playlist for audio and video recursively # # Usage: cd '/path/to/music/or/video/directory' && playlist # alias playlist="find -D tree . | sort -R --random-source=/dev/urandom > playlist.m3u" #Potentially lower an image's file size using ImageMagick by lowering #the amount of colors, using dithering, increasing contrast, etc... # # Usage: optimg '/path/to/image.ext' # function optimg() { convert "$1" -dither FloydSteinberg -colors 256 -morphology Thicken:0.5 '3x1+0+0:1,0,0' -remap netscape: -ordered-dither o8x8,6 +contrast "$1_converted" ; } #Potentially lower a PDF's file size using Ghostscript # # Usage: optpdf '/path/to/file.pdf' # function optpdf() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile="${1%.*}_small.pdf" "$1" ; } #Convert a PDF to a different version; pdfto11 = 1.1; pdfto12 = 1.2; etc... # # Usage Example: pdfto13 input.pdf output.pdf # function pdfto11() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.1 -sOutputFile="$2" "$1" ; } function pdfto12() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -sOutputFile="$2" "$1" ; } function pdfto13() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -sOutputFile="$2" "$1" ; } function pdfto14() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile="$2" "$1" ; } function pdfto15() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -sOutputFile="$2" "$1" ; } function pdfto16() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -sOutputFile="$2" "$1" ; } function pdfto17() { gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.7 -sOutputFile="$2" "$1" ; } #Use the following functions to create an encrypted PDF from all of the #the images in the current directory. Start with 'img2pdfenc' and if #you get an "Invalid" error, use the 'img2pdfcheck' function to go #through each image and print the file-names associated with the error #as 'img2pdf' annoying does not do this for you; echo "$i" helps; the #'img2pdfcheck' function will take a long time if you have a lot of #images; it uses a FOR-LOOP, so it does not check recursively. If you #already have a PDF you want to encrypt, run the 'pdf2enc' function. # # Usage Example: img2pdfcheck # Usage Example: img2pdfench output.pdf # Usage Example: pdf2enc input.pdf output.pdf # Usage Example: pdf2decrypt input.pdf output.pdf # function img2pdfcheck(){ echo '' && echo 'Checking rotation of JPF images... Please be patient...' && n=0 && TOTAL="$(ls *.jpg | wc | awk '{print $1}')" && for i in *.jpg; do (( n++ )) && echo "Checking file $i, which is $n out of $TOTAL" && if [ "$(img2pdf "$i" | grep 'Invalid')" != '' ]; then echo "$i - Rotation is bad"; fi ; done ; } function img2pdfenc(){ find . -type f -iname "*.jpg" -exec img2pdf --output "$1" "{}" + && pdftk "$1" output "${1%.*}_enc.pdf" user_pw PROMPT && rm -f "$1" && mv "${1%.*}_enc.pdf" "$1" ; } function pdf2enc(){ pdftk "$1" output "$2" user_pw PROMPT ; } function pdf2decrypt(){ pdftk "$1" input_pw PROMPT output "$2" ; } #Append line numbers to the beginning of each line # # Usage: addlinenumbers '/path/to/file.txt' # Make permanent: addlinenumbers input.txt | tee output.txt # function addlinenumbers() { awk '{printf("%01d %s\n", NR, $0)}' "$1" ; } #Displaying a #hex or rgb(#,#,#) color using ImageMagick; this is so you #do not have to do an Internet search or open a heavy program just to #find out what the color looks like. Do not forget the quotes. # # Usage HEX: dispcolor '#hex' # Usage RGB: dispcolor 'rgb(#,#,#)' # function dispcolor { display -size 300x300 xc:"$1" ; } function displaycolor { dispcolor "$1" ; } #If you are encrypting/decrypting files using OpenSSL... # # Usage encrypt: encrypt normalFile.ext encryptedFile.enc public.key # Usage decrypt: decrypt encryptedFile.enc private.key # function encrypt() { openssl smime -encrypt -binary -aes-256-cbc -in "$1" -out "$2" -outform DEM "$3" ; } #"$3" is path to public key function decrypt() { openssl smime -decrypt -in "$1" -binary -inform DEM -inkey "$2" ; } #"$2" is path to private key #Sorts out unique lines in text file in alphabetical order # # Usage: unique '/path/to/file.txt' # function unique() { sort "$1" | uniq -u ; } #Zip all files in current directory INDEpendently from each other; in #other words, each file gets its own zip. # # Usage: cd /path/to/directory && indezip # function indezip(){ for file in *; do zip "${file%.*}.zip" "$file"; done ; } #Zip all files in current directory independently from each other AND #delete the originals when finished. # # Usage: cd /path/to/directory && indeziprm # function indeziprm(){ for file in *; do zip "${file%.*}.zip" "$file" && rm "$file"; done ; } #Convert an image to a 10 second MP4 video # # Usage: img2vid 'input.jpg' 640 480 'output.mp4' # #The numbers above are for WxH in pixels function img2vid(){ ffmpeg -hide_banner -threads 0 -loop 1 -i "$1" -c:v libx264 -t 10 -pix_fmt yuv420p -vf scale="$2":"$3" "$4" ; } #Merge video and audio together; replaces current audio if it exists # # Usage: avmerge 'video.ext' 'audio.ext' [output.ext] # function avmerge(){ if [ "$3" = "" ]; then OUTPUT="output_$RANDOM.mp4"; else OUTPUT="$3";fi && ffmpeg -hide_banner -threads 0 -i "$1" -i "$2" -map 0:v -map 1:a -c:v copy -shortest "$OUTPUT" ; } #Copy the contents of a CD-ROM to an ISO if /dev/sr0 is your device, #to which is usually the case for external disc drives. # # Usage: cpcd output.iso # function cpcd(){ isoinfo -d -i /dev/cdrom && blocks=$(isosize -d 2048 /dev/sr0) && dd if=/dev/sr0 of="$1" bs=2048 count=$blocks status=progress ; } #Add some flags to some basic commands that probably should be default #The aliases below with '-i' refer to asking for confirmation before #doing things with files; rm needs to have three or more files or have #the '-r' flag involved before asking for confirmation to delete. alias cp="cp -i" alias mv="mv -i" alias rm="rm -i" alias ln="ln -i" alias df='df -h' alias free="free -m" alias mkdir="mkdir -pv" # Some 'ps' command aliases... alias psa="ps auxf" alias psgrep="ps aux | grep --v grep | grep -i -e VSZ -e" alias psmem='ps auxf | sort -nr -k 4' alias pscpu='ps auxf | sort -nr -k 3' #Create an empty audio file for n amount of seconds. #This is useful for DVD authoring software (DevedeNG, DVD Styler, etc.) #in which you need an audio layer for menus, even if it is an empty one; #some older DVD players and game consoles notice when this is missing #and may create a short (or long) "chirp" noise during certain menus, #especially those with background video or animated chapter selection. #Sometimes these menus are loopable but only loop based on whether the #video layer or audio layer, if separate, have the smallest amount of #time. Hopefully this makes sense. # #Usage: emptyaudio [seconds] output.mp3 # function emptyaudio(){ ffmpeg -hide_banner -threads 0 -ar 48000 -t "$1" -f s16le -i /dev/zero "$2" ; } #This function lists the most used commands and how many times in a simplistic way function top-history(){ history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -nr | head -10 | less ; } #Convert a video to a bunch of JPEG's and convert a bunch of PNG's or #JPEG's to video. I have two separate functions for JPG and JPEGs, even #though they are the same format. Someone out there may be taking #advantage of this and have JPGs that "stand for" one thing and then use #the JPEG extension for some other purpose. # # Usage example A: video2jpg /path/to/video.mp4 [framerate] # Usage example B: cd /path/to/PNG/directory && png2video [framerate] output.mp4 # Usage example C: cd /path/to/JPG/directory && jpg2video [framerate] output.mp4 # Usage example D: cd /path/to/JPEG/directory && jpeg2video [framerate] output.mp4 # function video2jpg(){ ffmpeg -hide_banner -threads 0 -i "$1" -r "$2" "$(basename $1)"_%05d.jpg ; } function png2video() { ffmpeg -hide_banner -threads 0 -framerate "$1" -pattern_type glob -i "*.png" -r "$1" "$2" ; } function jpg2video() { ffmpeg -hide_banner -threads 0 -framerate "$1" -pattern_type glob -i "*.jpg" -r "$1" "$2" ; } function jpeg2video() { ffmpeg -hide_banner -threads 0 -framerate "$1" -pattern_type glob -i "*.jepg" -r "$1" "$2" ; } #Lists URLs that start with 'http' or 'https' on a webpage using cURL # # Usage: listurls https://example.org # function listurls() { curl -s -f -L "$1" | grep -Eo '"(http|https)://[a-zA-Z0-9#~.*,/!?=+&_%:-]*"' | sed 's/"//g' ; } #I did not like how the 'ebook-convert' program from 'Calibre' converts #comic books to whatever with automatic grayscale, especially when the #CBR or CBZ file in question is not a typical comic and is full-color. # # Usage: ebook-convert-cbz input.cb[r,z] output.ext # function ebook-convert-cbz(){ ebook-convert "$1" "$2" --dont-grayscale --no-process --dont-normalize ; } #Use this to get the color palette of a video. #Output should be the same location as the video. # # Usage: video2palette '/path/to/video.ext' # function video2palette(){ ffmpeg -i "$1" -vf "fps=1,scale=480:-1:flags=lanczos,palettegen" "${1%.*}_palette.gif" ; } #Sometimes an SD card, especially those that are 1TB or larger, get #very hot when copy/pasting files; use this to copy files at a 10MB/s #limit. # # Usage Example: rsyncsd "/path/to/file_or_folder" "/path/to/file_or_folder" # alias rsyncsd="rsync -a --bwlimit=10000 --progress" #Use this to permanently overlay a subtitle file onto an MP4. #By the way, 'ffmpeg' can also be used to convert subtitle files, such #as VVT to SRT. # # Usage Example: submp4 "/path/to/video.mp4" "/path/to/subtitles.srt" # function submp4() { ffmpeg -hide_banner -threads 0 -i "$1" -i "$1" -map 1:0 -map 0:1 -y -vf subtitles="$2" -passlogfile "/tmp/${1%.*}.log" -pass 1 "${1%.*}_sub.mp4" ; } #Use this to lower video quality to 720p at ~600k bitrate with 22050Hz #audio. I believe that this is "good enough" for most people, especially #those who grew-up on CRT televisions or do not plan on keeping the #video after watching anyway. # # Usage Example: lowervideoquality "/path/to/4kVideo.mp4" # function lowervideoquality(){ ffmpeg -hide_banner -threads 0 -i "$1" -vf 'scale=trunc(oh*a/2)*2:720' -b:v 600k -maxrate 600k -ar 22050 -passlogfile "/tmp/ffmpeg.log" -pass 1 "${1%.*}_converted.mp4" ; } #Older radio show recordings (1930s-50s) are often too muffled to #understand what the actors are saying because the recording is too #"warm." Use this to lower the bass and increase the treble. However, #do not expect this to work for everything. If converting instead of #previewing, the original is kept with "_fixed" appended to the new MP3 #file. SoX supports most popular audio file-formats. # # Usage Example: radiofix "/path/to/recording.mp3" # function radiofixplreview(){ play "$1" equalizer 295 147k -20 equalizer 400 200k 9.5 equalizer 750 2000k 1 equalizer 8500 17000k 12.7 bass -30 treble +3 ; } function radiofixconvert(){ sox "$1" "${1%.*}_fixed.mp3" equalizer 295 147k -20 equalizer 400 200k 9.5 equalizer 750 2000k 1 equalizer 8500 17000k 12.7 bass -30 treble +3 ; } #Got tired of scrolling, so "ENDs" will be placed here for CTRL+W search #END #LASTLINE #ENDOFLINE