This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathnptool.sh
executable file
·92 lines (80 loc) · 2.12 KB
/
nptool.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
# test if export is supported
export 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
CMD="export"
SEP="="
else
setenv 1>/dev/null 2>/dev/null
if [ "${?} == 0" ]; then
CMD="setenv"
SEP=" "
else
echo "Neither setenv nor export found!"
fi
fi
# find script path
if [ -n "$ZSH_VERSION" ]; then
SCRIPTPATH="$( cd "$( dirname "${(%):-%x}" )" && pwd )"
elif [ -n "$tcsh" ]; then
SCRIPTPATH="$( cd "$( dirname "$0" )" && pwd )"
elif [ -n "$BASH_VERSION" ]; then
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
else
echo "neither bash or zsh is used, abort"
exit 1
fi
# export NPTOOL environment variable
${CMD} NPTOOL${SEP}$SCRIPTPATH
NPARCH=$(uname)
# mac os x case
if [ "${NPARCH}" = "Darwin" ] ;
then
${CMD} DYLD_LIBRARY_PATH${SEP}$NPTOOL/NPLib/lib:$DYLD_LIBRARY_PATH
${CMD} DYLD_LIBRARY_PATH${SEP}$NPTOOL/NPSimulation/lib:$DYLD_LIBRARY_PATH
else
${CMD} LD_LIBRARY_PATH${SEP}$NPTOOL/NPLib/lib:$LD_LIBRARY_PATH
${CMD} LD_LIBRARY_PATH${SEP}$NPTOOL/NPSimulation/lib:$LD_LIBRARY_PATH
fi
${CMD} PATH=$NPTOOL/NPLib/bin:$PATH
${CMD} PATH=$NPTOOL/NPSimulation/bin:$PATH
alias npt='cd $NPTOOL'
alias npl='cd $NPTOOL/NPLib'
alias nps='cd $NPTOOL/NPSimulation'
${CMD} npa_not_supported='npa is now longer supported, use npp instead'
alias npa='echo $npa_not_supported'
# open a project
function npp {
if [[ $1 == *"Example"* ]]
then
cd $NPTOOL/Examples/$1
else
cd $NPTOOL/Projects/$1
fi
}
# tab completion for npp
_npp() {
# Pointer to current completion word.
local cur
# Array variable storing the possible completions.
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
# LIST of available choices
LIST=`ls $NPTOOL/Projects $NPTOOL/Examples`
case "$cur" in
*)
COMPREPLY=( $( compgen -W '$LIST' -- $cur ) );;
esac
return 0
}
# associate the tab completion to npp
if [ -n "$ZSH_VERSION" ]; then
# ZSH have its own command to make things easy
#compdef _directories -W $NPTOLL/Project npp
:
else
# the rest of the world use standard posix complete
complete -F _npp -o filenames npp
fi
${CMD} Geant4_DIR${SEP}$G4LIB
${CMD} NPLib_DIR${SEP}$NPTOOL/NPLib