-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-challenge.fish
More file actions
31 lines (27 loc) · 997 Bytes
/
start-challenge.fish
File metadata and controls
31 lines (27 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function start-challenge --argument-name directory --description "Create a new directory with a notes.md containing the contents of the clipboard"
if test -z "$directory"
echo "Usage: $argv[0] directory" >&2
return 1
end
mkdir -p $directory
begin;
echo "# " (string replace --all '/' ' - ' $directory)
echo
pbpaste | string replace --all --regex '^' '> '
echo
end | tee $directory/notes.md >/dev/null
set -l name (string replace --all --regex '\s' '?' (basename "$directory"))
set -l archives (find $HOME/Downloads/ -iname "*$name*")
if count "$archives" >/dev/null
for archive in $archives
set -l reply (read -P "Found $archive, unpack? [Y/n] ")
if ! string match -i -q "n*" $reply
7z x -o$directory $archive
end
end
end
subl $directory/notes.md
if command which guake >/dev/null
guake --new-tab=$PWD/$directory
end
end