Skip to content

Commit 5a50cb4

Browse files
committed
bashrc: clean up Windows path settings & start/open funcs
1 parent ec8fda3 commit 5a50cb4

File tree

1 file changed

+31
-38
lines changed

1 file changed

+31
-38
lines changed

.bashrc

+31-38
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# otherwise I source this from .profile or .zshrc/.kshrc
66
# (but only for interactive shells -- this should not be run for noninteractive shells)
77

8-
98
# set for debugging:
109
# set -v
1110
# set -x
@@ -200,47 +199,39 @@ setpath_simplex_msys_emacs() {
200199
PATH=/FOR_MSYS:/bin:/usr/bin:/sbin:/mingw/bin:/c/Users/garyo/bin
201200
}
202201

203-
setpath_tower1_msys() {
204-
path_prepend "/bin"
205-
path_prepend "/c/Program Files/git/bin"
206-
path_prepend "/c/Program Files/git LFS"
207-
path_prepend /msys64
208-
path_prepend /c/Windows/System32/OpenSSH # for ssh-add etc.
209-
path_prepend "/c/Program Files/nodejs"
210-
# path_prepend /mingw64/bin # git lfs is here, but I copied it to c:/bin
211-
# path_prepend /c/emacs/emacs/bin # emacsclient
212-
path_prepend /c/ProgramData/chocolatey/bin # runemacs/emacs, putty etc.
213-
path_prepend "/c/Program Files/GnuGlobal/bin"
214-
path_prepend /c/bin always # ffmpeg etc.
215-
# path_prepend "/c/Users/garyo/Anaconda3" # Anaconda python
216-
path_prepend "/c/Python37" # Standard python, but see pyenv below
217-
path_prepend "/c/Python37/Scripts" # pip
218-
path_append "/c/Program Files/Cppcheck" # cppcheck, useful utility
219-
# dumpbin.exe:
220-
path_append "/c/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64"
221-
}
222-
223202
setpath_windows() {
224-
path_prepend "/c/Python36"
225-
path_prepend "/c/Python36/Scripts"
226-
path_prepend "/Python37"
227-
path_prepend "/Python37/Scripts"
228203
# path_prepend /bin
229204
path_prepend /msys64
230205
path_prepend /usr/bin # for msys2 bash/zsh
231206
path_prepend /mingw64/bin # mingw compiler etc., from msys shell
232207
case $OSTYPE in
233-
cygwin*) # msys2 comes with git
208+
cygwin*) # msys2 comes with git
234209
path_append "/Program files (x86)/Git/cmd" ;;
235210
esac
211+
path_prepend "/c/Program Files/git LFS"
212+
path_prepend "/c/Program Files/git/bin"
213+
path_prepend "/c/Program Files/git/cmd"
236214
# # Tex/LaTeX (http://tug.org/texlive/)
237215
path_append /texlive/2010/bin/win32
216+
path_prepend /c/Windows/System32/OpenSSH # for ssh-add etc.
217+
path_prepend /c/bin always # ffmpeg etc.
238218
path_append /c/Windows
239219
path_append /c/Windows/system32
220+
path_prepend "/c/Program Files/GnuGlobal/bin"
221+
path_append "/c/Program Files/Cppcheck" # cppcheck, useful utility
222+
# dumpbin.exe:
223+
path_append "/c/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64"
240224
path_append "/c/Program Files (x86)/PuTTY" # for plink (ssh)
241225
path_prepend "/c/bin" always # local programs e.g. git-lfs
242226
path_append "/c/Program Files/GnuGlobal/bin"
243227
path_append "/swig"
228+
# Common locations for Emacs:
229+
path_prepend "/c/emacs/emacs/bin"
230+
path_prepend "/c/emacs/bin"
231+
path_prepend "/d/emacs/emacs/bin"
232+
path_prepend "/d/emacs/bin"
233+
path_append "$HOME/bin/_Dependencies" # list dll dependencies, exe is "Dependencies"
234+
path_append /c/ProgramData/chocolatey/bin # runemacs/emacs, putty etc.
244235
}
245236

246237
setpath_mac() {
@@ -314,10 +305,7 @@ setpath_bun() {
314305

315306
setpath_rust() {
316307
if [[ -d $HOME/.cargo ]]; then
317-
# this prepends cargo bin to $PATH
318-
# It might do something more some day, so best to
319-
# use it rather than our path_prepend.
320-
. "$HOME/.cargo/env"
308+
path_prepend "$HOME/.cargo/bin"
321309
fi
322310
}
323311

@@ -719,7 +707,7 @@ fi
719707

720708
function mcd {
721709
mkdir -p "$1"
722-
cd "$1"
710+
cd "$1" || return
723711
}
724712

725713
if [[ $_OS = windows ]]; then
@@ -732,13 +720,17 @@ if [[ $_OS = windows ]]; then
732720
fi
733721
# start on Windows opens a file with its default application.
734722
# It's a builtin in cmd.exe.
735-
function start() {
736-
cmd ///c "start /B $(cygpath -w $@)"
723+
function start() {
724+
local args=()
725+
for arg in "$@"; do
726+
args+=("$(cygpath -m "$arg")")
727+
done
728+
c:/Windows/System32/cmd ////s ////c "start /B ${args[*]}"
737729
}
730+
738731
# "open" is the Mac command to do this, might as well emulate on Windows
739732
function open() {
740-
cmd ///c "start /B $(cygpath -w $@)"
741-
733+
start "$@"
742734
}
743735
fi
744736

@@ -748,12 +740,13 @@ function whatshell {
748740

749741
function gcproject {
750742
if [[ -e ~/.config/gcloud/active_config ]]; then
751-
local configfile=~/.config/gcloud/configurations/config_$(cat ~/.config/gcloud/active_config)
743+
local configfile
744+
configfile=~/.config/gcloud/configurations/config_$(cat ~/.config/gcloud/active_config)
752745
if [[ $1 == "short" ]]; then
753746
# horizon-dev-123abc => dev
754-
awk '/^project/ {gsub(/-[0-9a-z]+$/, "", $3); print $3}' $configfile
747+
awk '/^project/ {gsub(/-[0-9a-z]+$/, "", $3); print $3}' "$configfile"
755748
else
756-
awk '/^project/ {print $3}' $configfile
749+
awk '/^project/ {print $3}' "$configfile"
757750
fi
758751
fi
759752
}

0 commit comments

Comments
 (0)