-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture_timestamp.sh
More file actions
70 lines (58 loc) · 3.03 KB
/
Copy pathcapture_timestamp.sh
File metadata and controls
70 lines (58 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Script to capture file timestamp before editing (Linux version)
# Usage: ./capture_timestamp.sh <file>
# This creates a .timestamp file that can be used later to restore the mtime
set -e # Exit on any error
# ANSI color codes for cross-platform compatibility
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
GRAY='\033[0;90m'
NC='\033[0m' # No Color
# Function to show banner
show_banner() {
echo ""
echo -e "${CYAN} ██████╗ ██╗ ██╗ ██████╗ ███████╗████████╗██╗ ██╗██████╗ ██╗████████╗███████╗${NC}"
echo -e "${CYAN} ██╔════╝ ██║ ██║██╔═══██╗██╔════╝╚══██╔══╝██║ ██║██╔══██╗██║╚══██╔══╝██╔════╝${NC}"
echo -e "${CYAN} ██║ ███╗███████║██║ ██║███████╗ ██║ ██║ █╗ ██║██████╔╝██║ ██║ █████╗ ${NC}"
echo -e "${CYAN} ██║ ██║██╔══██║██║ ██║╚════██║ ██║ ██║███╗██║██╔══██╗██║ ██║ ██╔══╝ ${NC}"
echo -e "${CYAN} ╚██████╔╝██║ ██║╚██████╔╝███████║ ██║ ╚███╔███╔╝██║ ██║██║ ██║ ███████╗${NC}"
echo -e "${CYAN} ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝${NC}"
echo ""
echo -e "${YELLOW} 👻 Edit files without leaving timestamp traces 👻${NC}"
echo -e "${GRAY} https://logisek.com | info@logisek.com${NC}"
echo -e "${GRAY} https://github.com/Logisek/GhostWrite${NC}"
echo ""
}
# Function to show usage
usage() {
echo "Usage: $0 <file>"
echo "Example: $0 document.docx"
echo ""
echo "This script captures the current file modification time to a .timestamp file"
echo "for later restoration after editing."
exit 1
}
# Check if file argument is provided
if [ $# -ne 1 ]; then
usage
fi
TARGET_FILE="$1"
TIMESTAMP_FILE="${TARGET_FILE}.timestamp"
# Show banner
show_banner
# Check if file exists
if [ ! -f "$TARGET_FILE" ]; then
echo "Error: File '$TARGET_FILE' does not exist"
exit 1
fi
# Get current modification time (Linux format)
CURRENT_MTIME=$(stat -c %Y "$TARGET_FILE")
CURRENT_DATE=$(date -d @$CURRENT_MTIME)
# Save timestamp to file
echo "$CURRENT_MTIME" > "$TIMESTAMP_FILE"
echo "✓ Captured timestamp for: $TARGET_FILE"
echo " Modification time: $CURRENT_DATE"
echo " Saved to: $TIMESTAMP_FILE"
echo ""
echo "Now you can edit $TARGET_FILE in any application."
echo "After saving, run: ./restore_timestamp.sh '$TARGET_FILE'"