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 all commits
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
26 changes: 20 additions & 6 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash

## Author: Adeeb Abbas
# This script sets up the ros_dev function in the bashrc file.

# Get the absolute path to the script directory
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() {
# Define the function
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> ...]"
Expand All @@ -25,6 +24,21 @@ echo 'ros_dev() {
cd "$SCRIPT_DIR" && docker-compose up -d --build
done
}
' >> "$HOME/.bashrc"

if [[ $SHELL == "/bin/bash" ]]; then
shell_config_file="$HOME/.bashrc"
elif [[ $SHELL == "/bin/zsh" ]]; then
shell_config_file="$HOME/.zshrc"
else
echo "Unsupported shell"
exit 1
fi

if ! grep -q "ros_dev ()" "$shell_config_file"; then
declare -f ros_dev >> "$shell_config_file"
echo "ros_dev function added to $shell_config_file"
else
echo "ros_dev function already exists in $shell_config_file"
fi

echo "Done"