Skip to content

Commit

Permalink
Merge pull request #63 from hwixley/feature/shell-multiplex
Browse files Browse the repository at this point in the history
GPT-commit: Added 'sys.dependencies.installed()' function, updated de…
  • Loading branch information
hwixley authored Nov 19, 2024
2 parents fadab88 + 22ad6c9 commit 2bdd242
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
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

0 comments on commit 2bdd242

Please sign in to comment.