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

GPT-commit: Added 'sys.dependencies.installed()' function, updated de… #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions src/classes/sys/sys.class
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,28 @@ sys.util.trim() {
echo "$1" | xargs
}

sys.dependencies.installed() {
if [ $(which "$1") != "" ]; then
# echo "yes"
return 0
else
# echo "no"
return 1
fi
}

sys.dependencies.install() {
if sys.os.mac; then
sys.log.info "Installing dependencies for macOS..."
brew update
brew install xclip jq csvkit lynx
brew install xclip jq csvkit lynx tmux
brew tap teamookla/speedtest
brew install speedtest --force
pip3 install -r "${WYX_DIR}/requirements.txt"
elif sys.os.linux; then
sys.log.info "Installing dependencies for Linux..."
sudo apt-get update
sudo apt-get -y install xclip jq csvkit lynx
sudo apt-get -y install xclip jq csvkit lynx tmux
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
sudo apt-get -y install speedtest
pip3 install -r "${WYX_DIR}/requirements.txt"
Expand Down
33 changes: 33 additions & 0 deletions src/commands/multiplex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Check if tmux is installed
if ! sys.dependencies.installed "tmux"; then
echo "You need to install tmux to use this command."
exit 1
fi

# Check if at least one command is provided
if [ "$#" -lt 1 ]; then
echo "You need to provide at least one command."
exit 1
fi

# Create a new tmux session named "my_session"
SESSION="my_session"
tmux new-session -d -s $SESSION

# Create the first window and run the first command
tmux send-keys "$1" C-m

# Create additional panes for each command
for i in $(seq 2 $#); do
tmux split-window -t $SESSION -h
tmux select-layout -t $SESSION tiled
tmux send-keys "${!i}" C-m
done

# Adjust the layout to tiled
tmux select-layout -t $SESSION tiled

# Attach to the tmux session
tmux attach-session -t $SESSION
3 changes: 2 additions & 1 deletion src/data/arg_scripts.csv
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ list-deps,list-deps,"List the project dependencies",true,,deps
update-readme,update_readme,"Auto-update the project's readme with the available commands",false,,
update-cache,update_cache,"Auto-update the project's cache with the available commands",false,,
pp,pp,"Pull-Push Git Changes to Current Branch",true,,git
port-scan,port-scan,"Scan for open ports on a host",true,<host?> <port-range?>,nutil
port-scan,port-scan,"Scan for open ports on a host",true,<host?> <port-range?>,nutil
multiplex,multiplex,"Create a multiplexed window terminal running multiple commands.",<cmd1> <cmd2?> ...,code