Skip to content

Instantly share code, notes, and snippets.

@meodai
Last active April 2, 2024 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meodai/c4b0a8c7c97264cbd374be6e250c8aa1 to your computer and use it in GitHub Desktop.
Save meodai/c4b0a8c7c97264cbd374be6e250c8aa1 to your computer and use it in GitHub Desktop.
terminal helpers: A collection of fish / sometimes bash scripts that help me make life a bit easier
function ..
cd ..
end
function apatschi
npx browser-sync start --server --files "**/*.css, **/*.html, **/*.js"
end
# cd to wherever your OSX finder is
function cdf
set -l target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
if test "$target" != ""
cd "$target"
pwd
else
echo 'No open OSX Finder window found' >&2
end
end
#!/bin/bash
OLLAMAMODEL="mistral"
# check if ollama is installed
if ! [ -x "$(command -v ollama)" ]; then
echo 'Error: ollama is not installed. Get it from https://ollama.com/' >&2
exit 1
fi
# check if git is installed
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.' >&2
exit 1
fi
# check if anything is staged
if [ -z "$(git status --porcelain)" ]; then
echo 'No changes to commit.' >&2
exit 1
fi
STATUS=$(git status -v)
ollamacommitmsg() {
OLLAMAMSG="
Imagine being a developer, you just wrote some code and you're ready to commit
it. You run 'git status -v' and see the following changes. Summerize the
changes as a commit message that could be used to commit these changes.
Imperative writing.
$STATUS
"
# feed the changes to ollama using git status -v
OLLAMAMESSAGE=$(echo $OLLAMAMSG | ollama run $OLLAMAMODEL)
# remove eventual "Commit message:" string from the OLLAMAMESSAGE
OLLAMAMESSAGE=$(echo $OLLAMAMESSAGE | sed 's/Commit message://g')
# echo the OLLAMAMESSAGE
echo $OLLAMAMESSAGE
}
ollamacommitmsg
# Exit the script with a success status
exit 0
#!/bin/bash
tv7 () {
echo "Fetching new playlist"
TVCURL=$(curl --fail https://api.init7.net/tvchannels.xspf -o ~/Movies/Fiber7.TV.tmp.xspf)
if [[ $TVCURL ]]; then
echo "Refreshing playlist"
if [[ -e ~/Movies/Fiber7.TV.xspf ]]; then
rm ~/Movies/Fiber7.TV.xspf
fi
if [[ -e ~/Movies/Fiber7.TV.tmp.xspf ]]; then
mv ~/Movies/Fiber7.TV.tmp.xspf ~/Movies/Fiber7.TV.xspf
fi
else
echo "
Fetching new playlist failed, using cached one,
if it does not work it is likely that you are not on a init7 connection,
consider VPN'ing home or using a different connection.
"
fi
open -a vlc ~/Movies/Fiber7.TV.xspf
#/Applications/VLC.app/Contents/MacOS/VLC -I rc ~/Movies/Fiber7.TV.xspf
}
tv7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment