Compare commits

...

4 Commits

275
sshm.bash
View File

@ -18,6 +18,14 @@
set -eo pipefail; [[ $TRACE ]] && set -x set -eo pipefail; [[ $TRACE ]] && set -x
# Colors and formatting
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly BOLD='\033[1m'
readonly NC='\033[0m' # No Color
readonly VERSION="2.1.0" readonly VERSION="2.1.0"
readonly CONFIG_DIR="${HOME}/.config/sshm" readonly CONFIG_DIR="${HOME}/.config/sshm"
readonly DEFAULT_CONFIG="${HOME}/.ssh/config" readonly DEFAULT_CONFIG="${HOME}/.ssh/config"
@ -26,38 +34,43 @@ readonly GITHUB_REPO="Gu1llaum-3/sshm"
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
if [[ -f "$CURRENT_CONTEXT_FILE" ]]; then # Initialize SSHM_CONTEXT from file or default if not already set
CONFIG_FILE=$(cat "$CURRENT_CONTEXT_FILE") if [[ -z "${SSHM_CONTEXT:-}" ]]; then
else if [[ -f "$CURRENT_CONTEXT_FILE" ]]; then
CONFIG_FILE="$DEFAULT_CONFIG" export SSHM_CONTEXT=$(cat "$CURRENT_CONTEXT_FILE")
else
export SSHM_CONTEXT="$DEFAULT_CONFIG"
fi
fi fi
CONFIG_FILE="$SSHM_CONTEXT"
sshm_version() { sshm_version() {
echo "sshm $VERSION" echo -e "${BLUE}${BOLD}sshm $VERSION${NC}"
echo
# Fetch the latest release tag from GitHub # Fetch the latest release tag from GitHub
local latest_version local latest_version
latest_version=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest" | jq -r .tag_name) latest_version=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest" | jq -r .tag_name)
if [[ "$latest_version" == "null" ]]; then if [[ "$latest_version" == "null" ]]; then
echo "sshm $VERSION" echo -e "${RED}Error: Unable to fetch the latest release from GitHub.${NC}" 1>&2
echo "Error: Unable to fetch the latest release from GitHub." 1>&2
exit 1 exit 1
fi fi
# Compare with the current version # Compare with the current version
if [[ "$latest_version" != "$VERSION" ]]; then if [[ "$latest_version" != "$VERSION" ]]; then
echo "A new version of sshm is available: $latest_version (current: $VERSION)" echo -e "${YELLOW}A new version of sshm is available: $latest_version${NC} (current: $VERSION)"
echo "You can update by running: git pull origin main" echo -e "You can update by running: ${BOLD}git pull origin main${NC}"
else else
echo "This is the latest version" echo -e "${GREEN}This is the latest version${NC}"
fi fi
} }
sshm_help() { sshm_help() {
echo "Usage: sshm [command] <command-specific-options>" echo -e "${BLUE}${BOLD}Usage:${NC} sshm [command] <command-specific-options>"
echo echo
echo "Commands:" echo -e "${BLUE}${BOLD}Commands:${NC}"
cat<<EOF | column -t -s $'\t' cat<<EOF | column -t -s $'\t'
<host> Connect directly to SSH host by name <host> Connect directly to SSH host by name
list List SSH hosts and prompt for connection list List SSH hosts and prompt for connection
@ -76,10 +89,55 @@ EOF
sshm_list() { sshm_list() {
local config_file="$CONFIG_FILE" local config_file="$CONFIG_FILE"
echo -e "\nList of SSH hosts:"
grep -E '^Host ' "$config_file" | awk '{print $2}' | grep -v '^#' | sort | nl
echo -ne "\nEnter the number or name of the host (or press Enter to exit): " # Check if the file exists and is not empty
if [[ ! -s "$config_file" ]]; then
echo -e "\n${YELLOW}No SSH hosts configured in current context.${NC}"
echo -e "Use ${BOLD}sshm add${NC} to add a new host configuration."
exit 0
fi
# Check if there are any Host entries
if ! grep -q "^Host " "$config_file"; then
echo -e "\n${YELLOW}No SSH hosts configured in current context.${NC}"
echo -e "Use ${BOLD}sshm add${NC} to add a new host configuration."
exit 0
fi
# Display context name if not default
if [[ "$SSHM_CONTEXT" != "$DEFAULT_CONFIG" ]]; then
local context_name=$(basename "$SSHM_CONTEXT")
echo -e "\n${BLUE}${BOLD}Context: ${NC}${context_name}"
fi
echo -e "\n${BLUE}${BOLD}List of SSH hosts:${NC}"
# Create a temporary file to store results
local tmp_file
tmp_file=$(mktemp)
# Process each host
while IFS= read -r line; do
host=$(echo "$line" | awk '{print $2}')
hostname=$(awk '/^Host '"$host"'$/,/^$/' "$config_file" | awk '/HostName/ {print $2}')
# Skip if no hostname found
if [[ -z "$hostname" ]]; then
continue
fi
if ping -c 1 -W 1 "$hostname" &> /dev/null; then
echo -e "${GREEN}${NC} $host ($hostname)" >> "$tmp_file"
else
echo -e "${RED}${NC} $host ($hostname)" >> "$tmp_file"
fi
done < <(grep -E '^Host ' "$config_file" | grep -v '^#' | sort)
# Display numbered results
nl "$tmp_file"
rm -f "$tmp_file"
echo -ne "\n${BOLD}Enter the number or name of the host (or press Enter to exit):${NC} "
read host read host
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "No host specified, exiting." echo "No host specified, exiting."
@ -93,7 +151,7 @@ sshm_connect() {
local config_file="$1" local config_file="$1"
local host="$2" local host="$2"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: please provide a host number or name." 1>&2 echo -e "${RED}Error: please provide a host number or name.${NC}" 1>&2
exit 1 exit 1
fi fi
@ -101,19 +159,21 @@ sshm_connect() {
local host_name local host_name
host_name=$(grep -E '^Host ' "$config_file" | awk '{print $2}' | grep -v '^#' | sed -n "${host}p") host_name=$(grep -E '^Host ' "$config_file" | awk '{print $2}' | grep -v '^#' | sed -n "${host}p")
if [[ -n "$host_name" ]]; then if [[ -n "$host_name" ]]; then
echo -e "\n${GREEN}Connecting to $host_name...${NC}\n"
ssh -F "$config_file" "$host_name" ssh -F "$config_file" "$host_name"
else else
echo "Error: Invalid host number." 1>&2 echo -e "${RED}Error: Invalid host number.${NC}" 1>&2
exit 2 exit 2
fi fi
else else
# Check if the host exists in the SSH configuration # Check if the host exists in the SSH configuration
if ! grep -q "^Host $host$" "$config_file"; then if ! grep -q "^Host $host$" "$config_file"; then
echo "Error: Host '$host' not found in SSH configuration." 1>&2 echo -e "${RED}Error: Host '$host' not found in SSH configuration.${NC}" 1>&2
echo "Use 'sshm list' to see available hosts or 'sshm add $host' to add it." 1>&2 echo -e "Use ${BOLD}sshm list${NC} to see available hosts or ${BOLD}sshm add $host${NC} to add it." 1>&2
exit 1 exit 1
fi fi
echo -e "\n${GREEN}Connecting to $host...${NC}\n"
ssh -F "$config_file" "$host" ssh -F "$config_file" "$host"
fi fi
} }
@ -122,21 +182,22 @@ sshm_ping() {
local config_file="$1" local config_file="$1"
local host="$2" local host="$2"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: please provide a host name." 1>&2 echo -e "${RED}Error: please provide a host name.${NC}" 1>&2
exit 1 exit 1
fi fi
local hostname local hostname
hostname=$(awk '/^Host '"$host"'$/,/^$/' "$config_file" | awk '/HostName/ {print $2}') hostname=$(awk '/^Host '"$host"'$/,/^$/' "$config_file" | awk '/HostName/ {print $2}')
if [[ -z "$hostname" ]]; then if [[ -z "$hostname" ]]; then
echo "Error: HostName not found for host $host in SSH configuration." 1>&2 echo -e "${RED}Error: HostName not found for host $host in SSH configuration.${NC}" 1>&2
exit 1 exit 1
fi fi
echo -e "\n${BLUE}Pinging $host ($hostname)...${NC}"
if ping -c 1 -W 1 "$hostname" &> /dev/null; then if ping -c 1 -W 1 "$hostname" &> /dev/null; then
echo -e "\033[32m$host ($hostname) is available\033[0m" echo -e "${GREEN}$host ($hostname) is available${NC}"
else else
echo -e "\033[31m$host ($hostname) is unavailable\033[0m" echo -e "${RED}$host ($hostname) is unavailable${NC}"
fi fi
} }
@ -144,18 +205,18 @@ sshm_view() {
local config_file="$1" local config_file="$1"
local host="$2" local host="$2"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: please provide a host name." 1>&2 echo -e "${RED}Error: please provide a host name.${NC}" 1>&2
exit 1 exit 1
fi fi
local host_info local host_info
host_info=$(awk '/^Host '"$host"'$/,/^$/' "$config_file") host_info=$(awk '/^Host '"$host"'$/,/^$/' "$config_file")
if [[ -z "$host_info" ]]; then if [[ -z "$host_info" ]]; then
echo "Error: host not found in SSH configuration." 1>&2 echo -e "${RED}Error: host not found in SSH configuration.${NC}" 1>&2
exit 1 exit 1
fi fi
echo -e "\nInformation for host $host:\n" echo -e "\n${BLUE}${BOLD}Information for host $host:${NC}\n"
echo "$host_info" echo "$host_info"
} }
@ -165,23 +226,37 @@ sshm_delete() {
local silent="${3:-false}" local silent="${3:-false}"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: please provide a host name." 1>&2 echo -e "${RED}Error: please provide a host name.${NC}" 1>&2
exit 1 exit 1
fi fi
# Create a backup of the original file
cp "$config_file" "$config_file.bak"
# Create a temporary file for the new content
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
sed '/^Host '"$host"'$/,/^$/d' "$config_file" > "$tmp_file" sed '/^Host '"$host"'$/,/^$/d' "$config_file" > "$tmp_file"
mv "$tmp_file" "$config_file"
# Check if the temporary file is not empty before overwriting
if [[ -s "$tmp_file" ]]; then
mv "$tmp_file" "$config_file"
rm -f "$config_file.bak"
else
mv "$config_file.bak" "$config_file"
rm -f "$tmp_file"
echo -e "${RED}Error: Operation would result in empty file. Operation cancelled.${NC}" 1>&2
exit 1
fi
if [[ "$silent" != "true" ]]; then if [[ "$silent" != "true" ]]; then
echo "Host $host removed from SSH configuration." echo -e "${GREEN}Host $host removed from SSH configuration.${NC}"
fi fi
} }
sshm_add() { sshm_add() {
local config_file="$1" local config_file="$CONFIG_FILE"
local host="$2" local host="$1"
local hostname local hostname
local user local user
local port local port
@ -191,17 +266,26 @@ sshm_add() {
default_identity_file=$(find ~/.ssh -maxdepth 1 -type f \( -name "id_rsa" -o -name "id_ed25519" -o -name "id_ecdsa" -o -name "id_dsa" \) | head -n 1) default_identity_file=$(find ~/.ssh -maxdepth 1 -type f \( -name "id_rsa" -o -name "id_ed25519" -o -name "id_ecdsa" -o -name "id_dsa" \) | head -n 1)
default_identity_file=${default_identity_file:-~/.ssh/id_rsa} default_identity_file=${default_identity_file:-~/.ssh/id_rsa}
echo -e "\n${BLUE}${BOLD}Adding new SSH host configuration${NC}\n"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
read -p "Enter host name: " host read -p "Enter host name: " host
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: host name cannot be empty." 1>&2 echo -e "${RED}Error: host name cannot be empty.${NC}" 1>&2
exit 1 exit 1
fi fi
fi fi
# Vérifier si le host existe déjà
if grep -q "^Host $host$" "$config_file" 2>/dev/null; then
echo -e "${RED}Error: Host '$host' already exists in configuration.${NC}" 1>&2
echo -e "Use ${BOLD}sshm edit $host${NC} to modify the existing configuration or choose a different name." 1>&2
exit 1
fi
read -p "Enter HostName (IP address or domain): " hostname read -p "Enter HostName (IP address or domain): " hostname
if [[ -z "$hostname" ]]; then if [[ -z "$hostname" ]]; then
echo "Error: HostName cannot be empty." 1>&2 echo -e "${RED}Error: HostName cannot be empty.${NC}" 1>&2
exit 1 exit 1
fi fi
@ -216,6 +300,10 @@ sshm_add() {
read -p "Enter ProxyJump host (optional): " proxy_jump read -p "Enter ProxyJump host (optional): " proxy_jump
# Create the file if it doesn't exist
touch "$config_file"
# Add the new configuration
{ {
echo "" echo ""
echo "Host $host" echo "Host $host"
@ -232,24 +320,27 @@ sshm_add() {
fi fi
} >> "$config_file" } >> "$config_file"
echo "Configuration for host $host added successfully." echo -e "\n${GREEN}✓ Configuration for host $host added successfully.${NC}"
echo -e "You can now connect using: ${BOLD}sshm $host${NC}"
} }
sshm_edit() { sshm_edit() {
local config_file="$1" local config_file="$CONFIG_FILE"
local host="$2" local host="$1"
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
echo "Error: please provide a host name." 1>&2 echo -e "${RED}Error: please provide a host name.${NC}" 1>&2
exit 1 exit 1
fi fi
local host_info local host_info
host_info=$(awk '/^Host '"$host"'$/,/^$/' "$config_file") host_info=$(awk '/^Host '"$host"'$/,/^$/' "$config_file")
if [[ -z "$host_info" ]]; then if [[ -z "$host_info" ]]; then
echo "Error: host not found in SSH configuration." 1>&2 echo -e "${RED}Error: host not found in SSH configuration.${NC}" 1>&2
exit 1 exit 1
fi fi
echo -e "\n${BLUE}${BOLD}Editing configuration for host $host${NC}\n"
default_identity_file=$(find ~/.ssh -maxdepth 1 -type f \( -name "id_rsa" -o -name "id_ed25519" -o -name "id_ecdsa" -o -name "id_dsa" \) | head -n 1) default_identity_file=$(find ~/.ssh -maxdepth 1 -type f \( -name "id_rsa" -o -name "id_ed25519" -o -name "id_ecdsa" -o -name "id_dsa" \) | head -n 1)
default_identity_file=${default_identity_file:-~/.ssh/id_rsa} default_identity_file=${default_identity_file:-~/.ssh/id_rsa}
@ -260,6 +351,9 @@ sshm_edit() {
local current_identity_file=$(echo "$host_info" | awk '/IdentityFile/ {print $2}') local current_identity_file=$(echo "$host_info" | awk '/IdentityFile/ {print $2}')
local current_proxyjump=$(echo "$host_info" | awk '/ProxyJump/ {print $2}') local current_proxyjump=$(echo "$host_info" | awk '/ProxyJump/ {print $2}')
# Create backup of the original file
cp "$config_file" "$config_file.bak"
# Prompt for new values, defaulting to current values if no input is given # Prompt for new values, defaulting to current values if no input is given
read -p "HostName [$current_hostname]: " new_hostname read -p "HostName [$current_hostname]: " new_hostname
new_hostname=${new_hostname:-$current_hostname} new_hostname=${new_hostname:-$current_hostname}
@ -274,16 +368,32 @@ sshm_edit() {
new_identity_file=${new_identity_file:-${current_identity_file:-$default_identity_file}} new_identity_file=${new_identity_file:-${current_identity_file:-$default_identity_file}}
if [[ -n "$current_proxyjump" ]]; then if [[ -n "$current_proxyjump" ]]; then
read -p "ProxyJump [$current_proxyjump]: " new_proxyjump read -p "ProxyJump [$current_proxyjump] (enter 'none' to remove): " new_proxyjump
new_proxyjump=${new_proxyjump:-$current_proxyjump} if [[ "$new_proxyjump" == "None" || "$new_proxyjump" == "none" ]]; then
new_proxyjump=""
else
new_proxyjump=${new_proxyjump:-$current_proxyjump}
fi
else else
read -p "ProxyJump (leave empty if none): " new_proxyjump read -p "ProxyJump (leave empty if none): " new_proxyjump
fi fi
# Create a temporary file for the new content
local tmp_file
tmp_file=$(mktemp)
# Delete the old configuration # Delete the old configuration
sshm_delete "$config_file" "$host" true sed '/^Host '"$host"'$/,/^$/d' "$config_file" > "$tmp_file"
# Add the new configuration # Check if the temporary file is not empty
if [[ ! -s "$tmp_file" ]]; then
mv "$config_file.bak" "$config_file"
rm -f "$tmp_file"
echo -e "${RED}Error: Operation would result in empty file. Operation cancelled.${NC}" 1>&2
exit 1
fi
# Add the new configuration
{ {
echo "" echo ""
echo "Host $host" echo "Host $host"
@ -295,31 +405,32 @@ sshm_edit() {
if [[ "$new_identity_file" != "$default_identity_file" ]]; then if [[ "$new_identity_file" != "$default_identity_file" ]]; then
echo " IdentityFile $new_identity_file" echo " IdentityFile $new_identity_file"
fi fi
if [[ -n "$new_proxyjump" ]]; then if [[ -n "$new_proxyjump" && "$new_proxyjump" != "None" && "$new_proxyjump" != "none" ]]; then
echo " ProxyJump $new_proxyjump" echo " ProxyJump $new_proxyjump"
fi fi
} >> "$config_file" } >> "$tmp_file"
echo "Configuration for host $host updated successfully." # Move the temporary file to the final location
mv "$tmp_file" "$config_file"
rm -f "$config_file.bak"
echo -e "\n${GREEN}✓ Configuration for host $host updated successfully.${NC}"
} }
context_list() { context_list() {
local current_context echo -e "\n${BLUE}${BOLD}Available contexts:${NC}"
current_context=$(cat "$CURRENT_CONTEXT_FILE" 2>/dev/null || echo "$DEFAULT_CONFIG") if [[ "$SSHM_CONTEXT" == "$DEFAULT_CONFIG" ]]; then
echo -e "${GREEN}* default${NC}"
echo "Available contexts:"
if [[ "$current_context" == "$DEFAULT_CONFIG" ]]; then
echo "* default"
else else
echo " default" echo " default"
fi fi
for context in "$CONFIG_DIR"/*; do for context in "$CONFIG_DIR"/*; do
if [[ -f "$context" ]]; then # Vérifie que c'est bien un fichier existant if [[ -f "$context" ]]; then
local context_name local context_name
context_name=$(basename "$context") context_name=$(basename "$context")
if [[ "$CONFIG_DIR/$context_name" == "$current_context" ]]; then if [[ "$CONFIG_DIR/$context_name" == "$SSHM_CONTEXT" ]]; then
echo "* $context_name" echo -e "${GREEN}* $context_name${NC}"
else else
echo " $context_name" echo " $context_name"
fi fi
@ -330,62 +441,69 @@ context_list() {
context_use() { context_use() {
local context="$1" local context="$1"
if [[ -z "$context" ]]; then if [[ -z "$context" ]]; then
echo "Error: please provide a context name." 1>&2 echo -e "${RED}Error: please provide a context name.${NC}" 1>&2
exit 1 exit 1
fi fi
if [[ "$context" == "default" ]]; then if [[ "$context" == "default" ]]; then
echo "$DEFAULT_CONFIG" > "$CURRENT_CONTEXT_FILE" export SSHM_CONTEXT="$DEFAULT_CONFIG"
echo "Switched to default context."
elif [[ ! -f "$CONFIG_DIR/$context" ]]; then elif [[ ! -f "$CONFIG_DIR/$context" ]]; then
echo "Error: context '$context' does not exist." 1>&2 echo -e "${RED}Error: context '$context' does not exist.${NC}" 1>&2
exit 1 exit 1
else else
echo "$CONFIG_DIR/$context" > "$CURRENT_CONTEXT_FILE" export SSHM_CONTEXT="$CONFIG_DIR/$context"
echo "Switched to context '$context'."
fi fi
# Update the file for persistence between sessions
echo "$SSHM_CONTEXT" > "$CURRENT_CONTEXT_FILE"
echo -e "${GREEN}✓ Switched to context '$context'.${NC}"
# Update CONFIG_FILE for the current session
CONFIG_FILE="$SSHM_CONTEXT"
} }
context_create() { context_create() {
local context="$1" local context="$1"
if [[ -z "$context" ]]; then if [[ -z "$context" ]]; then
echo "Error: please provide a context name." 1>&2 echo -e "${RED}Error: please provide a context name.${NC}" 1>&2
exit 1 exit 1
fi fi
if [[ -f "$CONFIG_DIR/$context" ]]; then if [[ -f "$CONFIG_DIR/$context" ]]; then
echo "Error: context '$context' already exists." 1>&2 echo -e "${RED}Error: context '$context' already exists.${NC}" 1>&2
exit 1 exit 1
fi fi
touch "$CONFIG_DIR/$context" touch "$CONFIG_DIR/$context"
chmod 600 "$CONFIG_DIR/$context" chmod 600 "$CONFIG_DIR/$context"
echo "Context '$context' created." echo -e "${GREEN}Context '$context' created.${NC}"
} }
context_delete() { context_delete() {
local context="$1" local context="$1"
if [[ -z "$context" ]]; then if [[ -z "$context" ]]; then
echo "Error: please provide a context name." 1>&2 echo -e "${RED}Error: please provide a context name.${NC}" 1>&2
exit 1 exit 1
fi fi
if [[ ! -f "$CONFIG_DIR/$context" ]]; then if [[ ! -f "$CONFIG_DIR/$context" ]]; then
echo "Error: context '$context' does not exist." 1>&2 echo -e "${RED}Error: context '$context' does not exist.${NC}" 1>&2
exit 1 exit 1
fi fi
rm -f "$CONFIG_DIR/$context" rm -f "$CONFIG_DIR/$context"
echo "Context '$context' deleted." echo -e "${GREEN}Context '$context' deleted.${NC}"
if [[ "$(cat "$CURRENT_CONTEXT_FILE")" == "$CONFIG_DIR/$context" ]]; then # If the deleted context was the current one, switch to default
echo "$DEFAULT_CONFIG" > "$CURRENT_CONTEXT_FILE" if [[ "$SSHM_CONTEXT" == "$CONFIG_DIR/$context" ]]; then
echo "Switched to default context." export SSHM_CONTEXT="$DEFAULT_CONFIG"
echo "$SSHM_CONTEXT" > "$CURRENT_CONTEXT_FILE"
CONFIG_FILE="$SSHM_CONTEXT"
echo -e "${YELLOW}Switched to default context.${NC}"
fi fi
} }
sshm_main() { sshm_main() {
local config_file="$CONFIG_FILE"
local command="$1" local command="$1"
shift shift
@ -399,22 +517,22 @@ sshm_main() {
# Check if command is a known command, otherwise treat it as a host to connect to # Check if command is a known command, otherwise treat it as a host to connect to
case "$command" in case "$command" in
"list") "list")
sshm_list "$config_file" sshm_list
;; ;;
"ping") "ping")
sshm_ping "$config_file" "$@" sshm_ping "$CONFIG_FILE" "$@"
;; ;;
"view") "view")
sshm_view "$config_file" "$@" sshm_view "$CONFIG_FILE" "$@"
;; ;;
"delete") "delete")
sshm_delete "$config_file" "$@" sshm_delete "$CONFIG_FILE" "$@"
;; ;;
"add") "add")
sshm_add "$config_file" "$@" sshm_add "$@"
;; ;;
"edit") "edit")
sshm_edit "$config_file" "$@" sshm_edit "$@"
;; ;;
"context") "context")
local subcommand="$1" local subcommand="$1"
@ -433,7 +551,8 @@ sshm_main() {
context_delete "$@" context_delete "$@"
;; ;;
*) *)
echo "Error: invalid context subcommand." 1>&2 echo -e "${RED}Error: invalid context subcommand.${NC}" 1>&2
echo
sshm_help sshm_help
exit 3 exit 3
;; ;;
@ -447,7 +566,7 @@ sshm_main() {
;; ;;
*) *)
# If command is not recognized, treat it as a host name to connect to # If command is not recognized, treat it as a host name to connect to
sshm_connect "$config_file" "$command" sshm_connect "$CONFIG_FILE" "$command"
esac esac
} }