-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,28 @@ | ||
# GitSlick | ||
My personal chat with myself | ||
The miniature single-file Git based chat client | ||
|
||
GitSlick is a simple chat client, in a single bash file, that transfers commit messages via a Git server. | ||
|
||
I created GitSlcik mostly for sending messages to myself from one machine to another, mostly for use | ||
on e.g. customer machines where I can't use our own company Slack, and may be limited in what other tools | ||
I can install. | ||
|
||
GitSlick only requires a terminal, bash and a reasonably new Git (> 2.27 I would guess), which should never | ||
be a problem anywhere I work. | ||
|
||
DISCLAIMER: This is VERY bare-bones with very little error handling or safety features. I am assuming you are qualified to understand how this tool works. I strongly suggest reading the entire script. The tool WILL make commits to whatever Git repo you are currently in when you run it, and try to push them, even if it is your production source code or a very public Open Source Repo that you happen to have push rights to. Consider yourself warned. | ||
|
||
## Using | ||
Clone this repo, or simply download the chat.sh file, place it somewhere reachable on your machine and make it executable. | ||
|
||
Create a Git repo somewhere that is reachable for all participants. It could be a private repo on GitHub, or | ||
just a local git server on a machine at home if you are only chatting with yourself. | ||
This will be your "chat server". | ||
|
||
Clone this repo to your machine, using credentials that have push rights. (I personally prefer ssh). | ||
|
||
cd into this chat directory, and start up chat.sh (from your PATH if you have made that choice, or e.g. `../chat.sh`). | ||
|
||
The tool prints out initial instructions for you to read, so please do that :-) | ||
|
||
Every chat message is an empty commit to the repo, and is immediately pushed to the remote. There is no async refresh, but every time you type something (a slash command or a message), it will fetch and print any incomming messages. Just pressing `<enter>` counts as a NO-OP that just fetches latest messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
CYAN='\033[0;36m' | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
RC='\033[0m' # Reset Color | ||
echo -e "${CYAN}Welcome to GitSlick, the Git based miniature chat app.${RC}" | ||
echo | ||
echo "Commands:" | ||
echo -e "${GREEN}/quit${RC} (to quit chat)" | ||
echo -e "${GREEN}/switch <channel name>${RC} (to change #channel" | ||
echo -e "${GREEN}/create <channel name>${RC} (to create a new #channel)" | ||
echo -e "${GREEN}/list${RC} (to list channels)" | ||
echo -e "${GREEN}/repeat [n]${RC} (repeat last n messages - default 5)" | ||
echo "Anything else is treated as a chat message. It will be commited to current dir git repo and pushed immediately to origin" | ||
echo "with NO safety checks or error handling". | ||
echo | ||
echo "NOTE: Currently only really supports single line messages. Behaviour undefined if pasting multiline content." | ||
echo | ||
echo -e "You are currenty in folder ${RED}$(pwd)${RC}" | ||
echo -e "And pushing to ${RED}$(git remote get-url origin --push)${RC}" | ||
echo | ||
git fetch --quiet | ||
git log --pretty="format:%C(green)%aN %C(blue)[%ad]%C(reset)%n%B" --date=relative ..@{u} | ||
git merge --ff-only --quiet | ||
while true ; do | ||
while IFS=" " read -r -e -p "$(git branch --show-current)> " cm options; do | ||
#echo "[$cm] [$options]" | ||
git fetch --quiet | ||
git log --pretty="format:%C(green)%aN %C(blue)[%ad]%C(reset)%n%B" --date=relative ..@{u} | ||
git merge --ff-only --quiet | ||
echo | ||
if [ "$cm" = "" ]; then | ||
: | ||
elif [ "$cm" = "/quit" ]; then | ||
exit 0 | ||
elif [ "$cm" = "/switch" ]; then | ||
git switch --quiet "$options" | ||
echo "Showing last 5 messages in $options" | ||
git log -5 --pretty="format:%C(green)%aN %C(blue)[%ad]%C(reset)%n%B" --date=relative | ||
elif [ "$cm" = "/list" ]; then | ||
echo -e "Existing channels: (use ${GREEN}/switch <channelname>${RC} to change channel" | ||
git branch -a | ||
elif [ "$cm" = "/create" ]; then | ||
echo "Creating new channel $options" | ||
git switch --quiet --orphan "$options" | ||
git commit --allow-empty --message "Beginning of Channel $options" | ||
git push --set-upstream origin "$options" | ||
elif [ "$cm" = "/repeat" ]; then | ||
: "${options:=5}" | ||
echo -e "Repeating last $options messages in ${RED}$(git branch --show-current)${RC}" | ||
git log "-$options" --pretty="format:%C(green)%aN %C(blue)[%ad]%C(reset)%n%B" --date=relative | ||
else | ||
message="$cm $options" | ||
git commit --quiet --allow-empty --message "$message" | ||
git log -1 --pretty="format:%C(green)%aN %C(blue)[%ad]%C(reset)%n%B" --date=relative | ||
git push --quiet origin | ||
fi | ||
done | ||
done |