dotfiles/dot_zsh_functions

127 lines
3.9 KiB
Plaintext
Raw Normal View History

2019-03-01 08:17:42 +00:00
function google() {
open -na "Google Chrome" --args "https://www.google.com/search?q=$*"
}
function stackoverflow() {
open -na "Google Chrome" --args "https://www.google.com/search?q=site:stackoverflow.com $*"
}
function github() {
open -na "Google Chrome" --args "https://github.com/search?q=$*"
}
function hacker() {
open -na "Google Chrome" --args "https://hn.algolia.com/?sort=byDate&query=$*"
}
function gmail() {
open -na "Google Chrome" --args "https://mail.google.com/mail/u/0"
}
function gmail2() {
open -na "Google Chrome" --args "https://mail.google.com/mail/u/1"
}
function tooling() {
open -na "Google Chrome" --args "https://issues.collibra.com/secure/RapidBoard.jspa?rapidView=449&projectKey=TOOL&view=planning.nodetail"
}
function issues() {
jira jql "status = Open AND text ~ \"$*\" ORDER BY Created DESC"
}
2019-03-01 08:28:18 +00:00
function calendar() {
open -na "Google Chrome" --args "https://calendar.google.com/calendar/r?tab=mc"
}
2019-03-01 08:51:19 +00:00
function asana() {
open -na "Google Chrome" --args "https://app.asana.com"
}
2019-07-18 10:03:52 +00:00
function bookmarks() {
open -na "Google Chrome" --args "https://github.com/MorganGeek/bookmarks/blob/master/README.md"
}
function spotify() {
open -na "Google Chrome" --args "https://open.spotify.com/search/results/$*"
}
function lob() {
open -na "Google Chrome" --args "https://lobste.rs"
}
2019-07-22 16:27:08 +00:00
function logtalk() {
path_swilgt=$(find /usr/local/Cellar/logtalk -name "*swilgt.sh" 2>/dev/null)
sh "$path_swilgt"
}
2019-07-23 12:29:00 +00:00
function archive() {
open -na "Google Chrome" --args "https://web.archive.org/web/*/$*"
}
2019-07-25 06:10:40 +00:00
function git_listobjectsbysize() {
tempFile=$(mktemp)
IFS=$'\n'
for commitSHA1 in $(git rev-list --all); do
git ls-tree -r --long "$commitSHA1" >>"$tempFile"
done
# sort files by SHA1, de-dupe list and finally re-sort by filesize
sort --key 3 "$tempFile" | \
uniq | \
sort --key 4 --numeric-sort --reverse
# remove temp file
rm -f "$tempFile"
}
function top_commands() {
2019-07-25 07:20:12 +00:00
history | cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n50
2019-07-25 06:10:40 +00:00
}
function top_commands_full() {
2019-07-25 07:20:12 +00:00
history | cat | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | sort -nr | nl | head -n50
2019-07-25 06:10:40 +00:00
}
2019-07-31 11:28:08 +00:00
function istherenewissues() {
LASTISSUE=$(newissues | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' | head -n1 | awk '{print $2}')
if [[ -f ".newjiraissue" ]]
then
previous_jira_issue=$(cat ".newjiraissue")
if [ "$LASTISSUE" != "$previous_jira_issue" ]; then
newissues
else
echo "no new issue"
fi
fi
echo "$LASTISSUE" > .newjiraissue
}
function greppagedate() {
2019-08-05 10:56:04 +00:00
year=$(echo "$*" | egrep -Eo '\b[[:digit:]]{4}\b')
if [ -z "$year" ]
then
year=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "date|datetime" -A 1 | \grep -Eo '\b[[:digit:]]{4}\b' | head -n1)
fi
yearint=$(($year + 0))
currentyear=$(echo `date +"%Y"`)
if [[ $yearint -ge 1970 && $yearint -le $currentyear ]]
then
echo "$yearint"
fi
}
# Extract a column from a tabular output
# via https://blog.developer.atlassian.com/ten-tips-for-wonderful-bash-productivity/
function col() {
awk -v col=$1 '{print $col}'
}
# Skip first x words in line
# via https://blog.developer.atlassian.com/ten-tips-for-wonderful-bash-productivity/
function skip {
n=$(($1 + 1))
cut -d' ' -f$n-
}
2019-08-08 12:35:18 +00:00
# Find files bigger than X size and sort them by size
function biggerthan() {
find . -size "+$*" -type f -print0 | xargs -0 ls -Ssh | sort -z
}
2019-08-08 18:11:20 +00:00
# To automatically ls when changing directory
function cd() {
builtin cd "$@" && ls -latr
}
2019-08-16 12:52:59 +00:00
function mouse() {
case "$(uname -s)" in
Darwin)
sh ~/.scripts/mouse_bluetooth.sh
;;
esac
}
function meteo() {
curl "fr.wttr.in/$*"
}
function how_in() {
where="$1"; shift
IFS=+ curl "https://cht.sh/$where/$*"
}