See my Fish config for more CLI awesomness
Using Wolfram Alpha in command line. See blog post for description and more ideas.
- Make sure to configure variables in script
- Put api key in
APPID
- For
VIEWER
, you can use text only api and optionaly use terminal that supports images orsudo apt-get install imagemagick
to view images. - Configure
BG
andFG
variables depending on color scheme
➤ wa helsinki to dublin plane
2 hours 20 minutes
➤ wa time in dublin
5:37:57 pm GMT; Friday, January 27, 2017
➤ wa 15.36 english money to eur
14.35 euros
➤ wa days till nov 16
293 days
➤ wa 154Mbit/s to MB/s
19.2 megabytes per second
➤ wa brick red hex
#AB0303
➤ wa weather in moscow
9 degrees Celsius and cloudy, with light winds✖
➤ wa plot x=y^2
[...draws plot if supported]
➤ # many many more usages... https://www.wolframalpha.com/examples/
Script to control audio volume from console, hotkeys, e.t.c. Also shows nice Notify OSD buble with current volume value
sudo apt-get install pulseaudio notify-osd
volume (up|down|mute)
Show file or stream currently playing in VLC. Works well with (with xfce4-genmon-plugin). See playerctl -h
for another players.
sudo apt-get install vlc playerctl
vlc-now
Includes useful functions- `cutExt() {
- `wrapInBrackets() {
- `basename() {
- `urlDecode() {
Wrapper around webpreview. Takes url, downloads a preview image (or image iself, if url points to image) and returns formatted markdown with page title and description. Useful with clipboard manager. Read more
pip install webpreview
$ url-preview-md.py img_directory url
$ url-preview-md.py ~/img http://developer.run/70
[Markdown Url Preview](http://developer.run/70) Markdown Url Preview in text editor.
![](/home/dmi3/img/2023_09_01_developer.run_url-preview-md.png)
If you have OpenGraph.io api key, add it as last argument to try it if webpreview finds nothing useful
$ url-preview-md.py ~/img http://developer.run/70 e2b0e47c-8a03-11ef-b1b2-13950b80fc62
Update tray icon depending on script result. Current example shows unread mail count for Evolution mail (for those poor souls who need exchange but don't have web client), but actually it can check and notify about literally anything! Another example shows Git repository status.
On click simulates some keypresses to mark all mail as read.
Read more:
- https://sourceforge.net/p/yad-dialog/wiki/NotificationIcon/
- https://dset0x.github.io/mail-counting.html
sudo apt-get install yad
- For Evolution
sudo apt-get install sqlite3 wmctrl xdotool
tray-unread.sh
Update tray icon depending if there are changes in Git repository. ⚠ Note that it does not show any icon if repository is in sync Check for new changes every 10 minutes. See also git-sync
See https://stackoverflow.com/a/3278427/18078777
sudo apt-get install yad git
tray-git.sh
Prompts for text. Then inputs translation. Works in any application.
- Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
sudo apt-get install zenity xsel
- Bind script to hotkey in your DE. After input wait couple of seconds for translation to appear.
CLI Yandex Translate API ru↔en. Automatically detects language. Translates any language to Russian, and Russian to English.
yandex-translate.sh cat is a small, typically furry, carnivorous mammal # en → ru
yandex-translate.sh die Hauskatze ist eine Unterart der Wildkatze # de → ru
yandex-translate.sh кот это маленькое, пушистое и очень хитрое млекопитающее # ru → en
Show popup with translation of selected text. Works in any application.
- Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
sudo apt-get install zenity xsel
- Bind script to hotkey in your DE.
- Select any text. Press hotkey.
- Simple Hackable Pomodoro Timer with optional Slack and Habitica integrations.
- Intended to be hacked and modified to fit your specific vision of how Pomodoro timers should work.
- Moved to separate repo
Wrapper for wl for adding todos with more convenient syntax Read More
- ⚠ Make sure Fish shell > 2.3.0
curl https://raw.githubusercontent.com/dmi3/bin/master/todo --create-dirs -o ~/bin/todo
curl https://raw.githubusercontent.com/dmi3/bin/master/config/fish/completions/todo.fish --create-dirs -o ~/.config/fish/completions/todo.fish
- https://developer.wunderlist.com/apps
[CREATE APP]
(Put https://wunderlist.com to bothAPP URL
andAUTH CALLBACK URL
)- Set enviroment variables in this script ↓ (line 31)
- Add more list shortcuts ↓ (line 39)
todo buy stuff --life --on next monday
todo resolve issue --work --star
todo --work meet customer --on jan 7
Simple timer with sound and dialog window notification. To remind you to turn stove off :). Replace pc_up.wav to any available audiofile.
sudo apt-get install dunst aplay
timer 6 # i.e. notify after 6 minutes
Shows CPU, System and GPU temperature
sudo apt-get install jq lm-sensors nvidia-smi
temp
CLI web stats dashboard. Visualizes GitHub followers, top GitHub repos and last 500 blog hits
with top pages and refferers. Works well in addition to headlines.sh and newsbeuter -x reload -x print-unread 2> /dev/null
Read more
- spark (the other spark, not the behemoth one)
sudo apt-get install jq
- Set
URL
,GITHUB_ID,
PARSE_APP_IDand
PARSE_MASTER_KEY` variables status.sh
Like sssh, in addition:
hostname
parameter of ssh command will appear in title.- Useful when calling by nickname from local
~/.ssh/config
i.e.ssh server_nickname
, and change of server hostname is not an option.
- Useful when calling by nickname from local
- If command supports tunneling, display it in title
- I.e.
ssh -L 80:localhost:80 server_nickname
will set titleuser@[80]server_nickname
- Avoid accidental closing of such tabs
- I.e.
- Appends some useful aliases to existing
~/.bashrc
- Preserves command history on multiple sessions
See sssh
Script to change your terminal title to user@host when connecting to ssh and changing
it back after exiting. Additionally sets green prompt on remote host.
Useful for Keepassx and visual distinction to avoid notorious "wrong window" problem.
Also works when connecting Fish → Bash
If you want hostname from local ~/.ssh/config
file to appear in title use sssh2.
sudo apt-get install xdotool
sssh user@hostname
alias ssh=sssh
System wide text snippet expander. Simulates cut→replace→paste so works in almost any application. Examples:
- Type
->
, press hotkey, get→
. - Type
thx
, press hotkey, getThank you
. Original idea by sessy and Linux Magazine with following improvements: - Works as keybinding in Compiz/Unity/Openbox
- Does not go crazy if keybinding includes Ctrl, Alt, Shift...
- Works in Sublime Text/IntelliJ Idea/Chrome/Slack
- Expands snippets without preceding space i.e.
30eur
to30€
- If snippet needs preceding space or start of line - use regexp
\b
i.e.s/\bv$/✔/g;
convertsv
to✔
only if its separate symbol
- If snippet needs preceding space or start of line - use regexp
- Expands snippets with symbols i.e.
->
to→
- Expands commands i.e.
now
to formatted todays date,mon
to to formatted next mondays date - Stores all snippets in one file
- Works with Ubuntu 16.04
sudo apt-get install xdotool xclip xsel
- Bind script to hotkey in your DE, for example Shift+Tab.
- Add new snippets after line 30, in format
s/SHORCUT$/REPLACEMENT/g;
Script to run append Skype messages in Notify OSD as shown on http://thexnews.com/uploads/notify.gif
Since x-canonical-append
is broken in notify-send for example in Skype you will wait forever untill all messages are shown
This script makes new messages readable in same notification window
Readme in russian
wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append
skypenotify "%sname" "%smessage"
Execute .desktop
file from terminal
rundesktop /usr/share/applications/firefox.desktop
See https://github.com/dmi3/bin/blob/master/poweroff
Font especially designed to fit 6 digits to 20x8 screens For some reason miniwi.flf figlet font is not working in tty Useful for Raspberry Pi 2fa
▐ ██ ██ ▌▐ ██ ██
▐ ▐ ▐ ▌▐ ▌ ▌
▐ ██ ██ ██ ██ ██
▐ ▌ ▐ ▐ ▐ ▌▐
▐ ██ ██ ▐ ██ ██
python3 numbers.py 123456
Gracefully closes all running X applications, then powers off the computer.
Make sure to avoid conflicts with system poweroff
is such exists.
Useful to avoid issues when calling poweroff
from console:
- "The database you are trying to open is locked by another instance of KeePassXC.",
- "Well, this is embarrassing. Firefox is having trouble recovering your windows and tabs."
- Spotify forgetting current playlist
- etc
sudo apt-get install wmctrl
Interactive (un)mount of hotplug devices (USB drives) from console using FZF!
Outputs path to mounted device so could be used in alias to actomatically
cd
to mounted directory.
sudo apt-get install jq fzf udisks2
alias unplug='plug -u'
cd
to mounted directory:
- Fish shell:
alias plug='cd (command plug)'
- Bash shell:
alias plug='cd $(command plug)'
$ plug
> ACRONIS_MED DataTraveler_2.0 sdb1
DATA DataTraveler_3.0 sdc1
Mounted /dev/sdb1 at /media/dmi3/ACRONIS_MED.
$ plug -u
> /media/dmi3/ACRONIS_MED ACRONIS_MED DataTraveler_2.0 sdb1
/ workbuntu2020 Samsung_SSD_860_EVO_M.2_500GB sda2
/media/dmi3/ElTorito ElTorito Samsung_SSD_860_EVO_M.2_500GB sda1
Unmounted /dev/sdb1
Script to run append Notify OSD messages as shown on http://thexnews.com/uploads/notify.gif Since x-canonical-append is broken in notify-send for example in Skype you will wait forever untill all messages are shown This script makes new messages shown in same notification window bellow the already shown Created as addition to notify-send. Use notify-send when you want to send notification and notify-append when you want append or replace it. Readme in russian
Setups MUS (Minimal Usable System). Targets very slow machines with very broken disks and very bad internet, so checks everything.
/usr/bin/GET https://raw.githubusercontent.com/dmi3/bin/master/mus.sh > ~/mus.sh && chmod +x ~/mus.sh && ~/mus.sh
Prints free memory in gigabytes. Sends urgent notification if usage is less than defined value. Cached memory is considered free. Works best with indicator-sysmonitor and dunst
sudo apt-get install notify-send
Script to set keyboard layout depending if its Apple or regular keyboard + some settings
layoutset
Knocks to given ports with 0.5 second delay. Useful when default knockd delay is to short for server to react. Additionally displays Bob Dylan's lyrics :)
sudo apt-get install knockd python3 python3-setuptools
sudo easy_install3 sh
knock ip [port,port...]
Mounts USB device, syncs new podcast in gpodder then umounts device
sudo apt-get install python3 id3v2
wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append
- set LABEL to label of your player filesystem (for example
SANSA CLIP
to find label typels -l /dev/disk/by-label/
) - set GPODDER_DIR to directory where gpodder download podcasts
- run
itunec
when you want to sync or - gpodder -> Podcasts -> Prefences -> Devices; set Device type to
Filesystem-based
andMountpoint
path where device is mounted by default - gpodder -> Podcasts -> Prefences -> Edit config -> cmd_all_download_complete -> itunec
- Prints ground shaking headlines from Hacker News in shell greeting
- Don't miss next Meltdown, be notified right away!
- Doesn't distract you if nothing important happened
- Allows open all news in browser and mark it as read
- If you prefer simpler version without additional functionality refer to initial version
- See http://developer.run/27 for description and more ideas
sudo apt-get install jq
headlines.sh
will print latest headlinesheadlines.sh read
will open all news in browser and mark it as read (hide)~/.readnews
stores titles and urls of read news~/.readnews
might be useful if you want to find article later~/.readnews
might be synced between computers
headlines.sh clear
will mark all news as read (hide)- Add to shell greeting see screenshot
- https://ownyourbits.com/2017/04/05/customize-your-motd-login-message-in-debian-and-ubuntu/
- OR
chmod 777 /var/run/motd.dynamic
on boot andheadlines.sh > /var/run/motd.dynamic
- OR
chmod 777 /var/run/motd.dynamic
on boot and put0 */2 * * * /path/to/headlines.sh > /var/run/motd.dynamic
tocrontab -e
- To read and update greeting use
headlines.sh read > /var/run/motd.dynamic && clear
Script to simply sync all changes into git repository with one command. For example publish local changes to Github.
sudo apt-get install git
- Setup mergetool
git-sync /path/to/repo
git-sync # current dir
git-sync # if you want sync all files
git-sync -u # if you want only sync files explicitly added via `git add filename`
Generates this readme
echo -e "#!/bin/sh\necho \# Useful scripts for Linux users > README.md\necho \"See my [Fish config](https://github.com/dmi3/fish) for more CLI awesomness\" >> README.md\ngenerate-readme.fish --reverse >> README.md\nshasum -a 256 * | grep -v 'SHASUMS\|config' > SHASUMS" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
Saves full screen screenshot with current window name and date to predefined folder and plays sound if successful.
sudo apt-get install scrot xdotool
- Bind a hotkey to
game-screenshot.sh /path/to/folder
Export playlists from Spotify without giving credentials to shady sites (to avoid your Spotify credentials be stolen and resold to someone in different timezone)
Converts Spotify playlist from "Song Links" list:
https://open.spotify.com/track/6autdCG3xl7gzoiDCEB2HN
https://open.spotify.com/track/4q6RvRkXquQ965hubV58lb
https://open.spotify.com/track/01pzLOA8rQLfoodUCLc2wj
To "Track - Artist" list:
Nerevar Rising - Jeremy Soule
Arcanum - NewEnglandStringQuartet
Wilderness - Matt Uelmen
sudo apt-get install jq
- Open Spotify app
- Open playlist or "Songs" view
- Select all tracks
Ctrl+A
- Copy track urls
Ctrl+C
- Paste into file and save
cat /path/to/file | ex-spotify-playlist.sh
- Writes all running AWS EC2 instances with defined name to SSH config file
- So you write
ssh instance_name
instead ofssh -i ~/.ssh/gate.pem ec2-user@ec2-12-345-67-89.us-east-1.compute.amazonaws.com
- Autocompletion!
- Command history is clean and reusable for
ssh
andscp
- Instance IP change on reboot is not problem anymore
- Works well with sssh2.
- Setup aws-cli
- (Optional) Install latest Openssh in 16.04
- Change credentials in
TEMPLATE
↓
- If you have Openssh > 7.3:
ec2ssh.sh | tee ~/.ssh/aws_config
- Add Include aws_config to
~/.ssh/config
- Else (will overwrite file)
- ec2ssh.sh | tee ~/.ssh/config
Ping https://healthchecks.io/ on successful Duplicati backup
Add path to this script to run-script-after
in job Configuration
→ Options
→ Advanched Options
On Windows you will need to create .bat
file containing path to this script, and add path to .bat
file to run-script-after
Script to run gzdoom with various configurations/wads. Selectable via dmenu
- Get latest Gzdoom
- `sudo apt-get install gzdoom dmenu python3 python3-setuptools
sudo easy_install3 sh
doom
GUI LXQT Settings menu
fzf
control-panel
Config for LXTerminal with copy/paste on Ctrl+C/V and nicer color theme
Config for Kitty with custom hotkeys, nicer color scheme and some useful tweaks Refer to original documentation for more options
Fish config with awesome flexible prompt, unicode symbols, better fzf integration and tons of handy functions.
Config for ClipIt with sane defaults and hotheys
Moves mouse in the center of active window.
sudo apt-get install xdotool python3-sh gir1.2-wnck-3.0
center-mouse-active-window.py
Script for quickly adding and accessing bookmarks. Browser independent. When you want to store bookmarks in plain format, use CLI, but don't want use bm or Buku Useful when set by hotkeys or clipboard manager actions.
sudo apt-get install fzf
bookmarks -a http://github.com useful site
bookmarks -a %s $(zenity --entry)
Interactivebookmarks
- Bookmark currently copied link using ClipIt actions:
bookmarks -a %s $(zenity --entry)
One more script to show battery status as bar(s). Difference from other solutions:
- Simplicity, duh
- Acknowledges the fact that there were sometimes more than one battery in laptop
- Will display capacity for all batteries
- Also the fact that there were sometimes no battery at all!
- No error in this case
- Old batteries usually max at ≈99, so it has same symbol as 100
- Can work with indicator-sysmonitor
- Spark could be used here, but this solution is even simpler
$ battery # multiple batteries are installed
🔌 ▄▇
$ battery # single battery is installed
🔌 ▇
$ battery # no battery is installed
🔌
Renames files given in arguments. Interactively prompts for file name. If no otherwise specified - uses first file name + number.
rename.py file1 file2 file3 ...
- Backup secrets from www.protectedtext.com to local storage
- If file is changed, keep previous version with date postfix
- Only backups once per day
- Can be decrypted using
base64 -d BACKUP_FILE | openssl aes-256-cbc -d -k PASSWORD
- More info http://developer.run/13
Run from commandline or add to cron
Some handy bash aliases and settings. ⚠ You may find more useful commands in Fish shell aliases (which is easily portable to Bash)
wget https://raw.githubusercontent.com/dmi3/bin/aliases.bash --no-check-certificate -O ~/bin/aliases.bash
echo "source ~/bin/aliases.bash" >> ~/.bashrc
- To make bash more usable you probably want to install https://github.com/mrzool/bash-sensible
- To make this work across remote machines, you also may want to install https://github.com/Russell91/sshrc