-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslugme
More file actions
20 lines (14 loc) · 708 Bytes
/
slugme
File metadata and controls
20 lines (14 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# takes string with spaces, &s, uppercase and converts to slug--lowercase, replace spaces and slashes with dashes and ampersands with and
# then copies to OSX clipboard
# establish number of arguments; will check later that they were supplied
EXPECTED_ARGS=1
# check that argument was passed
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: $0 basename"
exit
fi
echo $1 | tr A-Z a-z | sed 's/&/-and-/g' | sed "s/['|!|?|!|\;|:|\(|\)]//g" | sed 's/ *- */-/g' | sed 's/\//-/g' | sed 's/"//g' | tr [:blank:] - | pbcopy
echo $1 | tr A-Z a-z | sed 's/&/-and-/g' | sed "s/['|!|?|!|\;|:|\(|\)]//g" | sed 's/ *- */-/g' | sed 's/\//-/g' | sed 's/"//g' | tr [:blank:] -
echo "copied to clipboard"