Skip to content

Commit

Permalink
feat: Add matterhorn scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Arturo Volpe <[email protected]>
  • Loading branch information
aVolpe committed Jan 10, 2024
1 parent c3bf59c commit 4d1b73d
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 9 deletions.
4 changes: 4 additions & 0 deletions global_gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
[url "[email protected]:"]
insteadOf = http://github.com/
insteadOf = https://github.com/

[diff "zip"]
textconv = unzip -c -a

3 changes: 2 additions & 1 deletion matterhorn_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ activityNotifyCommand = $HOME/.scripts/matterhorn_notification.sh

# The command to use to open URLs found in chat messages.
# OS X:
urlOpenCommand = open
urlOpenCommand = $HOME/.scripts/matterhorn_open.sh

# Linux:
# urlOpenCommand = xdg-open

Expand Down
66 changes: 66 additions & 0 deletions matterhorn_notification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

# Sample shell script for using notify-send with matterhorn This script
# works on Linux only. It depends on the 'notify-send' command.

# Positional parameters passed to this script by Matterhorn:
mentioned="${1?}"
sender="${2?}"
message="${3?}"

# Script options

# notify_URGENCIES
#
# The first word is the urgency for items where you are not mentioned.
# The second word is the urgency for items where you are mentioned.
# Use "none" to not be notified; otherwise use "low", "normal", or
# "critical".
notify_URGENCIES="normal normal"

# The desktop notification category
notify_CATEGORY="im.received"

# Notification header
notify_HEAD="$sender"

# Notification body
notify_BODY="$message"

getUrgencyHelper() {
if [ "$mentioned" == "1" ]
then
echo "$1"
else
if [ "$mentioned" == "2" ]
then
echo "$2"
else
echo "Error: mentioned value '$mentioned' unexpected" > /dev/stderr
exit 1
fi
fi
}

getUrgency() {
# We are using arguments as a poor man's bash array for portability
# shellcheck disable=SC2086
getUrgencyHelper $notify_URGENCIES
}

urgency=$(getUrgency)

printf -v NOW '%(%Y-%m-%d %H:%M:%S)T' -1

echo "$NOW: $@" >> ~/.matterhon_notifications

if [[ "$message" == *":clockify:"* ]]; then
echo "$NOW: $@" >> ~/.matterhon_clockify
exit
fi

if [ ! -z "$urgency" ]
then
test "$urgency" = "none" ||
terminal-notifier -subtitle "$notify_HEAD:" -title "Matterhorn" -message "$notify_BODY"
fi
38 changes: 38 additions & 0 deletions matterhorn_open.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
echo "Command and arguments: $0 $@" >> ~/debug.log

# Check if there is exactly one argument
if [ $# -ne 1 ]; then
echo "Usage: $0 <URL>"
exit 1
fi

url="$1"

# Define domains to be ignored
ignore_domains=("tel.meet" "another.domain")

# Define domains to be opened with Google Chrome
chrome_domains=("google" "figma")

# Extract the domain from the URL
domain=$(echo $url | awk -F/ '{print $3}')

# Check if the domain is in the ignore list
for ignore_domain in "${ignore_domains[@]}"; do
if [[ "$domain" == *"$ignore_domain"* ]]; then
exit
fi
done

# Check if the domain is in the Chrome list
for chrome_domain in "${chrome_domains[@]}"; do
if [[ "$domain" == *"$chrome_domain"* ]]; then
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --profile-directory="Profile 1" "$url"
exit
fi
done

# If it's not in either list, execute the 'open' command
open "$url"
26 changes: 18 additions & 8 deletions vim/.nvimrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
language en_US

if !exists("g:gui_vimr")
language en_US
endif

let g:python2_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
Expand Down Expand Up @@ -42,9 +45,9 @@ Plug 'junegunn/vim-easy-align'

Plug 'airblade/vim-gitgutter'
Plug 'onsails/Lspkind-nvim'
Plug 'glepnir/galaxyline.nvim', has('gui_vimr') ? { 'on': []} : {'branch': 'main'}
Plug 'kyazdani42/nvim-web-devicons', has('gui_vimr') ? { 'on': []} : {'branch': 'master'} " lua
Plug 'ryanoasis/vim-devicons', has('gui_vimr') ? { 'on': []} : {'branch': 'master'} " vimscript
Plug 'glepnir/galaxyline.nvim', {'branch': 'main'}
Plug 'kyazdani42/nvim-web-devicons', {'branch': 'master'} " lua
Plug 'ryanoasis/vim-devicons', {'branch': 'master'} " vimscript

call plug#end()
" }
Expand Down Expand Up @@ -305,10 +308,9 @@ nmap ga <Plug>(EasyAlign)
"
"
" Load lua config
"lua require('lspkind')
"if !has("gui_vimr")
"lua require('statusline')
"endif
lua require('lspkind')

lua require('statusline')

set ic " allows search to be case insensitive until a upper case appear
set smartcase " allows search to be case insensitive until a upper case appear
Expand Down Expand Up @@ -432,3 +434,11 @@ augroup git_commit_config
au FileType gitcommit let g:editorconfig = v:false
augroup END
" }
"
" Configure markdown {
augroup markdown_config
au!
" The important one is guifg
au FileType markdown hi SpellBad cterm=underline gui=underline guisp=#fb5e2a guifg=#E12222
augroup END
" }

0 comments on commit 4d1b73d

Please sign in to comment.