-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvtools.sh
More file actions
91 lines (74 loc) · 2.13 KB
/
Copy pathenvtools.sh
File metadata and controls
91 lines (74 loc) · 2.13 KB
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
function splitpath()
{
sed 's/:/\n/g'
}
function showenvplus()
{
echo "--- PATH"
echo $PATH | splitpath
echo "--- PYTHONPATH"
echo $PYTHONPATH | splitpath
echo "--- LD_LIBRARY_PATH"
echo $LD_LIBRARY_PATH | splitpath
echo "--- LIBRARY_PATH"
echo $LIBRARY_PATH | splitpath
echo "--- CPATH"
echo $CPATH | splitpath
echo "--- C_INCLUDE_PATH"
echo $C_INCLUDE_PATH | splitpath
echo "--- CPLUS_INCLUDE_PATH"
echo $CPLUS_INCLUDE_PATH | splitpath
echo "--- CMAKE_PREFIX_PATH"
echo $CMAKE_PREFIX_PATH | splitpath
echo "--- CMAKE_LIBRARY_PATH"
echo $CMAKE_LIBRARY_PATH | splitpath
echo "--- CMAKE_INCLUDE_PATH"
echo $CMAKE_INCLUDE_PATH | splitpath
}
function showenv()
{
echo "--- PATH"
echo $PATH | splitpath
echo "--- PYTHONPATH"
echo $PYTHONPATH | splitpath
echo "--- LD_LIBRARY_PATH"
echo $LD_LIBRARY_PATH | splitpath
}
function showpath()
{
echo "--- PATH"
echo $PATH | splitpath
}
function direnv_cd() {
cd "$1"
eval "$(direnv export bash)"
}
function pyvenv-here() {
cp "$LOCALBASH_DIR/templates/pyvenv.envrc" "$PWD/.envrc"
}
function venv-here() {
cp "$LOCALBASH_DIR/templates/venv.envrc" "$PWD/.envrc"
}
function env-up() {
echo "source_up" >> "$PWD/.envrc"
direnv allow .
}
function indirenv() {
$BASH --rcfile <( cat "$HOME/.bashrc"; direnv stdlib; echo 'export PS1="$PS1 direnv > "'; )
}
### - Tracing BASH environment genesis
# you enter a subshell with this function; after comnpletion, type CTRL-D to exit.
# Result is in the $outfile listed below after you exit.
# parameters passed here go into the bash invocation before the short parameters
function trace_bash() {
local outfile="$HOME/.bashtrace.log"
PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash $@ -xl 7> "$outfile"
echo "bash log stored in $outfile!"
}
# assumes already read $HOME/.bashtrace.log, saves it in $HOME/.bashtrace.sources
function trace_bash_files {
cat $HOME/.bashtrace.log | grep -E '^\+' | grep -v "completion" | sed 's/\+*\([^>]*\).*/\1/' | sed '/^\s*$/d' | sort | uniq > "$HOME/.bashtrace.sources"
}
function grep_bash_trace() {
cat $HOME/.bashtrace.sources | xargs -L1 egrep -Hn --color=always $@
}