Fabric icon indicating copy to clipboard operation
Fabric copied to clipboard

[Question]: Where are the save and tr commands?

Open caunus opened this issue 1 year ago • 11 comments
trafficstars

What is your question?

Will the save and tr commands be added in a future version, or will they be provided as a separate repository like yt? By the way, it would be great if the README mentioned that yt needs to be installed separately. Thanks!

caunus avatar Aug 18 '24 16:08 caunus

By the way, it would be great if the README mentioned that yt needs to be installed separately. Thanks!

It does.

https://github.com/danielmiessler/fabric/blob/main/README.md#yt-installation

x-Jack-8276 avatar Aug 18 '24 16:08 x-Jack-8276

ok, I found it in the first in the Issues. I apologize for missing this, in the readme.

caunus avatar Aug 18 '24 16:08 caunus

Still would like to see the save command come back or have the output option read the .env output path.

npayton77 avatar Aug 21 '24 02:08 npayton77

Meanwhile, I created a small shell script as a substitute. Save it as save in a folder that is part of your $PATH (in my case, I use $HOME/.local/bin) and make it executable with chmod +x $HOME/.local/bin/save. That should work. If anyone has a replacement for the tr command, please let me know.

#!/bin/zsh

# Define the directory where the file will be saved
TARGET_DIR="$HOME/markdown_files"

# Create the directory if it doesn't exist
mkdir -p "$TARGET_DIR"

# Set the current date as a prefix for the filename
DATE_PREFIX=$(date +"%Y-%m-%d")

# Set the base filename
BASENAME="note"
EXTENSION=".md"

# Generate the initial filename
FILENAME="${DATE_PREFIX}-${BASENAME}${EXTENSION}"

# Check if the file exists and find an incremental number
COUNTER=1
while [[ -e "${TARGET_DIR}/${FILENAME}" ]]; do
    FILENAME="${DATE_PREFIX}-${BASENAME}-${COUNTER}${EXTENSION}"
    COUNTER=$((COUNTER + 1))
done

# Read the text from the pipe and save it to the file
cat > "${TARGET_DIR}/${FILENAME}"

caunus avatar Aug 21 '24 10:08 caunus

Meanwhile, I created a small shell script as a substitute. Save it as save in a folder that is part of your $PATH (in my case, I use $HOME/.local/bin) and make it executable with chmod +x $HOME/.local/bin/save. That should work. If anyone has a replacement for the tr command, please let me know.

#!/bin/zsh

# Define the directory where the file will be saved
TARGET_DIR="$HOME/markdown_files"

# Create the directory if it doesn't exist
mkdir -p "$TARGET_DIR"

# Set the current date as a prefix for the filename
DATE_PREFIX=$(date +"%Y-%m-%d")

# Set the base filename
BASENAME="note"
EXTENSION=".md"

# Generate the initial filename
FILENAME="${DATE_PREFIX}-${BASENAME}${EXTENSION}"

# Check if the file exists and find an incremental number
COUNTER=1
while [[ -e "${TARGET_DIR}/${FILENAME}" ]]; do
    FILENAME="${DATE_PREFIX}-${BASENAME}-${COUNTER}${EXTENSION}"
    COUNTER=$((COUNTER + 1))
done

# Read the text from the pipe and save it to the file
cat > "${TARGET_DIR}/${FILENAME}"

Thanks for this. Changing the # Set the base filename section to the following allows for custom file names in quotes, similar to the previous command:

# Check if a custom filename was provided
if [[ -n "$1" ]]; then
    BASENAME="$1"
else
    BASENAME="note"
fi

EXTENSION=".md"

Usage: ➜ ~ echo "This is a test" | save ➜ ~ echo "This is a test" | save "Test Note"

RFingAdam avatar Aug 22 '24 14:08 RFingAdam

Great, thank you for this extra mile. Perfect!

caunus avatar Aug 22 '24 14:08 caunus

Hey guys. I don't understand the purpose of this command. The -o flag already exists in fabric and you can save the output anywhere on your whole computer

fabric -o [path to save to]

xssdoctor avatar Aug 22 '24 15:08 xssdoctor

Consistency to what existed previously, ease of use, don't have to retype the path or save as variable or something. Just type "save" and it does everything. It seems to be missed, even if it is slightly redundant, it was easy to add the path to the config and just use the save command. For some reason the -o flag didn't save to the path I was using after hours of trying too, where this script worked.

Thanks, Adam

RFingAdam avatar Aug 22 '24 15:08 RFingAdam

so if you type in echo hi | fabric -o /tmp/hi.txt that doesn't save to /tmp/hi.txt?

xssdoctor avatar Aug 22 '24 15:08 xssdoctor

That directory works. This particular instance I was testing in is a Windows Subsystem for Linux, so I was trying to save to /mnt/c/Users/user/Documents/AI Notes/0 - Inbox/Fabric/hi.txt.

-Looking at it again, I realize the -o command stops at /AI and doesn't process the 'spaces'. So, I could rename my directory to AI_Notes/0-Inbox/Fabric, and it would likely work as expected. I guess the script happened to accept spaces in the directory name.

Adam

RFingAdam avatar Aug 22 '24 15:08 RFingAdam

I'm pretty sure you can do "\ " for a space. That's how it works in Linux

xssdoctor avatar Aug 22 '24 15:08 xssdoctor

Closing this issue. -o answers the original question.

ksylvan avatar Aug 26 '25 15:08 ksylvan