# -*- mode: shell-script -*- if [ -n "${MSYSTEM}" ] then agm2() { local MINGW_DIRS="mingw32 mingw64" local AG_FIND= for dir in ${MINGW_DIRS}; do if type -p /${dir}/bin/ag >/dev/null; then AG_FIND=/${dir}/bin/ag fi done if ! type -p /usr/bin/git >/dev/null; then echo "bash: git: command not found. Please install \"git\" package." exit 1 fi if [ -n "$AG_FIND" ]; then $AG_FIND --makepkg --depth 1 "$@" $(git rev-parse --show-toplevel) else echo "bash: ag: conmmand not found. Please install \"mingw-w64-i686-ag\" or \"mingw-w64-x86_64-ag\" package." exit 1 fi } fi # This function defines a 'cd' replacement function capable of keeping, # displaying and accessing history of visited directories, up to 10 entries. # acd_func 1.0.5, 10-nov-2004 # Petar Marinov, http:/geocities.com/h2428, this is public domain cd_func() { local x2 the_new_dir adir index local -i cnt if [[ $1 == "--" ]] then dirs -v return 0 fi the_new_dir=$1 [[ -z $1 ]] && the_new_dir=$HOME if [[ ${the_new_dir:0:1} == '-' ]] then # # Extract dir N from dirs index=${the_new_dir:1} [[ -z $index ]] && index=1 adir=$(dirs +$index) [[ -z $adir ]] && return 1 the_new_dir=$adir fi # # '~' has to be substituted by ${HOME} [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}" # # Now change to the new dir and add to the top of the stack pushd "${the_new_dir}" > /dev/null [[ $? -ne 0 ]] && return 1 the_new_dir=$(pwd) # # Trim down everything beyond 11th entry popd -n +11 2>/dev/null 1>/dev/null # # Remove any other occurence of this dir, skipping the top of the stack for ((cnt=1; cnt <= 10; cnt++)) do x2=$(dirs +${cnt} 2>/dev/null) [[ $? -ne 0 ]] && return 0 [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}" if [[ "${x2}" == "${the_new_dir}" ]] then popd -n +$cnt 2>/dev/null 1>/dev/null cnt=cnt-1 fi done return 0 } alias cd=cd_func settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; } # Function which adds an alias to the current shell and to # the ~/.bash_aliases file. add-alias() { local name=$1 value="$2" echo alias $name=\'$value\' >>~/.bash_aliases eval alias $name=\'$value\' alias $name } # "repeat" command. Like: # # repeat 10 echo foo repeat() { local count="$1" i; shift; for i in $(_seq 1 "$count"); do eval "$@"; done } # Subfunction needed by `repeat'. _seq() { local lower upper output; lower=$1 upper=$2; if [ $lower -ge $upper ] then return; fi while [ $lower -lt $upper ]; do echo -n "$lower " lower=$(($lower + 1)) done echo "$lower" } remove_dups() { local D=${2:-:} path= dir= while IFS= read -d$D dir do [[ $path$D =~ .*$D$dir$D.* ]] || path+="$D$dir" done <<< "$1$D" printf %s "${path#$D}" } prepend_roslyn_to_path() { if [ -d "/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/Roslyn" ] then PATH="/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/Roslyn:${PATH}" return 0 fi if [ -d "/c/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/Roslyn" ] then PATH="/c/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/Roslyn:${PATH}" return 0 fi return 1 } prepend_opt_context_to_path() { if [ ! -d "${OptDirectory}/context-win64" ] then return 1 fi PATH="${OptDirectory}/context-win64/tex/texmf-win64/bin:${OptDirectory}/context-win64/bin:${PATH}" return 0 } set_msvc_env_x64() { if [ -d "/c/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64" ] then PATH="/c/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/VC/VCPackages:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer:/c/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/bin/Roslyn:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools:/c/Program Files/Microsoft Visual Studio/2022/Professional/Team Tools/DiagnosticsHub/Collector:/c/Program Files/Microsoft Visual Studio/2022/Professional//MSBuild/Current/Bin/amd64:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE:/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/Tools:${PATH}" return 0 fi return 1 }