From d4489648b4ea7d17f38ebeb8577b79e37bd83ef6 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Wed, 14 Aug 2024 23:13:56 -0700 Subject: [PATCH] fix: Launch script from the directory in which it's contained --- src/commands/applications-setup/alacritty-setup.sh | 2 +- src/commands/applications-setup/dwmtitus-setup.sh | 4 ++-- src/commands/applications-setup/kitty-setup.sh | 2 +- src/commands/applications-setup/rofi-setup.sh | 2 +- src/commands/applications-setup/zsh-setup.sh | 4 ++-- src/commands/security/firewall-baselines.sh | 2 +- src/commands/system-setup/1-compile-setup.sh | 2 +- src/commands/system-setup/2-gaming-setup.sh | 2 +- src/commands/system-setup/3-global-theme.sh | 2 +- src/commands/system-setup/4-remove-snaps.sh | 2 +- src/commands/system-setup/system-update.sh | 2 +- src/commands/utils/monitor-control/auto_detect_displays.sh | 2 +- src/commands/utils/monitor-control/change_orientation.sh | 2 +- src/commands/utils/monitor-control/disable_monitor.sh | 2 +- src/commands/utils/monitor-control/duplicate_displays.sh | 2 +- src/commands/utils/monitor-control/enable_monitor.sh | 2 +- src/commands/utils/monitor-control/extend_displays.sh | 2 +- src/commands/utils/monitor-control/manage_arrangement.sh | 2 +- src/commands/utils/monitor-control/reset_scaling.sh | 2 +- src/commands/utils/monitor-control/scale_monitor.sh | 2 +- src/commands/utils/monitor-control/set_primary_monitor.sh | 2 +- src/commands/utils/monitor-control/set_resolutions.sh | 2 +- src/running_command.rs | 5 ++++- 23 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/commands/applications-setup/alacritty-setup.sh b/src/commands/applications-setup/alacritty-setup.sh index 46143729..69581953 100755 --- a/src/commands/applications-setup/alacritty-setup.sh +++ b/src/commands/applications-setup/alacritty-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh setupAlacritty() { echo "Install Alacritty if not already installed..." diff --git a/src/commands/applications-setup/dwmtitus-setup.sh b/src/commands/applications-setup/dwmtitus-setup.sh index e6253ec4..6421b31e 100644 --- a/src/commands/applications-setup/dwmtitus-setup.sh +++ b/src/commands/applications-setup/dwmtitus-setup.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh makeDWM(){ cd $HOME && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus @@ -24,4 +24,4 @@ setupDWM() { checkEnv setupDWM -makeDWM \ No newline at end of file +makeDWM diff --git a/src/commands/applications-setup/kitty-setup.sh b/src/commands/applications-setup/kitty-setup.sh index b2bce9ea..f4a69d12 100755 --- a/src/commands/applications-setup/kitty-setup.sh +++ b/src/commands/applications-setup/kitty-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh setupKitty() { echo "Install Kitty if not already installed..." diff --git a/src/commands/applications-setup/rofi-setup.sh b/src/commands/applications-setup/rofi-setup.sh index a6639bb9..a571c16d 100755 --- a/src/commands/applications-setup/rofi-setup.sh +++ b/src/commands/applications-setup/rofi-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh setupRofi() { echo "Install Rofi if not already installed..." diff --git a/src/commands/applications-setup/zsh-setup.sh b/src/commands/applications-setup/zsh-setup.sh index c7a7ea9e..e2ec8fd8 100644 --- a/src/commands/applications-setup/zsh-setup.sh +++ b/src/commands/applications-setup/zsh-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -. ./common-script.sh +. ../common-script.sh # Function to install zsh install_zsh() { @@ -48,4 +48,4 @@ EOL checkEnv setup_zsh_config -install_zsh \ No newline at end of file +install_zsh diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index 0a062289..40d24fab 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh installPkg() { echo "Install UFW if not already installed..." diff --git a/src/commands/system-setup/1-compile-setup.sh b/src/commands/system-setup/1-compile-setup.sh index e2243d94..b5f3eab7 100755 --- a/src/commands/system-setup/1-compile-setup.sh +++ b/src/commands/system-setup/1-compile-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh # Check if the home directory and linuxtoolbox folder exist, create them if they don't LINUXTOOLBOXDIR="$HOME/linuxtoolbox" diff --git a/src/commands/system-setup/2-gaming-setup.sh b/src/commands/system-setup/2-gaming-setup.sh index 96bfe777..24b706b6 100755 --- a/src/commands/system-setup/2-gaming-setup.sh +++ b/src/commands/system-setup/2-gaming-setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh installDepend() { ## Check for dependencies. diff --git a/src/commands/system-setup/3-global-theme.sh b/src/commands/system-setup/3-global-theme.sh index eaebcd6e..4d660a37 100644 --- a/src/commands/system-setup/3-global-theme.sh +++ b/src/commands/system-setup/3-global-theme.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh # Check if the home directory and linuxtoolbox folder exist, create them if they don't LINUXTOOLBOXDIR="$HOME/linuxtoolbox" diff --git a/src/commands/system-setup/4-remove-snaps.sh b/src/commands/system-setup/4-remove-snaps.sh index c839e4f0..26a115f3 100644 --- a/src/commands/system-setup/4-remove-snaps.sh +++ b/src/commands/system-setup/4-remove-snaps.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh removeSnaps() { case $PACKAGER in diff --git a/src/commands/system-setup/system-update.sh b/src/commands/system-setup/system-update.sh index 89b2d448..7f93e4f7 100755 --- a/src/commands/system-setup/system-update.sh +++ b/src/commands/system-setup/system-update.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -. ./common-script.sh +. ../common-script.sh fastUpdate() { case ${PACKAGER} in diff --git a/src/commands/utils/monitor-control/auto_detect_displays.sh b/src/commands/utils/monitor-control/auto_detect_displays.sh index 0ff72376..a86ddfc1 100644 --- a/src/commands/utils/monitor-control/auto_detect_displays.sh +++ b/src/commands/utils/monitor-control/auto_detect_displays.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to auto-detect displays and set common resolution auto_detect_displays() { diff --git a/src/commands/utils/monitor-control/change_orientation.sh b/src/commands/utils/monitor-control/change_orientation.sh index 46ca1d34..93927149 100644 --- a/src/commands/utils/monitor-control/change_orientation.sh +++ b/src/commands/utils/monitor-control/change_orientation.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to change monitor orientation change_orientation() { diff --git a/src/commands/utils/monitor-control/disable_monitor.sh b/src/commands/utils/monitor-control/disable_monitor.sh index 4de80062..f999d408 100644 --- a/src/commands/utils/monitor-control/disable_monitor.sh +++ b/src/commands/utils/monitor-control/disable_monitor.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh RESET='\033[0m' BOLD='\033[1m' diff --git a/src/commands/utils/monitor-control/duplicate_displays.sh b/src/commands/utils/monitor-control/duplicate_displays.sh index eb6f542d..4332a0f9 100644 --- a/src/commands/utils/monitor-control/duplicate_displays.sh +++ b/src/commands/utils/monitor-control/duplicate_displays.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to duplicate displays duplicate_displays() { diff --git a/src/commands/utils/monitor-control/enable_monitor.sh b/src/commands/utils/monitor-control/enable_monitor.sh index b18a7c65..bf770053 100644 --- a/src/commands/utils/monitor-control/enable_monitor.sh +++ b/src/commands/utils/monitor-control/enable_monitor.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh RESET='\033[0m' BOLD='\033[1m' diff --git a/src/commands/utils/monitor-control/extend_displays.sh b/src/commands/utils/monitor-control/extend_displays.sh index 974b9e82..d93b2eb3 100644 --- a/src/commands/utils/monitor-control/extend_displays.sh +++ b/src/commands/utils/monitor-control/extend_displays.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to extend displays extend_displays() { diff --git a/src/commands/utils/monitor-control/manage_arrangement.sh b/src/commands/utils/monitor-control/manage_arrangement.sh index 7637641d..305e5210 100644 --- a/src/commands/utils/monitor-control/manage_arrangement.sh +++ b/src/commands/utils/monitor-control/manage_arrangement.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to manage monitor arrangement manage_arrangement() { diff --git a/src/commands/utils/monitor-control/reset_scaling.sh b/src/commands/utils/monitor-control/reset_scaling.sh index 73f03ca8..3a80e856 100644 --- a/src/commands/utils/monitor-control/reset_scaling.sh +++ b/src/commands/utils/monitor-control/reset_scaling.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to reset scaling back to 1 (native resolution) for all monitors reset_scaling() { diff --git a/src/commands/utils/monitor-control/scale_monitor.sh b/src/commands/utils/monitor-control/scale_monitor.sh index 4c88738b..eb680187 100644 --- a/src/commands/utils/monitor-control/scale_monitor.sh +++ b/src/commands/utils/monitor-control/scale_monitor.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to scale smaller monitors to the highest resolution of a bigger monitor scale_monitors() { diff --git a/src/commands/utils/monitor-control/set_primary_monitor.sh b/src/commands/utils/monitor-control/set_primary_monitor.sh index 68d8a17f..f10c8d34 100644 --- a/src/commands/utils/monitor-control/set_primary_monitor.sh +++ b/src/commands/utils/monitor-control/set_primary_monitor.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh # Function to set a monitor as primary set_primary_monitor() { diff --git a/src/commands/utils/monitor-control/set_resolutions.sh b/src/commands/utils/monitor-control/set_resolutions.sh index 40eab9f6..636cf573 100644 --- a/src/commands/utils/monitor-control/set_resolutions.sh +++ b/src/commands/utils/monitor-control/set_resolutions.sh @@ -1,5 +1,5 @@ #!/bin/bash -source ./utils/monitor-control/utility_functions.sh +source ./utility_functions.sh RESET='\033[0m' BOLD='\033[1m' diff --git a/src/running_command.rs b/src/running_command.rs index b2b30291..55cc8e79 100644 --- a/src/running_command.rs +++ b/src/running_command.rs @@ -137,7 +137,10 @@ impl RunningCommand { cmd.arg(prompt); } Command::LocalFile(file) => { - cmd.arg(file); + cmd.arg(&file); + if let Some(parent) = file.parent() { + cmd.cwd(parent); + } } Command::None => panic!("Command::None was treated as a command"), }