setting an enviroment using bash script
a little rattled, but i can do an intro, or try
a unix shell is an interpreter for the unix operatign system to process commands and do several things, including interpreting commands into the kernel, but mainly communicating with programs, but most unix shell feature powerful text editing features through several programs, including awk, sed, grep, and perl. you can also set custom commands and modify both user and bash shell system wide variables, including the PATH variables
so lets say i want to set a custom enviroment for a program, we can call it, uhmm, a fork of mpv
so we have options, we can set enviromental variables that allow variablistic access to files, meaning i can define /Volumes/M2/src/git/mpv/src/main.c to $MPV_MAIN_FILE, so i can do emacs $MPV_MAIN_FILE, or i believe you set a sequence of commands (including pipes, redirects, and operatives such as the AND operator), such as EDIT_MPV to execute emacs $MPV_MAIN_FILE (which starts emacs with that variable, which is set to the main variable in the mpv directory)
these variables have to be exported i think, but in bash it should be 'export VARIABLE_NAME=COMMAND', in tcsh its 'setenv VARIABLE COMMAND' i think, note the difference in equals command
note that there is no real way to delete a variable in memory aside from assigning it a null value (meaning "" or nothing at all), and i havent looked at the memory code in any shell yet, but i believe it resides in memory until terminated or freed by another function, they can be unset however, but this is just what i think lol it is a blog
but in the script, you'll have to export the variables i believe to make it accessible outside the script. so we can do, not sure if this works on bash->zsh or zsh->bash etcetra but yeah, google around
#!/bin/bash
export MPV_MAIN_DIR=/Volumes/M2/mpv/
export MPV_MAIN_FILE=$MPV_MAIN_DIR/src/main.c
export MPV_EDITOR=emacs
export MPV_COMPILE_HP=cat $MPV_MAIN_DIR/Makefile | awk/sed/grep magic to parse the makefile and replace it with different options
export MPV_SWITCH_SDL_LIB=command to replace sdl libraries
export MPV_COMPILE=cd $MPV_MAIN_DIR && ./configure && make -j100 && make install
//etc
echo "you can additionally echo commands!"
by setting these enviromental variables, and customizing your bash instance, since shell scripts somewhat work on a recursive heirarchical manner, you can greatly automate and customize your bash shell.
you can also use a shell profile, but yeah, i havent looked at my bash profile for a while
but this is really catered to software development, any command you type in can be automated and scripted in most if not all production and community supported unix shells
i dont know all of the shells off hand, but this fits the criteria of most common unix shells, including bash, sh, tcsh, csh, and zsh
oh well, happy programming! im personally going to experiment with this method later
unidef