-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
I quite like this package and approach. Thus, I would like to include a lesson I recently learnt while developing an R code aims to include some CLI tools. It is possible to include the following line in the R/configure file:
#!/bin/bash
# Determine the user's shell configuration file
SHELL_RC="$(basename $SHELL)rc"
USER_RC="$HOME/.$SHELL_RC"
# Define color codes
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Add the exec directory of the package to the PATH
export PATH=$(Rscript -e "cat(system.file(\"exec\", package = \"yourpackagename\"))"):$PATH
EXPORT_CMD='export PATH=$(Rscript -e "cat(system.file(\"exec\", package = \"yourpackagename\"))"):$PATH'
if ! grep -Fxq "$EXPORT_CMD" "$USER_RC"; then
echo "$EXPORT_CMD" >> "$USER_RC"
echo -e "${GREEN}Added yourpackagename exec directory to PATH in $USER_RC${NC}"
else
echo -e "${YELLOW}yourpackagename exec directory already in PATH in $USER_RC${NC}"
fi
echo -e "${YELLOW}Please run 'source $USER_RC' before using the command.${NC}"
# Source the user's shell configuration file to apply changes
source "$USER_RC"
This way it is not necessary to communicate with users to include the proper export in their .bashrc or ./zshrc as it will be automatically identified.
j-andrews7
Metadata
Metadata
Assignees
Labels
No labels