dotfiles/fake_home/.sofi-preview.sh

66 lines
1.4 KiB
Bash
Raw Normal View History

2023-12-13 12:24:21 -05:00
#!/bin/bash
choice="$1"
query_string="$2"
arg="$(echo "$choice" | cut -c 5-)"
arg="${arg/#\~/$HOME}"
case $choice in
git*)
tree -L 1 $arg
exit 0
;;
win*)
echo $choice
exit 0
;;
app*)
echo $choice
exit 0
;;
emj*)
echo $choice
exit 0
;;
fil*)
echo $choice
exit 0
;;
mvr*)
groupId="$(echo "$arg" | sed 's/\(.*\):.*/\1/')"
artifactId="$(echo "$arg" | sed 's/.*:\(.*\) .*/\1/')"
latestVersion="$(echo "$arg" | sed 's/.* \(.*\)/\1/')"
echo "<dependency>"
echo " <groupId>$groupId</groupId>"
echo " <artifactId>$artifactId</artifactId>"
echo " <version>$latestVersion</version>"
echo "</dependency>"
exit 0
;;
inf*)
date
echo
free -h
echo
df -h | grep '/dev\|Filesystem'
;;
2023-12-13 12:24:21 -05:00
*)
qarg="$(echo "$query_string" | cut -c 5-)"
qarg="${qarg/#\~/$HOME}"
case $query_string in
mvn*)
curl -s "https://search.maven.org/solrsearch/select?q=$qarg&rows=5&wt=json" | jq '[.response.docs[] | { g, a, latestVersion, timestamp } ]' 2>/dev/null
;;
npm*)
NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
npm search $qarg | tail -n +2
;;
esac
;;
esac