Skip to content

Commit

Permalink
Merge pull request #2 from blbynum/release/1.1.0
Browse files Browse the repository at this point in the history
prof v1.1.0
  • Loading branch information
blbynum authored Jun 4, 2023
2 parents 8389c9d + 69bdd68 commit 8cf9c57
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,21 @@ Here are some examples of how you can use `prof`:
```

For more details on each command and its usage, refer to the

[Usage](#usage) section above.

---
---

## Upgrading from v1.0.0

Upgrade Instructions:
1. Download the latest release from the [GitHub repository](https://github.com/your_username/prof/releases).
2. Replace your existing prof file with the new version.
3. Update your existing profiles to include the new loading message by running the following script:
- Download the migration script from [this link](https://github.com/blbynum/prof/blob/release/1.1.0/resources/profiles_migration_1.1.0.sh).
- Open a terminal and navigate to the directory where you downloaded the script.
- Make the script executable with the command: `chmod +x profiles_migration_1.1.0.sh`.
- Run the script with the command: `./profiles_migration_1.1.0.sh`.
- The script will add the loading message to each existing profile that does not already contain it.

---

10 changes: 7 additions & 3 deletions prof
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# Ben Bynum
#
# Version:
# 1.0.0
# 05/23/2023
# 1.1.0
# 06/04/2023
#
# Repository:
# https://github.com/blbynum/prof
Expand Down Expand Up @@ -47,7 +47,6 @@
################################################################################


# Global variable for profile template
profile_template=$(cat << EOF
#!/usr/bin/env bash
Expand Down Expand Up @@ -92,9 +91,14 @@ profile_template=$(cat << EOF
# Add anything else here
# End of profile: {profile_name}
# Print a message indicating that the profile has been loaded
echo "Profile {profile_name} loaded."
EOF
)


function create_profile {
if [ -z "$1" ]; then
echo "Error: No profile name provided."
Expand Down
31 changes: 31 additions & 0 deletions resources/profiles_migration_1.1.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Directory path where profile files are located
profile_dir="$HOME/.bash_profiles"

# Text to add at the end of each profile file
text_to_add="# Print a message indicating that the profile has been loaded
echo \"Profile $(basename {profile_file}) loaded.\""

# Iterate over each profile file in the directory
for file in "$profile_dir"/*; do
# Exclude .profile_metadata file
if [[ "$file" == "$profile_dir/.profile_metadata" ]]; then
continue
fi

# Get the filename without the full path
filename=$(basename "$file")

# Check if the file already contains the specified text
if grep -q "Print a message indicating that the profile has been loaded" "$file"; then
echo "Skipped: $filename already contains the desired text."
else
# Replace {profile_file} with the actual profile filename
modified_text="${text_to_add//\{profile_file\}/$filename}"
# Append the modified text to the end of the file
echo "$modified_text" >> "$file"
echo "Added the desired text to: $filename"
fi
done

0 comments on commit 8cf9c57

Please sign in to comment.