How to check if a file is sourced in Bash

Sometimes you will want to ensure that a file is sourced instead of executed. This ensures, among other things, that any environment variables that the script defines remain in your current shell after the script completes.

To do so, use the following to check whether the file was sourced or run in a sub-shell

(return 0 2/dev/null) && sourced=1 || sourced=0
echo "sourced=$sourced"

Bash allows return statements only from functions and in a scripts top level scope IF it → Continue reading “How to check if a file is sourced in Bash”

Pruning directories from find

I have no idea why, but for some reason I always have a hard time remembering the exact syntax for find when I want to prune some list of directories from a search.

Let’s say that you want to execute a find in a directory where there are a lot of .git directories and you don’t want to search through the guts of the repo directories. With the following command we specify the prune predicate ahead of the search for → Continue reading “Pruning directories from find”

Using cut with a delimiter of any amount of whitespace

The TLDR; is to first use tr to replace all occurrences of any horizontal whitespace character with a single space, and then squeeze down any number of spaces to a single space and then define the delimiter for cut as a single space. The following example assumes that you want to see from the 5th column to the end of the line.

<do-something-to-generate-input| tr '[:blank:]' ' ' | tr -s ' ' | cut -d ' ' -f5-

The → Continue reading “Using cut with a delimiter of any amount of whitespace”

Pumpkin Pie

This recipe is for pumpkin pie made from fresh pumpkin. I have not tried swapping out the pumpkin for the same volume of canned pumpkin. I typically use a Cheese or Galeux d’Eysines pumpkin. The former is a squat, grey colored pumpkin that looks like a cheese wheel and the latter like it was grown in Chernobyl and is grey covered in what can best be described as warts. The more ‘warts’ the sweeter they are. They are both delicious.→ Continue reading “Pumpkin Pie”

Pasta-Bean Soup with Fresh Herbs

Ingredients

  • 2 cups sliced fresh mushrooms
  • 1 medium onion, chopped
  • 2 cloves garlic, minced
  • 1 tablespoon margarine or butter
  • 2 14%-ounce cans vegetable, chicken, or beef broth
  • 4 cup small pasta shells
  • 1 16-ounce can tomatoes, cut up
  • 1 15-ounce can garbanzo beans, rinsed and drained
  • 1/4 cup snipped fresh basil
  • 1 tablespoon snipped fresh thyme
  • Fresh basil sprigs (optional)

Directions

In a large saucepan or Dutch oven cook the mushrooms, onion, and garlic in hot margarine or butter till → Continue reading “Pasta-Bean Soup with Fresh Herbs”

Four Bean Enchiladas

Ingredients

  • 16 6-inch corn tortillas
  • 1 15-ounce can red kidney beans, rinsed and drained
  • 1 15-ounce can garbanzo beans, rinsed and drained
  • 1 15-ounce can pinto beans, rinsed and drained
  • 1 15-ounce can navy or great northern beans, rinsed and drained
  • 1 11-ounce can condensed cheddar cheese or nacho cheese soup, or 10 ounces of cheddar cheese
  • 1 10-ounce can enchilada sauce
  • 1 8-ounce can tomato sauce
  • 14 cups shredded Monterey Jack or cheddar cheese (6 ounces)
  • Sliced pitted ripe
Continue reading “Four Bean Enchiladas”

Spinach and Rice Caserole

Ingredients

  • 1 small onion, chopped (4 cup)
  • 1 clove garlic, minced
  • 1 tablespoon cooking oil
  • 1 14-ounce can peeled Italian-style tomatoes, cut up
  • 1 teaspoon dried oregano or basil,crushed
  • 8 ounces tofu, drained
  • 2 cups cooked brown rice
  • 1 10-ounce package frozen chopped spinach, thawed and well drained
  • A cup shredded Swiss cheese (2 ounces)
  • A teaspoon salt
  • A teaspoon pepper
  • 1 tablespoon sesame seed, toasted

Directions

In a large saucepan cook the onion and garlic in hot oil till → Continue reading “Spinach and Rice Caserole”

[SOLVED] What is the right type of glue for heated motorcycle grips?

Last winter I finally put a set of heated grips on my street bike. I went with a variable setting model from Koso, which happens to make all sorts of awesome electrical components for motorcycles. They suggested using Krazy glue to adhere them to the clipon and throttle and I did not want to go that way. I read a number of posts that suggested using regular grip glue or hairspray. I tried both and they didn’t work. As soon → Continue reading “[SOLVED] What is the right type of glue for heated motorcycle grips?”

Mexican Casserole and Sliced Avocados

You can use either boneless chicken breasts, beans, or other meat substitute for the protein

Ingredients

  • Additional protein: choose from one of the following
    • 3 boneless skinless chicken breasts
    • Equivalent mass of cooked chick peas or vegetarian meat substitute
  • 1 cup sour cream
  • 1 cup salsa
  • 4 green onions
  • 1/2 cup cream cheese
  • 2 cups shredded Monterey Jack cheese
  • 4 4-ounce can diced green chilies
  • 4 corn tortillas
  • 1 15-ounce can black beans – rinsed and drained
  • 2 ripe avocados
Continue reading “Mexican Casserole and Sliced Avocados”

Spaghetti Squash, Spinach and Turkey Sausage Lasagna

Ingredients

  • 2 small or 1 large spaghetti squash
  • 4 TB olive oil
  • 4 garlic cloves, minced
  • 1 cup onions, diced
  • 1 cup red peppers, diced
  • 8 oz fresh spinach
  • 1/2 cup part-skim ricotta cheese
  • 1 cup shredded mozzarella cheese, divided
  • 1 lb. ground mild Italian turkey sausage, or vegetarian sausage
  • 2 cups marinara sauce
  • Red pepper flakes, use amount based on desired spice/heat level
  • 1/4 cup parmesan cheese

Instructions

  1. Preheat oven to 425° and line a large baking sheet with
Continue reading “Spaghetti Squash, Spinach and Turkey Sausage Lasagna”