Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zsh support #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 48 additions & 20 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,53 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Adds the following function to the bashrc file:

echo "Adding ros_dev function to bashrc file"

echo 'ros_dev() {
# Check if the correct number of arguments were provided
if (( $# % 2 != 0 )); then
echo "Usage: ros_dev <container_name1> <project_path1> [<container_name2> <project_path2> ...]"
return 1
if [[ $SHELL == "/bin/bash" ]]; then
# Check if the function already exists in the bashrc file
if ! grep -q "ros_dev()" "$HOME/.bashrc"; then
echo 'ros_dev() {
# Check if the correct number of arguments were provided
if (( $# % 2 != 0 )); then
echo "Usage: ros_dev <container_name1> <project_path1> [<container_name2> <project_path2> ...]"
return 1
fi
while (( $# >= 2 )); do
# Set environment variables
export ROS_DEV_CONTAINER_NAME=$1
export ROS_PROJECT_PATH=$2
shift 2
# Run docker-compose from the correct directory
cd "$SCRIPT_DIR" && docker-compose up -d --build
done
}' >> "$HOME/.bashrc"
echo "ros_dev function added to bashrc file"
else
echo "ros_dev function already exists in bashrc file"
fi
else if [[ $SHELL == "/bin/zsh" ]]; then
ghanta1996 marked this conversation as resolved.
Show resolved Hide resolved
# Check if the function already exists in the zshrc file
if ! grep -q "ros_dev()" "$HOME/.zshrc"; then
echo 'ros_dev() {
# Check if the correct number of arguments were provided
if (( $# % 2 != 0 )); then
echo "Usage: ros_dev <container_name1> <project_path1> [<container_name2> <project_path2> ...]"
return 1
fi
while (( $# >= 2 )); do
# Set environment variables
export ROS_DEV_CONTAINER_NAME=$1
export ROS_PROJECT_PATH=$2
shift 2
# Run docker-compose from the correct directory
cd "$SCRIPT_DIR" && docker-compose up -d --build
done
}' >> "$HOME/.zshrc"
echo "ros_dev function added to zshrc file"
else
echo "ros_dev function already exists in zshrc file"
fi
else
echo "Unsupported shell"
exit 1
ghanta1996 marked this conversation as resolved.
Show resolved Hide resolved
fi

while (( $# >= 2 )); do
# Set environment variables
export ROS_DEV_CONTAINER_NAME=$1
export ROS_PROJECT_PATH=$2
shift 2

# Run docker-compose from the correct directory
cd "$SCRIPT_DIR" && docker-compose up -d --build
done
}
' >> "$HOME/.bashrc"

fi
echo "Done"