Useful scripts for Linux users
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
LICENSE.txt
README.md
aliases.bash
backup_protectedtext.py
batch-rename.py
battery
bookmarks
doom
duplicati-ping.py
generate-readme.fish
git-sync
headlines.sh
itunec
knok
layoutset
memory-available.sh
notify-append
poweroff
reboot
skypenotify
snippy.sh
sssh
timer
todo
tomatych.py
translate-selection.sh
translate-yandex.sh
translation-insert.sh
volume

README.md

Useful scripts for Linux users

aliases.bash

Decription

Some handy bash aliases

Requirements

sudo apt-get install twistd pm-utils

Usage

  1. wget https://raw.githubusercontent.com/dmi3/bin/aliases.bash --no-check-certificate -O ~/bin/aliases.bash
  2. echo "source ~/bin/aliases.bash" >> ~/.bashrc
  3. To make bash more usable you probably want to install https://github.com/mrzool/bash-sensible
  4. To make this work across remote machines, you also may want to install https://github.com/Russell91/sshrc

backup_protectedtext.py

Decription

  • 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

Usage

Run from commandline or add to cron


batch-rename.py

Decription

Renames files given in arguments. Interactively prompts for file name. If no otherwise specified - uses first file name + number.

Usage

rename.py file1 file2 file3 ...


battery

Description

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

Usage

$ battery # multiple batteries are installed
🔌 ▄▇
$ battery # single battery is installed
🔌 ▇
$ battery # no battery is installed
🔌

bookmarks

Decription

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 ClipIt actions.

Requirements

  1. sudo apt-get install fzf

Usage

  • bookmarks -a http://github.com useful site
  • bookmarks
  • Bookmark currently copied link using ClipIt actions: bookmarks -a %s $(zenity --entry)

config/clipit/clipitrc


config/fish/config.fish

Fish config with awesome flexible prompt, unicode symbols, better fzf integration and tons of handy functions.


duplicati-ping.py

Decription

Ping https://healthchecks.io/ on successful Duplicati backup

Usage

Add path to this script to run-script-after in job ConfigurationOptionsAdvanched 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


generate-readme.fish

Decription

Generates this readme

Usage

 echo -e "#!/bin/sh\necho \# Useful scripts for Linux users > README.md\ngenerate-readme.fish >> README.md" > .git/hooks/pre-commit
 chmod +x .git/hooks/pre-commit    

git-sync

Decription

Script to simply sync all changes into git repository with one command. For example publish local changes to Github.

Requirements

  1. sudo apt-get install git
  2. Setup mergetool

Usage

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`

headlines.sh

Description

  • 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
  • Additionally prints latest @sadserver tweet for cynical comment
  • If you prefer simpler version without additional functionality refer to initial version
  • See http://developer.run/27 for description and more ideas

Requirements

sudo apt-get install jq

Usage

  • headlines.sh will print latest headlines
  • headlines.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 synced between computers
  • Add to shell greeting see screenshot

itunec

Decription

Mounts USB device, syncs new podcast in gpodder then umounts device

Requirements

  1. sudo apt-get install python3 id3v2
  2. wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append

Usage

  1. set LABEL to label of your player filesystem (for example SANSA CLIP to find label type ls -l /dev/disk/by-label/)
  2. set GPODDER_DIR to directory where gpodder download podcasts
  3. run itunec when you want to sync or
  4. gpodder -> Podcasts -> Prefences -> Devices; set Device type to Filesystem-based and Mountpoint path where device is mounted by default
  5. gpodder -> Podcasts -> Prefences -> Edit config -> cmd_all_download_complete -> itunec

knok

Decription

Knocks to given ports with 0.5 second delay. Useful when default knockd delay is to short for server to react. Additionally displays Gun's N' Roses lyrics :)

Requirements

  1. sudo apt-get install knockd python3 python3-setuptools
  2. sudo easy_install3 sh

Usage

knock ip [port,port...]


memory-available.sh

Decription

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

Requirements

  1. sudo apt-get install notify-send

poweroff

Decription

Gracefully closes all running X applications, then powers off the computer. 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

Requirements

  1. sudo apt-get install wmctrl

skypenotify

Decription

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

Requirements

wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append

Usage

skypenotify "%sname" "%smessage"


snippy.sh

Decription

System wide text snippet expander. Simulates cut→replace→paste so works in almost any application. Examples:

  • Type ->, press hotkey, get .
  • Type thx, press hotkey, get Thank 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
  • Expands snippets without preceding space i.e. 30eur to 30€
    • If snippet needs preceding space or start of line - use regexp \b i.e. s/\bv$/✔/g; converts v to only if its separate symbol
  • Expands snippets with symbols i.e. -> to
  • Stores all snippets in one file
  • Works with Ubuntu 16.04

Requirements

sudo apt-get install xdotool xclip xsel

Usage

  • Bind script to hotkey in your DE, for example Shift+Tab.
  • Add new snippets after line 30, in format s/SHORCUT$/REPLACEMENT/g;
  • If you use this for emoji, it will work but make me sad.

sssh

Decription

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

Requirements

sudo apt-get install xdotool

Usage

sssh user@hostname


tomatych.py

  * 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](https://github.com/dmi3/tomatych)

translate-selection.sh

Decription

Show popup with translation of selected text. Works in any application.

Requirements

  1. Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
  2. sudo apt-get install zenity xsel

Usage

  • Bind script to hotkey in your DE.
  • Select any text. Press hotkey.

translate-yandex.sh

Decription

CLI Yandex Translate API ru↔en. Automatically detects language. Translates any language to Russian, and Russian to English.

Usage

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

translation-insert.sh

Decription

Prompts for text. Then inputs translation. Works in any application.

Requirements

  1. Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
  2. sudo apt-get install zenity xsel

Usage

  • Bind script to hotkey in your DE. After input wait couple of seconds for translation to appear.