An attempt at python command line personal url shortening tool from multiple services concurrently at once via API with custom shorten back-half / alias provision.
-
- Install all the required packages :
pip install -r requirements.txt
-
make (optional)
- Using Makefile for installation :
You can edit the install destination path
(defaults to ~/.local/bin)
and filenameshrink
in Makefile
make install clean
- Manually : Run the following commands in terminal
cp shrink.py shrink
chmod +x shrink
cp shrink ~/.local/bin/
Note :
It is assumed that ~/.local/bin
is already added to $PATH. If not add it to PATH and update via .bashrc or .zshrc
WINDOWS :
-
Read this on how to : Add file / folder to PATH
-
Please add an alias
shrink
topython \path\to\folder\shrink.py
for console to use the tool.
-
Copy the
templates/api_keys_template
file to your desired folder and Read and Fill it with necessary details -
Rename the file after placing in your desired folder
mv templates/api_keys_template ~/.config/api_keys
- Source the file to your shell environment variables via .bashrc or .zshrc
echo "source ~/.config/api_keys" >> ~/.bashrc
- Test by opening new termial window or refreshing shell and do:
echo "$TINYURL_ROUTE"
- DO NOT add
api_keys
file to any git repo or online public backup
For Windows please refer to guides on environmental variables setup
NOTE :
Please add the variables for persistent setup and also check your IDE environment variables if you use an IDE to fork and develop further as this can pose some problems with environment variables
usage: shrink [-h] [-v] [-a ALIAS] [-q] URL
To shorten the given Long URL
positional arguments:
URL the long url to shorten
options:
-h, --help show this help message and exit
-v, --verbose add verbosity to output
-a ALIAS, --alias ALIAS
try for custom back-half e.g bit.ly/{ALIAS}
-q, --quick quickly get single link, useful to chain commands in Linux
ALTERNATIVELY, there is a choice to use the application standalone with any of the providers from the src/
folder
- Simple copy avaiable with middle-click mouse
shrink -q https://example.com | xclip -r
- Copy with Notification :
shrink -q https://example.com | xclip -r && notify-send "Short URL" "Ready to paste"
-
Pick and Paste : Like a Boss
With fzf :
shrink https://example.com/ -a test | fzf | xclip -r && notify-send "Short URL" "Ready to paste"
Or with dmenu :
shrink https://example.com/ -a test | dmenu | xclip -r && notify-send "Short URL" "Ready to paste"
Based on the free tier options with API provided for personal use from these URL shortening service providers. (as of 17-Aug-2022)
Thank You :