-- Leo's gemini proxy

-- Connecting to nuacht.flounder.online:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8

aliases


In .bashrc, you can say something like

alias l='ls --color=auto'

and you can then just type 'l' followed by return to run the ls command.



For something more advanced, you can have an alias call a script to check a conditition before allowing the command to run. This is helpful in my git sandbox where the index.html file is sometimes a dummy file, since it faces the internet. I don't want to check that in by accident - I want to swap the dummy for the real one before git ever executes anything.


So my alias for git now calls a script to handle all of this. Typing git from a bash terminal, or any terminal that uses .bashrc will do this:

alias git='/home/pi/bin/gitcheck.sh'

Then the script itself checks the contents of index.html for the contents that are in the real file. If they are there, it also checks that the file size is above 100k, since this is also a property of the real file. The dummy file is tiny in comparison. I'm then confident to let git do it's thing, which I do by calling it with the $ parameters to include up to five arguments. I assume five is enough:

#!/bin/bash

# git should not check in our dummy index.html to the optimumhealth.ie repo
# so if it  doesn't contain text we know should be there,  it's the dummy and we abort
res=$(  grep -i "optimum health" /home/pi/http/oh.ie/index.html | wc -w  )
if [ $res == 0 ]; then
  echo "You can't use git while the wrong index.html is in place"; exit;
elif [ $(wc -c < /home/pi/http/oh.ie/index.html) > 100000 ]; then
  echo "Index is large and contains our keywords. Note: git limited to 5 arguments by bin/gitcheck.sh";
  git $1 $2 $3 $4 $5;
fi
bin/gitcheck.sh (END)

Now when I try to run a git command with the dumming index file in place, it saves me:

You can't use git while the wrong index.html is in place

But when the correct index file is in place, it allows the git commands to be executed:

$ git status
Index is large and contains our keywords. Note: git limited to 5 arguments by bin/gitcheck.sh
On branch main
Your branch is up to date with 'origin/main'.

...

no changes added to commit (use "git add" and/or "git commit -a")

-- Response ended

-- Page fetched on Tue May 21 21:06:53 2024