#+TITLE: DONE A Quick Command-Line URL Shortener That Actually Saves Time ⚡ :blog_sl:bash:tips: CLOSED: [2025-06-07 Sat 16:42] :PROPERTIES: :CREATED: [2025-06-07 Sat 16:42] :ID: shorturl-tip :END: :LOGBOOK: - State "DONE" from [2025-06-07 Sat 16:42] :END: We've all been there: you need to share a long URL and spend precious minutes hunting through various URL shortening websites 😤. After doing this dance one too many times, I decided to create a simple bash function that puts URL shortening right at my fingertips. * The Solution 🛠️ Here's the bash function that has quietly revolutionized my workflow: #+begin_src bash function shorturl() { if [ -z "$1" ]; then printf "Usage: shorturl \n" return 1 fi printf "Shortening url '$1'\n" curl -s "https://is.gd/create.php?format=simple&url=$1" \ | tee >(pbcopy) } #+end_src The function is elegantly simple: it validates input, shows you which URL is being shortened, calls the is.gd API, and automatically copies the result to your clipboard (on macOS): the =tee >(pbcopy)= command displays the shortened URL in your terminal while simultaneously doing the clipboard copy. * Setup 🔧 Add the above to your =.alias= file in your home directory, then ensure your =.bashrc= includes: #+begin_src bash test -e ~/.alias && . ~/.alias #+end_src This keeps your custom functions organized while making them available in every shell session. * Why This Matters 💡 It's not just about time saved—it's about removing friction from your workflow. Instead of opening a browser, navigating to a service, pasting, copying, and switching back, you simply type =shorturl = and the shortened version is instantly ready to paste. This tiny function represents a broader principle: *automate the small, repetitive tasks that interrupt your flow*. These micro-inefficiencies break your concentration and add up over time. * Using Linux? Replace =pbcopy= with =xclip -selection clipboard=. * The Philosophy of Small Tools This embodies the Unix philosophy of small, focused tools that do one thing well. Sometimes the most impactful improvements to your workflow are the smallest ones. Next time you find yourself doing the same digital task repeatedly, ask: "Could I automate this with a simple function?" You might be