From 348042a1ca2f28a900eea19ad8d86f3ec16590af Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 13 Jan 2025 08:29:53 +0800 Subject: [PATCH] update scripts --- rua-scripts/rua-tag.sh | 83 ++++++++++++++++++++++++++++++++++++++ rua-scripts/ssh-forward.sh | 4 ++ tmux/tmux.conf | 3 +- zsh/zshrc | 2 + 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 rua-scripts/rua-tag.sh create mode 100644 rua-scripts/ssh-forward.sh diff --git a/rua-scripts/rua-tag.sh b/rua-scripts/rua-tag.sh new file mode 100644 index 0000000..a3c7bbe --- /dev/null +++ b/rua-scripts/rua-tag.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Function to tag and push a Docker image +# Example usage +# tag_and_push gitlab/gitlab-runner +tag_and_push() { + if [ -z "$1" ]; then + echo "Usage: tag_and_push " + return 1 + fi + + # Set variables + local IMAGE_NAME=$1 + local TARGET_IMAGE="192.168.1.57:8004/$IMAGE_NAME" + + # Tag the Docker image + echo "Tagging image: $IMAGE_NAME as $TARGET_IMAGE" + docker tag "$IMAGE_NAME" "$TARGET_IMAGE" + + # Push the Docker image + echo "Pushing image: $TARGET_IMAGE" + docker push "$TARGET_IMAGE" + + if [ $? -eq 0 ]; then + echo "Image successfully tagged and pushed: $TARGET_IMAGE" + else + echo "Failed to push the image: $TARGET_IMAGE" + return 2 + fi +} + +check_client() { + if [ -d "$FOLDER_PATH" ]; then + return 0 + else + return 1 + fi +} + +build_lib() { + if [ -z "$1" ]; then + echo "Usage: build_lib " + return 1 + fi + + VERSION=$1 + METHOD=$2 + + case $VERSION in + v2) + echo "Building lib v2" + FOLDER_PATH="../show-client-v2/src/show/lib/" + check_client + if [ $? -ne 0 ]; then + echo "Show-client v2 not found" + return -1 + fi + setopt rm_star_silent + npx gulp $METHOD + rm -rf "$FOLDER_PATH/*" + cp -aR lib/* $FOLDER_PATH + echo 'Copy done' + ;; + v3) + echo "Building lib v3" + FOLDER_PATH="../show-client/src/show/lib/" + check_client + if [ $? -ne 0 ]; then + echo "Show-client v3 not found" + return -1 + fi + setopt rm_star_silent + npx gulp $METHOD + rm -rf "$FOLDER_PATH/*" + cp -aR lib/* $FOLDER_PATH + echo 'Copy done' + ;; + *) + echo "Invalid version: $1" + return 2 + ;; + esac +} diff --git a/rua-scripts/ssh-forward.sh b/rua-scripts/ssh-forward.sh new file mode 100644 index 0000000..cc52d7c --- /dev/null +++ b/rua-scripts/ssh-forward.sh @@ -0,0 +1,4 @@ +#!/bin/env bash + +# 16 mysql +ssh -f -N -L 192.168.1.57:3306:localhost:3306 16 diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 930545a..0bc5f96 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -29,7 +29,8 @@ setw -g pane-base-index 1 # Enable mouse support set -g mouse on - +# forward slash +# bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" # ========================== # === Key bindings === diff --git a/zsh/zshrc b/zsh/zshrc index e6de01f..7feb35f 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -109,6 +109,8 @@ if [ -r $RUA_SCRIPT_DIR/xdg-startup.sh ]; then source ~/.config/rua-scripts/xdg-startup.sh source ~/.config/rua-scripts/docker.sh source ~/.config/rua-scripts/show-client.sh + source ~/.config/rua-scripts/rua-tag.sh + source ~/.config/rua-scripts/ssh-forward.sh fi # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.