Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming in C++ 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sdlbio-courses
Programming in C++ 2022
Commits
bd0b0e16
Commit
bd0b0e16
authored
3 years ago
by
Sandipan Mohanty
Browse files
Options
Downloads
Patches
Plain Diff
Add pathutils and aliases
parent
6d0045d6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/bash/aliases.sh
+7
-0
7 additions, 0 deletions
code/bash/aliases.sh
code/bash/pathutils.sh
+71
-0
71 additions, 0 deletions
code/bash/pathutils.sh
with
78 additions
and
0 deletions
code/bash/aliases.sh
0 → 100644
+
7
−
0
View file @
bd0b0e16
alias
cf
=
"clang-format --style=WebKit -i"
alias
C
=
"clang++ -std=c++20 -stdlib=libc++"
alias
Cm
=
"clang++ -std=c++20 -stdlib=libc++ -fmodules -fimplicit-module-maps"
alias
G
=
"g++ -std=c++20 -pedantic -Wall"
alias
Gm
=
"g++ -std=c++20 -fmodules-ts -pedantic -Wall"
alias
Gh
=
"g++ -std=c++20 -fmodules-ts -xc++-system-header"
This diff is collapsed.
Click to expand it.
code/bash/pathutils.sh
0 → 100644
+
71
−
0
View file @
bd0b0e16
#!/bin/bash
# ***********************************************
# Programming in C++
# 09 -- 13 May 2022
# Jülich Supercomputing Centre
# ***********************************************
rmspecial
()
{
sed
-e
's/[]\/()$*.^|[]/\\&/g'
<<<
"
$1
"
}
# Usage:
# prepend_path NAME_OF_PATH_ENV_VAR LOCATION_TO_PREPEND
prepend_path
()
{
local
pathtochange prevpath
pathtochange
=
$1
prevpath
=
${
!pathtochange
}
if
[
-d
"
$2
"
]
;
then
[[
":
${
prevpath
}
:"
!=
*
":
$2
:"
*
]]
&&
prevpath
=
"
$2
:
${
prevpath
}
"
fi
eval
"export
${
pathtochange
}
=
${
prevpath
}
"
}
# Usage:
# remove_path_element NAME_OF_PATH_ENV_VAR LOCATION_TO_REMOVE_FROM_IT
remove_path_element
()
{
local
pathtochange prevpath toremove
pathtochange
=
$1
prevpath
=
${
!pathtochange
}
toremove
=
$(
rmspecial
$2
)
prevpath
=
$(
eval
"echo
${
prevpath
}
| sed -e 's#
$toremove
:##'"
)
prevpath
=
$(
eval
"echo
${
prevpath
}
| sed -e 's#:
$toremove
##'"
)
eval
"export
${
pathtochange
}
=
${
prevpath
}
"
}
# Usage:
# pathadd /a/b/c/bin
pathadd
()
{
prepend_path PATH
$1
}
# Usage:
# pathrm /a/b/c/bin
pathrm
()
{
remove_path_element PATH
$1
}
libpathadd
()
{
prepend_path LD_LIBRARY_PATH
$1
prepend_path LD_RUN_PATH
$1
prepend_path LIBRARY_PATH
$1
}
libpathrm
()
{
remove_path_element LD_LIBRARY_PATH
$1
remove_path_element LD_RUN_PATH
$1
remove_path_element LIBRARY_PATH
$1
}
incpathadd
()
{
prepend_path CPATH
$1
}
incpathrm
()
{
remove_path_element CPATH
$1
}
cmpathadd
()
{
prepend_path CMAKE_PREFIX_PATH
$1
}
cmpathrm
()
{
remove_path_element CMAKE_PREFIX_PATH
$1
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment