Unix

Contents

Unix#

1#

#!/bin/bash

# Create the bdncsv directory if it doesn't exist
mkdir -p bdncsv

# Find and move all .csv files into the bdncsv directory
find . -maxdepth 1 -type f -iname "*.csv" -exec mv {} bdncsv/ \;

2#

#!/bin/bash

# Create the bdnimages directory if it doesn't exist
mkdir -p bdnimages

# Find and move all .jpg, .jpeg, and .png files into the bdnimages directory
find . -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec mv {} bdnimages/ \;

3#

#!/bin/bash

# Create the bdnpdfs directory if it doesn't exist
mkdir -p bdnpdfs

# Find and move all .pdf files into the bdnpdfs directory
find . -maxdepth 1 -type f -iname "*.pdf" -exec mv {} bdnpdfs/ \;

4#

#!/bin/bash

# Create the bdnpy directory if it doesn't exist
mkdir -p bdnpy

# Find and move all .py files into the bdnpy directory
find . -maxdepth 1 -type f -iname "*.py" -exec mv {} bdnpy/ \;

4#

#!/bin/bash

# Create the bdnsh directory if it doesn't exist
mkdir -p bdnsh

# Find and move all .sh files into the bdnsh directory
find . -maxdepth 1 -type f -iname "*.sh" -exec mv {} bdnsh/ \;

5#

#!/bin/bash

# Function to reset to a clean state.
reset_state() {
    # Abort any ongoing rebase.
    git rebase --abort &> /dev/null && echo "Aborted an ongoing rebase."

    # Stash any unstaged changes to ensure operations can proceed.
    git stash save "Unstaged changes before running githis.sh" && echo "Stashed unsaved changes."

    # Remove any lingering rebase directories.
    if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then
        rm -rf .git/rebase-*
        echo "Removed lingering rebase directories."
    fi
}

# Navigate to the main working directory.
cd ~/dropbox/1f.ἡἔρις,κ/1.ontology

# Navigate to the six100 directory.
cd six100 || { echo "Directory six100 does not exist. Exiting."; exit 1; }

# Reset to a clean state.
reset_state

# Fetch the latest changes from temp_og_repo using SSH.
if git fetch git@github.com:afecdvi/temp_og_repo.git main; then
    echo "Successfully fetched changes via SSH."
else
    echo "Failed to fetch changes using SSH. Exiting."
    exit 1
fi

# Reset the local branch to match the fetched changes.
git reset --hard FETCH_HEAD
echo "Local branch reset to match fetched changes."

# Check for network connection.
if ! ping -c 1 google.com &> /dev/null; then
    echo "No internet connection. Exiting."
    exit 1
fi

# Check repository size.
REPO_SIZE=$(du -sh .git | cut -f1)
echo "Repository size: $REPO_SIZE"

# Adjust Git configurations.
POST_BUFFER_SIZE=$(( (RANDOM % 200 + 300) * 1048576 ))
LOW_SPEED_LIMIT=$(( RANDOM % 5000 + 2000 ))
LOW_SPEED_TIME=$(( RANDOM % 60 + 30 ))

git config http.postBuffer $POST_BUFFER_SIZE
git config http.lowSpeedLimit $LOW_SPEED_LIMIT
git config http.lowSpeedTime $LOW_SPEED_TIME
echo "Adjusted Git's buffer size to $POST_BUFFER_SIZE, low speed limit to $LOW_SPEED_LIMIT and low speed time to $LOW_SPEED_TIME."

# Push the changes to the remote repository using SSH and verbose logging.
if git push git@github.com:afecdvi/og.git main --force -v; then
    echo "Successfully pushed changes using SSH."
    # Unstash any changes we stashed earlier.
    git stash pop &> /dev/null && echo "Restored previously stashed changes."
    echo "Script completed successfully!"
else
    echo "Failed to push changes even with SSH. Exiting."
    git stash pop &> /dev/null && echo "Restored previously stashed changes."
    exit 1
fi

6#

#!/bin/bash

# Change to the morality directory
cd morality

# Loop through all items in the directory
for item in *; do
    # Check if the item is a directory and not "kitabo"
    if [ -d "$item" ] && [ "$item" != "kitabo" ]; then
        # Remove all contents of the directory
        rm -rf "$item"/*
        echo "Deleted contents of $item"
    fi
done

echo "Finished deleting directory contents"

7#

#! /bin/bash

# setup tidy work directory
read -p "Enter your root directory (default: /documents/rhythm): " ROOT_DIR
ROOT_DIR=${ROOT_DIR:-/documents/rhythm}

read -p "Enter the name of the subdirectory that archives .sh scripts (default: new): " SUBDIR_NAME
SUBDIR_NAME=${SUBDIR_NAME:-new}

cd ~/$ROOT_DIR && rm -rf * && git clone https://github.com/abikesa/workflow && mv workflow $SUBDIR_NAME && $SUBDIR_NAME/setup_myenv.sh && source myenv/bin/activate

# template as starting point
read -p "Enter template GitHub repository name (default: template-repo): " REPO_NAME
REPO_NAME=${REPO_NAME:-haydn}

git clone https://github.com/abikesa/$REPO_NAME
mv $REPO_NAME local
cd local/kitabo/ensi
echo "Make updates to $ROOT_DIR/local"

8#

git clone https://github.com/abikesa/template