- Added command to clear clipboard history (`cmd_clear.go`). - Implemented command to copy a history item back to the clipboard (`cmd_copy.go`). - Created command to list clipboard history (`cmd_list.go`). - Developed command to watch clipboard changes and store history (`cmd_watch.go`). - Introduced configuration loading for logging and clipboard settings (`config.go`). - Established main application logic with command registration and configuration handling (`main.go`). - Implemented history management with loading, saving, and clearing functionality (`history.go`). - Defined history item structure to store clipboard data (`history_item.go`). - Added utility functions for hashing data and summarizing clipboard content (`hash.go`, `summary.go`). - Updated dependencies in `go.sum`.
49 lines
1.6 KiB
Bash
Executable File
49 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
BINARY_NAME=$1
|
|
BINARY_PATH=$2
|
|
COMPLETION_SCRIPT=$3
|
|
BINARY_PATH_VERSION=$BINARY_PATH.version
|
|
|
|
source bin/helpers/func.sh
|
|
|
|
# Check if HEAD is clean, if not abort
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
printfe "%s\n" "yellow" "You have uncomitted and/or untracked changes in your working directory."
|
|
fi
|
|
|
|
# Get the current tag checked out to HEAD and hash
|
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
|
LATEST_COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
|
|
LATEST_TAG_HASH=$(git rev-list -n 1 --abbrev-commit $LATEST_TAG 2>/dev/null)
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
|
|
# If BRANCH is HEAD and latest commit hash equals latest tag hash, we are on a tag and up to date
|
|
if [ "$BRANCH" == "HEAD" ] && [ "$LATEST_COMMIT_HASH" == "$LATEST_TAG_HASH" ]; then
|
|
BRANCH=$LATEST_TAG
|
|
fi
|
|
|
|
# In case the current head has uncomitted and/or untracked changes, append a postfix to the version saying (dirty)
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
POSTFIX=" (dirty)"
|
|
fi
|
|
|
|
printfe "%s\n" "cyan" "Building $BINARY_NAME binary for $BRANCH ($LATEST_COMMIT_HASH)$POSTFIX..."
|
|
go build -o $BINARY_PATH ./src
|
|
|
|
if [ $? -ne 0 ]; then
|
|
printf "\033[0;31m"
|
|
echo "Build failed."
|
|
printf "\033[0m"
|
|
exit 1
|
|
fi
|
|
|
|
# Put tag and hash in .kcm_version file
|
|
echo "$BRANCH ($LATEST_COMMIT_HASH)$POSTFIX" > $BINARY_PATH_VERSION
|
|
|
|
printfe "%s\n" "cyan" "Generating Bash completion script..."
|
|
$BINARY_PATH completion bash > $COMPLETION_SCRIPT
|
|
|
|
printfe "%s\n" "green" "Bash completion script installed to $COMPLETION_SCRIPT."
|
|
printfe "%s\n" "green" "Restart or 'source ~/.bashrc' to update your shell."
|