3 ms·
bash, AWK, sips. A couple of bash commands I use daily: cdf - change directory to the folder open in (Mac) Finder cdf () { currFolderPath=$( /usr/bin/os
by yesenadam 8y ago
bash, AWK, sips. A couple of bash commands I use daily:
cdf - change directory to the folder open in (Mac) Finder
cdf () {
currFolderPath=$( /usr/bin/osascript <<EOT
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT )
echo "cd to \"$currFolderPath\""
cd "$currFolderPath"
}
#dlm - "dlm filename" downloads filename.mp4 from URL in clipboard until its finished, resuming if interrupted
fname=$(pbpaste)
echo "Download $fname as $1.mp4 : "
until curl -C - -kLo $1.mp4 "$fname"
do
sleep 5
done
- cuchoi 8y agoWhere do you put this bash script?
- deleted 8y ago[deleted]
- JonathanMerklin 8y ago~/.bash_profile is the macOS equivalent of a .bashrc It's also possible that the author is source-ing it (spelled that way intentionally :\) ) from another file in their .bash_profile Note also that the author of the comment above was fast and loose with their description of dlm, and if you copypaste it as-written, it'll bomb. (Perhaps obvious, but you did ask where to put it!)
- yesenadam 8y agoAh thank u, yes, sorry. I have dlm saved as a shell script file. I didn't paste here the first-line bash shebang, which would have made that clearer. Maybe I use most: alias ..='cd ../' Then ".." moves up to the parent directory.
- theknarf 8y agoI don't use finder that much. My workflow usually involves finding stuff in the terminal and then using `open .` to open it in finder if needed. But that snipped was neet! So I'm adding it to my dotfiles.