File size: 1,377 Bytes
63364aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

# Download defaults.json from the given URL and save as "defaults.json"
curl -o defaults.json https://raw.githubusercontent.com/shubhamakshit/pwdlv3/main/defaults.linux.json

# Ensure pip is installed by downloading and running get-pip.py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python_installed=false

if command -v python &> /dev/null
then
    python_installed=true
    echo "Python is installed"
    python get-pip.py
    python -m pip install -r requirements.txt
elif command -v python3 &> /dev/null
then
    python_installed=true
    echo "Python3 is installed"
    python3 get-pip.py
    python3 -m pip install -r requirements.txt
else
    echo "Python is not installed"
    # exit if python is not installed
    exit 1
fi

# Clean up get-pip.py
rm get-pip.py

# Get the absolute path of the script's directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

chmod +x $SCRIPT_DIR/bin/*

# Check if 'alias pwdl' is already present in ~/.bashrc
if ! grep -q "alias pwdl" ~/.bashrc
then
    # Add alias to ~/.bashrc
    echo "alias pwdl='python3 $SCRIPT_DIR/pwdl.py'" >> ~/.bashrc
fi

# Source ~/.bashrc to make the alias available in the current session
source ~/.bashrc

# Notify the user to restart their terminal to apply the alias if not sourced
echo "Please restart your terminal or run 'source ~/.bashrc' to apply the alias."