danielmiessler / fabric

fabric is an open-source framework for augmenting humans using AI. It provides a modular framework for solving specific problems using a crowdsourced set of AI prompts that can be used anywhere.
https://danielmiessler.com/p/fabric-origin-story
MIT License
25.29k stars 2.68k forks source link

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

Open caunus opened 2 months ago

caunus commented 2 months ago

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!

x-Jack-8276 commented 2 months ago

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

caunus commented 2 months ago

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

npayton77 commented 2 months ago

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

caunus commented 2 months ago

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}"
RFingAdam commented 2 months ago

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"

caunus commented 2 months ago

Great, thank you for this extra mile. Perfect!

xssdoctor commented 2 months ago

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]

RFingAdam commented 2 months ago

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

xssdoctor commented 2 months ago

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

RFingAdam commented 2 months ago

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

xssdoctor commented 2 months ago

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