├── README.md ├── LICENSE └── chat.sh /README.md: -------------------------------------------------------------------------------- 1 | # MacChat 2 | Mac-Mac P2P Chat via SSH terminal app. 3 | Offers Terminal-GUI chat. Terminal (/terminal emulator) on local end. GUI on remote end (Native macOS Dialog using Applescript). 4 | 5 | Features: 6 | - P2P Chat via SSH 7 | - Log chat 8 | # Usage 9 | Execute this from local on remote by running 10 | ```bash 11 | $ chmod a+x ./chat.sh 12 | $ ssh user@host.local "bash -s" < ./chat.sh "option1" "option2" "option3" 13 | ``` 14 | You can specify any of these options (on invoke): 15 | ```bash 16 | options: 17 | -h show this help text 18 | -t Recipient name 19 | -f Sender name 20 | -l Log chat (flag) 21 | 22 | Type "exit" in the chat to end the chat. 23 | ``` 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Habib Rehman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /chat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################################ 3 | # Mac-Mac P2P Chat via ssh # 4 | # (C) Habib Rehman 2XXX. # 5 | # MIT license # 6 | ################################################################################ 7 | 8 | LOG=false # Do not log by default 9 | TO="Recipient" # Default recipient 10 | FROM="Me" # Default sender 11 | 12 | function showOpts { 13 | echo "options:" 14 | echo " -h show this help text" 15 | echo " -t Recipient name" 16 | echo " -f Sender name" 17 | echo " -l Log chat" 18 | echo "" 19 | echo "Type \"exit\" in the chat to end the chat." 20 | } 21 | # Get args 22 | while getopts 't:f:lh' flag; do 23 | case "${flag}" in 24 | l) 25 | LOG=true 26 | LOG_FNAME="$FROM-$TO `date` chat.log" 27 | printf "=== $FROM-$TO chat log ===" >> "$LOG_FNAME" 28 | ;; 29 | t) TO="${OPTARG}" ;; 30 | f) FROM="${OPTARG}" ;; 31 | h) 32 | showOpts 33 | exit 34 | ;; 35 | *) 36 | echo "Unexpected option ${flag}" 37 | showOpts 38 | exit 39 | ;; 40 | esac 41 | done 42 | 43 | while [[ true ]]; do 44 | # Read message 45 | read -r -p "$FROM: " MESSAGE 46 | if [[ "$MESSAGE" != 'exit' ]]; then 47 | # Show dialog and get reply 48 | REPLY=$(osascript -e "return \"$TO: \" & text returned of (display dialog \"$FROM: $MESSAGE\" with title \"Chat\" default answer \"\" buttons {\"Reply\"} default button 1)") 49 | echo $REPLY 50 | if [[ "$LOG" == true ]]; then 51 | # log message and reply 52 | printf "\n$FROM: $MESSAGE\n$REPLY" >> "$LOG_FNAME" 53 | fi 54 | else 55 | break 56 | fi 57 | done 58 | 59 | # Execute this from local on remote by running 60 | # $ ssh user@host.local "bash -s" < ./chat.sh "arg1" "arg2" "arg3" 61 | --------------------------------------------------------------------------------