Last active
January 8, 2022 17:32
-
-
Save nongiach/0a7231896108370c6ec0c42a3d3f1c82 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Author: @chaignc | |
# Two commands in this script: | |
# record2discord => send all typed bash command to your discord channel, see bellow for the blacklist | |
# last2discord => send the last typed command to your discord channel. | |
DISCORD_WEBHOOK_URL="Your_Discord_WebHook_URL" # UPDATE this with your web hook (take 2 minutes and read about this online) | |
_send2discord() { | |
# Blacklist some commands | |
[[ ! $BASH_COMMAND =~ .*autojump.* ]] && \ | |
[[ ! $BASH_COMMAND =~ ^ls.* ]] && \ | |
[[ ! $BASH_COMMAND =~ ^.?vim.* ]] && \ | |
[[ ! $BASH_COMMAND =~ ^cat.* ]] && \ | |
curl -H "Content-Type: application/json" -X POST \ | |
-d "{\"username\": \"chaignc\", \"content\": \"\`\`\`$BASH_COMMAND\`\`\`\"}" \ | |
$DISCORD_WEBHOOK_URL | |
} | |
# send bash typed command to discord in realtime | |
alias record2discord='trap _send2discord DEBUG' | |
# send last typed command to discord | |
function last2discord() { history -w /dev/stdout | sed 'x;$!d' | ( IFS= read -a BASH_COMMAND; _send2discord ) } | |
alias c=last2discord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment