-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc_os.CYGWIN_NT
66 lines (52 loc) · 1.97 KB
/
.bashrc_os.CYGWIN_NT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#----- header -----
[ "${0##*/}" != "${BASH_SOURCE##*/}" ] || { >&2 echo -e "ERROR\tfile must be sourced ($0)"; return 2; }
# prevent multiple-inclusion
__link=`readlink -f "$BASH_SOURCE"`
declare -n __tag=SOURCE_${__link//[^a-zA-Z0-9_]/}
[ ${__tag:-0} -eq 0 ] || return 0
__tag=1
#------------------
# ignore if wrong OS
_flavor=${BASH_SOURCE##*/}
_flavor=${_flavor#?*.}
[[ "${OSTYPE:-`uname`}" =~ "${_flavor:-unknown}" ]] || return 0
# CYGWIN variable
#
# see: https://cygwin.com/faq/faq.html#faq.api.symlinks
# 'winsymlinks[:lnk]' only needed in *old* versions of DOS/WIN (pre-Win10)
# ':nativestrict' works across MINGW/CYGWIN/WSL but not in SAMBA/CIFS or Dropbox
#
# since 2020 cygwin defaults to WSL reparse points w/ POSIX path but DOS programs
# (eg. AWS CLI) require real [sym]links as provided by :nativestrict or mklink
string.contains "${CYGWIN:-X}" 'winsymlinks' || CYGWIN+=' winsymlinks:nativestrict'
# prevent fork-bomb if cmd.exe unavailable
[ -n "${CYGWIN_NOWINPATH+X}" ] || {
is_exec -q cmd.exe && function command_not_found_handle() { cmd.exe /D /C "$@"; }
}
shopt -s nocaseglob
if is_exec -q procps; then
alias ps='\procps -e ${PS_ARGS:- -o uid,pid,ppid,stime,etime,cmd}'
is_exec -q pidof ||
function pidof() {
\procps -eo pid,cmd | awk -v pat="$1" '$NF ~ pat { print $1 }'
}
else
alias ps='\ps -f'
is_exec -q pidof ||
function pidof() {
\ps -s | awk -v pat="$1" '$NF ~ pat { print $1 }'
}
fi
# Example of a semi-smart search, but probably best to define in .aliases.local
# or better yet put $LOCALAPPDATA on $PATH and symlink to actual in bin/.
#which 'XXX' &>/dev/null || {
# bin='XXX.exe'
# for dir in USERPROFILE LOCALAPPDATA PROGRAMFILES; do
# [ -x "${!dir}/$bin" ] && { alias xxx="run $(convert_path -e "${!dir}/$bin")"; break; }
# done
# }
for f in "${BASH_SOURCE/bashrc/functions}"; do
[ -s "$f" ] || continue
source "$f" || { log.error "RC=$? during $f"; return; }
done
# vim: expandtab:ts=4:sw=4