Skip to content

Commit

Permalink
tolaria => [functions.bash][share.spell]
Browse files Browse the repository at this point in the history
  • Loading branch information
mendess committed Sep 23, 2024
1 parent 1346b98 commit e5eec98
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- [print](./spells/print.spell)
- [projects](./spells/projects.spell) - Open dmenu, show me my projects, open a terminal in the selected one
- [refresh_firefox](./spells/refresh_firefox.spell) - Refreshes firefox
- [share](./spells/share.spell)
- [ssh-menu](./spells/ssh-menu.spell) - A menu to quickly open ssh connections
- [syncspellbook](./spells/syncspellbook.spell) - Tries to synchronise with changes to the remote repository. Also runs [learnSpells](./learnSpells.sh) and [castRunes](./castRunes.sh)
- [termFromHere](./spells/termFromHere.spell) - Opens a terminal in the same `cwd` as the focused `X` program.
Expand Down
35 changes: 0 additions & 35 deletions runes/bash/functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -104,41 +104,6 @@ print("".join((map(lambda x: x.upper() if choice([True, False]) else x.lower(),
' "$@"
}

share() { (
set -e
HOST=argentum
while [[ "$#" -gt 0 ]]; do
case "$1" in
-u | --unlisted)
unlisted=1
;;
*)
if [[ "$FILE" ]]; then
filename="$1"
else
FILE="$1"
fi
;;
esac
shift
done
[ "$filename" ] || filename="$(basename "$FILE")"
if [ -d "$FILE" ]; then
zip -r "/tmp/$filename.zip" "$FILE"
FILE="/tmp/$filename.zip"
filename="$filename.zip"
fi
[[ "$unlisted" ]] && filename="unlisted/$filename"
spark rsync av "$FILE" "$HOST:core/mirari/mirrodin/share/$filename"
url="https://mendess.xyz/api/v1/file/$filename"
if command -v termux-clipboard-set &>/dev/null; then
echo -n "$url" | termux-clipboard-set
elif [[ "$DISPLAY" ]]; then
echo -n "$url" | xclip -sel clip
fi
echo "$url"
); }

gcl() {
if [[ "$(whoami)" = pmendes ]]; then
mk_repo_dir() {
Expand Down
34 changes: 34 additions & 0 deletions spells/share.spell
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e
HOST=argentum
while [[ "$#" -gt 0 ]]; do
case "$1" in
-u | --unlisted)
unlisted=1
;;
*)
if [[ "$FILE" ]]; then
filename="$1"
else
FILE="$1"
fi
;;
esac
shift
done
[ "$filename" ] || filename="$(basename "$FILE")"
if [ -d "$FILE" ]; then
zip -r "/tmp/$filename.zip" "$FILE"
FILE="/tmp/$filename.zip"
filename="$filename.zip"
fi
[[ "$unlisted" ]] && filename="unlisted/$filename"
spark rsync av "$FILE" "$HOST:core/mirari/mirrodin/share/$filename"
url="https://mendess.xyz/api/v1/file/$filename"
if command -v termux-clipboard-set &>/dev/null; then
echo -n "$url" | termux-clipboard-set
elif [[ "$DISPLAY" ]]; then
echo -n "$url" | xclip -sel clip
fi
echo "$url"

0 comments on commit e5eec98

Please sign in to comment.