BASH script: Functions and Conditionals
#!/usr/bin/bash
latest_commit=$(git log origin/master --pretty=format:"%H" -n 1)
lastPosts=$(git diff-tree --no-commit-id --name-only -r $latest_commit)
publish_prompt() {
local myPost="$1"
glow "$myPost"
cat "$myPost"
echo "Publish to LinkedIn?"
echo "1. Publish as is"
echo "2. Publish a link with a short text"
echo "No"
read num
}
publish_post() {
if [[ $num -eq 1 ]]; then
echo "Publish body to LinkedIn as a micropost"
elif [[ $num -eq 2 ]]; then
echo "Prompt user for text, get body of post, micropost text with link"
else
echo "Never mind."
fi
}
for myPost in $lastPosts; do
publish_prompt "$myPost"
publish_post
done
Published on 22 Apr 2024
all tags
100daysofcode activerecord android annoyances api apt arch array artix atom az3w backend bash blog browser bug callback career ci-cd cli cloud code coding config configuration cp crud cryptography css csv database db design devops django docker email erp feelsgood filter fugitive gif gist git gnome gnome pomodoro grep hebrew http ide isbn-fetcher iso javascript job search js kanban kindle koans learning linkedin linux logger manjaro map markdown microservices mobi mtp neovim nodejs nvchad packages panda pastbin patch portfolio post postgres pytest python rails reduce refactoring reflections rest routes rspec ruby salesforce script scripting security sed shell sql string_replacement study tdd terminal testing tmux ttd version_control vim vim sort walkthrough webdev workflow zsh