diff --git a/Cargo.lock b/Cargo.lock index 78ce4c9..f3786b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,9 +77,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "numtoa" @@ -113,18 +113,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -211,9 +211,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" @@ -223,9 +223,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "vec_map" diff --git a/install.sh b/install.sh index 0a973eb..f5f620f 100755 --- a/install.sh +++ b/install.sh @@ -17,33 +17,36 @@ display_success() { echo -e "${GREEN}[Success]: $1${NC}" } -# Check if script is run with root privileges -if [ "$EUID" -ne 0 ]; then - display_error "This script requires root privileges. Please run with sudo." -fi # Build the tool cargo build --release || display_error "Failed to build the tool." +mkdir -p ~/.local/bin || display_error "Failed to created ~/.local/bin directory" + # Copy the binary to a directory in the PATH -cp target/release/aliasmanager /usr/local/bin/ || display_error "Failed to copy the binary to /usr/local/bin." +cp target/release/aliasmanager ~/.local/bin/ || display_error "Failed to copy the binary to ~/.local/bin" + +mv target/release/aliasmanager . # Determine the user's shell -user_shell=$(basename "$SHELL") -echo "Detected user shell: $user_shell" +user_shell=$(basename "$SHELL")"rc" # Check if the source command already exists in the appropriate shell rc file -if grep -q ".my_aliases.txt" "/home/$SUDO_USER/.$user_shell"rc; then - display_success ".my_aliases.txt already sourced in .$user_shell"rc +if grep -q ".my_aliases.txt" "$HOME/.$user_shell"; then + display_success ".my_aliases.txt already sourced in .$user_shell" else # Append a source command to the appropriate shell rc file for .my_aliases.txt - touch /home/$SUDO_USER/.my_aliases.txt || display_error "Failed to create .my_aliases.txt" - echo "" >> "/home/$SUDO_USER/.$user_shell"rc - echo "# Alias Management Tool" >> "/home/$SUDO_USER/.$user_shell"rc - echo "source /home/$SUDO_USER/.my_aliases.txt" >> "/home/$SUDO_USER/.$user_shell"rc - display_success "Added source command to /home/$SUDO_USER/.$user_shell"rc + touch $HOME/.my_aliases.txt || display_error "Failed to create .my_aliases.txt" + echo "" >> "$HOME/.$user_shell" + echo "# Alias Management Tool" >> "$HOME/.$user_shell" + echo "source $HOME/.my_aliases.txt" >> "$HOME/.$user_shell" + display_success "Added source command to $HOME/.$user_shell" fi # Print installation success message -display_success "Installation complete!" -display_success "You can now use 'aliasmanager' to manage your aliases." +display_success "Installation complete!\n" +echo "Use ./aliasmanager or add it to PATH" + +echo -e "Add this to your $user_shell:\n" +echo "PATH=\$PATH:\$HOME/.local/bin" +echo "Run: aliasmanager add -n am -c aliasmanager"