Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
121 lines (103 loc) · 2.93 KB
/
Copy pathinstall.sh
File metadata and controls
121 lines (103 loc) · 2.93 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Install CLI tools
echo "Installing CLI Tool Kit..."
# Check if Python3 is installed
if ! command -v python3 &> /dev/null; then
echo "Error: Python3 is not installed"
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install dependencies if requirements.txt exists
if [ -f "requirements.txt" ]; then
echo "Installing dependencies..."
pip install -r requirements.txt
else
echo "Warning: requirements.txt not found"
echo "Creating basic requirements.txt..."
cat > requirements.txt << EOF
# CLI Tools Dependencies
pyperclip>=1.8.2
requests>=2.28.0
chardet>=5.1.0
EOF
pip install -r requirements.txt
fi
# Make tools executable
if [ -d "tools" ]; then
echo "Making tools executable..."
chmod +x tools/*.py 2>/dev/null || true
else
echo "Error: tools directory not found"
exit 1
fi
# Check for existing commands
check_command_exists() {
command -v "$1" &> /dev/null
}
# Create symlinks in /usr/local/bin (optional)
echo
read -p "Create symlinks in /usr/local/bin? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Check for sudo privileges
if ! sudo -v; then
echo "Error: Need sudo privileges to create symlinks"
exit 1
fi
# Create symlinks for each tool
tools=(
"file_organizer.py:forganize"
"password_generator.py:pgen"
"json_formatter.py:jsonfmt"
"url_shortener.py:urlshort"
"csv_processor.py:csvproc"
"text_processor.py:textproc"
)
for tool_pair in "${tools[@]}"; do
IFS=':' read -r source_name dest_name <<< "$tool_pair"
source_path="$(pwd)/tools/$source_name"
if [ -f "$source_path" ]; then
if check_command_exists "$dest_name"; then
echo "Warning: Command '$dest_name' already exists. Skipping..."
else
sudo ln -sf "$source_path" "/usr/local/bin/$dest_name"
echo "Created symlink: $dest_name"
fi
else
echo "Warning: $source_name not found"
fi
done
echo "Tools installed as system commands"
# Create an alias file for easier activation
cat > cli-tools-activate.sh << 'EOF'
#!/bin/bash
# Activate CLI tools environment
source "$(dirname "$0")/venv/bin/activate"
EOF
chmod +x cli-tools-activate.sh
echo "Created activation script: cli-tools-activate.sh"
fi
# Create a setup script for easy updates
cat > update-tools.sh << 'EOF'
#!/bin/bash
# Update CLI tools
source venv/bin/activate
pip install --upgrade -r requirements.txt
echo "Tools updated successfully"
EOF
chmod +x update-tools.sh
# Create a usage guide
cat > QUICKSTART.md << 'EOF'
# CLI Tools Quick Start
## Installation
Run the installation script:
```bash
./install.sh