├── 4fetch ├── LICENSE ├── README.md ├── adbf ├── add-art ├── add-current-art ├── anichk ├── anime ├── aniplay ├── anistrm ├── aniup ├── aquote ├── autozb ├── bat-notify-daemon ├── bw-pw ├── c-abcdef ├── c-bars ├── c-batman ├── c-blocks ├── c-blocks2 ├── c-cirno ├── c-determination ├── c-digdug ├── c-dna ├── c-double ├── c-faces ├── c-hash ├── c-hashbang ├── c-hypnotoad ├── c-invaders ├── c-lines ├── c-pacman ├── c-poke ├── c-rupees ├── c-scheme ├── c-skulls ├── c-skulls2 ├── c-slendy ├── c-spooky ├── c-streaks ├── c-table ├── c-tanks ├── c-tv ├── c-tvs ├── c-wheel ├── ccast ├── crop-gif ├── debloat-fossil-sport ├── dmenu_counter ├── extsub ├── fetch ├── fzmp ├── get-battery-status ├── get-truncated-window-title ├── gitlab-api ├── gitlab-artifacts ├── gitlab-install ├── gitlab-job-action ├── gitlab-job-id ├── gitlab-job-interactive ├── gitlab-job-monitor ├── global-entry-interviews ├── gspick ├── hack ├── haxxor ├── i3-focus-last ├── i3-for-window ├── imgt ├── ix ├── let-ssh ├── letsencrypt ├── lightsOn ├── mkgif ├── mobile-install ├── mpc-art ├── mpc-notify ├── mpc-notify-daemon ├── mpdswap ├── multitest ├── pipes ├── ptpb ├── pullc ├── pushc ├── random-ix-io ├── relink-dots ├── reload-chrome-theme ├── reload-desktop ├── resize-video ├── runall ├── scget ├── screencast ├── sctag ├── spin ├── sshh ├── tek ├── tester ├── todo ├── todo-head ├── ucsd-course-snipe ├── urldecode ├── urlencode ├── use-xresources ├── vidhalve ├── waaai ├── wchat ├── woodo ├── wzk ├── xfr └── xpipes /4fetch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Scrapes images from a 4chan thread. 3 | # 4 | # Author: metakirby5 5 | 6 | wget -nd -nc -q --show-progress -e robots=off \ 7 | -rHD i.4cdn.org -A '*.*' -R '*s.*,*.tmp' "$@" 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scripts 2 | ======= 3 | 4 | A collection of scripts I have found or written. 5 | -------------------------------------------------------------------------------- /adbf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Do an adb operation with a file, pull it, and remove it. 3 | # 4 | # Dependencies: adb 5 | # Author: metakirby5 6 | 7 | checkdep() { 8 | type "$1" &>/dev/null || echo " $1" 9 | } 10 | 11 | missing="$(checkdep adb)" 12 | if [ "$missing" ]; then 13 | echo "The following dependencies are missing:$missing" 14 | exit 1 15 | fi 16 | 17 | usage() { 18 | echo "Usage: $(basename "$0") [filename] [commands...]" 19 | exit 1 20 | } 21 | 22 | [ "$#" -lt 2 ] && usage 23 | 24 | filename="/sdcard/$1" 25 | shift 26 | 27 | finish() { 28 | sleep 0.5 29 | adb pull "$filename" 30 | adb shell rm "$filename" 31 | } 32 | trap finish EXIT 33 | 34 | adb shell "$@" "$filename" 35 | -------------------------------------------------------------------------------- /add-art: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Add album art to music using ffmpeg. 3 | # 4 | # http://stackoverflow.com/questions/18710992/how-to-add-album-art-with-ffmpeg 5 | # Author: metakirby5 6 | 7 | usage() { 8 | echo "USAGE: $(basename "$0") -i [image file / url] [music file(s)]" 9 | exit 1 10 | } 11 | 12 | # http://stackoverflow.com/a/14203146 13 | OPTIND=1 14 | image="" 15 | TMP="" 16 | 17 | while getopts "i:" opt; do 18 | case "$opt" in 19 | i) 20 | image=$OPTARG 21 | ;; 22 | esac 23 | done 24 | 25 | shift $((OPTIND-1)) 26 | 27 | # Sanity checks 28 | [ "$#" -lt 1 ] && usage 29 | 30 | for file in "$@"; do 31 | [ ! -f "$file" ] && usage 32 | done 33 | 34 | if [ ! -f "$image" ]; then 35 | [[ "$image" != http* ]] && usage 36 | 37 | # Download the image to a temporary file 38 | TMP="$(mktemp).${image##*.}" 39 | curl "$image" -o "$TMP" 2>/dev/null || (echo "URL invalid." && exit 1) 40 | image="$TMP" 41 | fi 42 | 43 | for file in "$@"; do 44 | OUT="$(mktemp).mp3" 45 | 46 | # Do the tagging 47 | ffmpeg -y -i "$file" -i "$image" \ 48 | -map 0:0 -map 1:0 -c copy -id3v2_version 3 \ 49 | -metadata:s:v title="Album cover" \ 50 | -metadata:s:v comment="Cover (Front)" "$OUT" 2>/dev/null &&\ 51 | mv "$OUT" "$file" 52 | done 53 | 54 | # Clean up 55 | [ -f "$TMP" ] && rm "$TMP" 56 | 57 | -------------------------------------------------------------------------------- /add-current-art: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Add album art to currently playing in mpd. 3 | # 4 | # Author: metakirby5 5 | 6 | usage() { 7 | echo "USAGE: $(basename "$0") [image file]" 8 | exit 1 9 | } 10 | 11 | # Sanity checks 12 | [ "$#" -ne 1 ] && usage 13 | 14 | add-art -i "$1" "${XDG_MUSIC_DIR%%/}/$(mpc current --format '%file%')" 15 | 16 | -------------------------------------------------------------------------------- /anichk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # PYTHON_ARGCOMPLETE_OK 3 | 4 | """ 5 | Uses the kitsu.io API and anilist.co API to tell you what episodes you need to 6 | catch up on. Series limit is 500. 7 | 8 | Required environment variables: 9 | $OAUTH2_ANILIST_ID, $OAUTH2_ANILIST_SECRET: anilist.co Oauth2 credentials. 10 | Optional environment variables: 11 | $KITSU_USERNAME: The default username to check. Can be overridden with the 12 | `username` arg. 13 | 14 | Author: metakirby5 15 | """ 16 | 17 | import os 18 | import re 19 | import requests 20 | import json 21 | import pytz 22 | import tzlocal 23 | from sys import exit 24 | from os import environ 25 | from datetime import datetime, timedelta 26 | from humanize import naturaltime 27 | from unidecode import unidecode 28 | from argparse import ArgumentParser, RawDescriptionHelpFormatter 29 | from argcomplete import autocomplete 30 | 31 | # Constants and helpers 32 | KT_API = 'https://kitsu.io/api/edge/' 33 | AL_API = 'https://anilist.co/api/' 34 | KT_CACHE = os.path.expanduser('~/.cache/kitsu/usernames') 35 | AL_TOKEN = os.path.expanduser('~/.local/tokens/anilist/client') 36 | END = '\033[0m' 37 | SEASONS = ('winter', 'spring', 'summer', 'fall') 38 | RE_LONG_VOWELS = re.compile(r'([aeiou])\1+') 39 | RE_REPLACES = [(re.compile(pat), replacewith) for pat, replacewith in [ 40 | (r' \([^)]*\)', r''), # (TV), (Web), etc 41 | (r'(\d)(st|nd|rd|th) Season', r'\1') # nth Season 42 | ]] 43 | OVERRIDES = { 44 | 'Youjo Senki: Saga of Tanya the Evil': 'Youjo Senki', 45 | 'Kobayashi-san Chi no Maid Dragon': 'Kobayashi-san Chi no Maidragon', 46 | 'Yuuki Yuuna wa Yuusha de Aru: Yuusha no Shou': 47 | 'Yuuki Yuuna wa Yuusha de Aru: Washio Sumi no Shou / Yuusha no Shou', 48 | } 49 | 50 | 51 | def normalize(s): 52 | s = OVERRIDES.get(s, s) 53 | for regex, replacewith in RE_REPLACES: 54 | s = regex.sub(replacewith, s) 55 | s = RE_LONG_VOWELS.sub(r'\1', s) 56 | s = ''.join(c.lower() for c in unidecode(s) if c.isalnum()) 57 | return s 58 | 59 | 60 | def red(s): 61 | return '\033[31m{}{}'.format(s, END) 62 | 63 | 64 | def green(s): 65 | return '\033[32m{}{}'.format(s, END) 66 | 67 | 68 | def yellow(s): 69 | return '\033[33m{}{}'.format(s, END) 70 | 71 | 72 | def exit_with(s): 73 | print('{}\n'.format(red(s))) 74 | exit(1) 75 | 76 | 77 | # Get environment variables 78 | try: 79 | AL_ID = os.environ['OAUTH2_ANILIST_ID'] 80 | AL_SECRET = os.environ['OAUTH2_ANILIST_SECRET'] 81 | except KeyError: 82 | exit_with('Environment variables $OAUTH2_ANILIST_ID ' 83 | 'and $OAUTH2_ANILIST_SECRET required.') 84 | 85 | 86 | # Parse args 87 | parser = ArgumentParser(description=__doc__, 88 | formatter_class=RawDescriptionHelpFormatter) 89 | parser.add_argument('--porcelain', 90 | help="only output unwatched as [series] [episode #]", 91 | action='store_true') 92 | parser.add_argument('-v', 93 | help="verbose", 94 | action='store_true') 95 | parser.add_argument('username', 96 | help="kitsu.io username", 97 | nargs='?', 98 | type=str, 99 | default=environ.get('KITSU_USERNAME')) 100 | autocomplete(parser) 101 | args = parser.parse_args() 102 | porcelain = args.porcelain 103 | verbose = args.v 104 | username = args.username 105 | 106 | if not username: 107 | exit_with("No username provided.") 108 | 109 | 110 | # Printing functions 111 | def human(s=''): 112 | if not porcelain: 113 | print(s) 114 | 115 | 116 | def machine(s=''): 117 | if porcelain: 118 | print(s) 119 | 120 | 121 | def json_pp(d): 122 | return json.dumps(d, sort_keys=True, indent=4, separators=(',', ': ')) 123 | 124 | 125 | def get_json(url, params={}): 126 | return json.loads(requests.get(url, params=params).text) 127 | 128 | 129 | # Get user ID 130 | os.makedirs(KT_CACHE, exist_ok=True) 131 | KT_CACHED_UID = os.path.join(KT_CACHE, username) 132 | try: 133 | with open(KT_CACHED_UID, 'r') as f: 134 | uid = int(f.read()) 135 | except FileNotFoundError: 136 | human('Fetching user ID for {}...'.format(username)) 137 | try: 138 | uid = get_json(KT_API + 'users', params={ 139 | 'fields[users]': 'id', 140 | 'filter[name]': username, 141 | })['data'][0]['id'] 142 | except OSError: 143 | exit_with("Could not reach kitsu.io.") 144 | except ValueError: 145 | exit_with("{} isn't on kitsu.io.".format(username)) 146 | with open(KT_CACHED_UID, 'w') as f: 147 | f.write(uid) 148 | 149 | 150 | # Get your currently watching anime 151 | human('Fetching library entries...'.format(uid)) 152 | kt = get_json(KT_API + 'library-entries', params={ 153 | 'page[limit]': 500, 154 | 'include': 'anime', 155 | 'fields[libraryEntries]': 'progress,anime', 156 | 'fields[anime]': 'titles,canonicalTitle,episodeCount', 157 | 'filter[status]': 'current', 158 | 'filter[userId]': uid, 159 | }) 160 | 161 | if not kt['data']: 162 | exit_with("{} isn't watching anything.".format(username)) 163 | 164 | anime_by_id = { 165 | a['id']: a['attributes'] 166 | for a in kt['included'] 167 | } 168 | 169 | # Get anilist.co credentials if needed 170 | os.makedirs(os.path.dirname(AL_TOKEN), exist_ok=True) 171 | try: 172 | now_utc = datetime.now(tzlocal.get_localzone()).astimezone(pytz.utc) 173 | with open(AL_TOKEN, 'r') as f: 174 | token = json.load(f) 175 | expiry = datetime.fromtimestamp( 176 | token['expires'] - 60, pytz.utc) 177 | if expiry < now_utc: 178 | raise IOError 179 | except: 180 | human('Authenticating with anilist.co...') 181 | 182 | # Delete existing token 183 | try: 184 | os.remove(AL_TOKEN) 185 | except OSError: 186 | pass 187 | 188 | content = requests.post( 189 | AL_API + 'auth/access_token', 190 | data={ 191 | 'grant_type': 'client_credentials', 192 | 'client_id': AL_ID, 193 | 'client_secret': AL_SECRET, 194 | }).text 195 | token = json.loads(content) 196 | if 'error' in token: 197 | exit_with('Error. {error}: {error_description}'.format(**token)) 198 | with open(AL_TOKEN, 'w') as f: 199 | f.write(content) 200 | 201 | # Get currently airing anime 202 | human('Fetching currently airing series from anilist.co...') 203 | ac = [] 204 | now = datetime.now() 205 | season_num = (now.month - 1) // 3 206 | seasons = [SEASONS[season_num - 1], SEASONS[season_num]] 207 | try: 208 | for season in seasons: 209 | human('Getting season {} {}...'.format(season, now.year)) 210 | ac += get_json( 211 | AL_API + 'browse/anime', 212 | params={ 213 | 'access_token': token['access_token'], 214 | 'year': now.year, 215 | 'season': season, 216 | 'full_page': 'true', 217 | 'airing_data': 'true', 218 | }) 219 | except OSError: 220 | exit_with("Could not reach anilist.co.") 221 | except ValueError: 222 | exit_with("Malformed anichart.net JSON.") 223 | 224 | airing = {} 225 | if verbose: 226 | human('=== AIRING ===') 227 | for a in ac: 228 | airing[normalize(a['title_romaji'])] = a['airing'] 229 | # Sometimes kitsu.io will put english for romaji... 230 | airing[normalize(a['title_english'])] = a['airing'] 231 | if verbose: 232 | human('\n{}:\n{}'.format(a['title_romaji'], json_pp(a))) 233 | 234 | # Create list of series 235 | anime = [] 236 | if verbose: 237 | human('=== KITSU ===') 238 | for info in kt['data']: 239 | attrs = info['attributes'] 240 | attrs.update(anime_by_id[info['relationships']['anime']['data']['id']]) 241 | # For currently airing shows, pull in next episode attrs 242 | attrs.update(airing.get(normalize(attrs['titles']['en_jp'])) or {}) 243 | anime.append(attrs) 244 | if verbose: 245 | human('\n{}:\n{}'.format(attrs['canonicalTitle'], json_pp(attrs))) 246 | anime.sort(key=lambda i: i['canonicalTitle']) 247 | 248 | # Print info 249 | human() 250 | for a in anime: 251 | title = a['canonicalTitle'] 252 | cur = a['progress'] 253 | total = a['episodeCount'] 254 | 255 | try: 256 | available = a['next_episode'] - 1 257 | except KeyError: 258 | available = total 259 | 260 | # Only bother if we haven't finished the series 261 | if not total or cur < total: 262 | # If we're waiting for next episode 263 | if not available or cur == available: 264 | # Create human-readable countdown 265 | try: 266 | time = naturaltime( 267 | now + timedelta(seconds=a['countdown']) 268 | ).replace( 269 | ' from now', '' 270 | ).replace( 271 | 'hour', 'hr' 272 | ).replace( 273 | 'minute', 'min' 274 | ).replace( 275 | 'second', 'sec' 276 | ) 277 | # Unknown time 278 | except KeyError: 279 | time = 'UNKNOWN' 280 | status = green(time) 281 | # If we're behind 282 | elif cur < available: 283 | printer = yellow if available == total else green 284 | status = printer('{}/{}'.format(cur, available)) 285 | machine(u'{} {}'.format(title, cur + 1)) 286 | # Invalid state 287 | else: 288 | status = red('INVALID') 289 | # We need to mark this as complete 290 | else: 291 | status = red('COMPLTE') 292 | 293 | # Status must be colored to be padded correctly 294 | human(u'{:>16} {}'.format(status, title)) 295 | human() 296 | -------------------------------------------------------------------------------- /anime: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Gentle encouragement with anime, brought to you by 1339.cf. 3 | # 4 | # Author: metakirby5 5 | 6 | ANIME="$(mktemp).png" 7 | ANIME_WIDTH="250" 8 | 9 | curl -sfL "http://1339.cf/grill.php" -o "$ANIME" 10 | mogrify -resize "$ANIME_WIDTH" "$ANIME" 11 | notify-send -i "$ANIME" -a "1339.cf" "頑張れ!" 12 | 13 | -------------------------------------------------------------------------------- /aniplay: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Chains together anichk with anistrm to play a random show. 3 | # 4 | # Author: metakirby5 5 | 6 | echo "Querying your list..." 7 | show="$(anichk --porcelain | shuf | head -n1)" 8 | echo "Let's watch $show!" 9 | anistrm "$show" 10 | -------------------------------------------------------------------------------- /anistrm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # PYTHON_ARGCOMPLETE_OK 3 | 4 | """ 5 | A personal script to mpv an anime episode. 6 | 7 | Required environment variables: 8 | `ANISTRM_URL`: The base URL to search from 9 | `ANISTRM_EXT`: The extension of expected videos 10 | 11 | Optional environment variables: 12 | `ANISTRM_PROGRAM`: The program to use to play anime. Defaults to 'mpv', 13 | and can be overridden with the `--program` flag. 14 | 15 | Author: metakirby5 16 | """ 17 | 18 | import re 19 | import requests 20 | from sys import exit 21 | from os import environ 22 | from subprocess import call 23 | from bs4 import BeautifulSoup 24 | from urllib.parse import unquote_plus 25 | from urllib.parse import urljoin 26 | from fuzzywuzzy import fuzz, process 27 | from argparse import ArgumentParser, RawDescriptionHelpFormatter 28 | from argcomplete import autocomplete 29 | 30 | NUMS = re.compile(r'\b0+(\d)') 31 | 32 | 33 | def exit_with(s): 34 | print('\033[31m{}\033[0m\n'.format(s)) 35 | exit(1) 36 | 37 | 38 | def normalize(s): 39 | return NUMS.sub(r'\1', s) 40 | 41 | 42 | parser = ArgumentParser(description=__doc__, 43 | formatter_class=RawDescriptionHelpFormatter) 44 | parser.add_argument('--program', 45 | help="program to use on the link", 46 | nargs='?', 47 | default=environ.get('ANISTRM_PROGRAM', 'mpv'), 48 | type=str) 49 | parser.add_argument('search_terms', 50 | help="anime series + episode number", 51 | nargs='+', 52 | type=str) 53 | autocomplete(parser) 54 | args = parser.parse_args() 55 | program = args.program.split(' ') 56 | search_terms = normalize(' '.join(args.search_terms)) 57 | 58 | try: 59 | base = environ['ANISTRM_URL'] 60 | ext = environ['ANISTRM_EXT'] 61 | except KeyError: 62 | exit_with("You need ANISTRM_URL and ANISTRM_EXT.") 63 | 64 | link = base 65 | while not link.endswith(ext): 66 | try: 67 | req = requests.get(link) 68 | except requests.exceptions.ConnectionError: 69 | exit_with("Could not reach \"{}\".".format(link)) 70 | 71 | links = BeautifulSoup(req.text, 'html.parser').findAll('a') 72 | if not links: 73 | exit_with("Leaf link \"{}\" is not a video.".format(link)) 74 | 75 | _, _, path = process.extractOne( 76 | search_terms, {l.get('href'): normalize(l.string) for l in links}, 77 | scorer=fuzz.token_set_ratio) 78 | 79 | link = urljoin(base, path) 80 | print('-> {}'.format(unquote_plus(link))) 81 | program.append(link) 82 | call(program) 83 | -------------------------------------------------------------------------------- /aniup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Quick and dirty script to increment the watched count for an episode. 3 | # 4 | # Dependencies: curl, jq, fzf 5 | # 6 | # Optional environment variables: 7 | # $KITSU_USERNAME: The default username to check. Can be overriden with $1. 8 | # 9 | # Author: metakirby5 10 | 11 | checkdep() { 12 | type "$1" &>/dev/null || echo " $1" 13 | } 14 | 15 | missing="$(checkdep curl)$(checkdep jq)$(checkdep fzf)" 16 | if [ "$missing" ]; then 17 | echo "The following dependencies are missing:$missing" 18 | exit 1 19 | fi 20 | 21 | usage() { 22 | echo "Usage: $(basename "$0") [kitsu.io username]" 23 | exit 1 24 | } 25 | 26 | # Complain if too many args 27 | [ "$#" -gt 1 ] && usage 28 | [[ "$1" == -* ]] && usage 29 | 30 | # If arg provided, use it 31 | [ "$1" ] && KITSU_USERNAME="$1" 32 | 33 | # Check for required variables 34 | if [ -z "$KITSU_USERNAME" ]; then 35 | echo 'Required: $KITSU_USERNAME' 36 | exit 1 37 | fi 38 | 39 | maybe_exit() { 40 | if [ -z "$1" ]; then 41 | echo "$2" 42 | exit "${3:-1}" 43 | fi 44 | } 45 | 46 | base="https://kitsu.io/api" 47 | api="$base/edge" 48 | oauth="$base/oauth" 49 | 50 | uid_cache=~/.cache/kitsu/usernames/"$KITSU_USERNAME" 51 | token_dir=~/.local/tokens/kitsu/password 52 | mkdir -p "$token_dir" 53 | 54 | # Try to get existing token 55 | token_file="$token_dir/$KITSU_USERNAME" 56 | if [ -f "$token_file" ]; then 57 | # If not expired, simply use it 58 | expiry="$(jq -r '.created_at + .expires_in // ""' "$token_file")" 59 | if [ "${expiry:-0}" -gt "$(date +%s)" ]; then 60 | token_json="$(< "$token_file")" 61 | # Otherwise, grab a new one 62 | else 63 | refresh_token="$(jq -r '.refresh_token // ""' "$token_file")" 64 | if [ "$refresh_token" ]; then 65 | token_json="$(curl -sfgX POST \ 66 | -d "grant_type=refresh_token&refresh_token=$refresh_token" \ 67 | "$oauth/token")" 68 | [ "$token_json" ] && 69 | jq '.refresh_token = "'$refresh_token'"' \ 70 | <<< "$token_json" > "$token_file" 71 | fi 72 | fi 73 | fi 74 | 75 | # If we failed to get it, prompt to authorize 76 | if [ -z "$token_json" ]; then 77 | [ -z "$KITSU_PASSWORD" ] && read -sp \ 78 | "Enter the password for $KITSU_USERNAME: " KITSU_PASSWORD 79 | echo 80 | 81 | token_json="$(curl -sfgX POST \ 82 | -d \ 83 | "grant_type=password\ 84 | &username=$KITSU_USERNAME\ 85 | &password=$KITSU_PASSWORD" \ 86 | "$oauth/token")" 87 | maybe_exit "$token_json" 'Failed to authenticate.' 88 | 89 | echo "$token_json" > "$token_file" 90 | fi 91 | 92 | token="$(jq -r '.access_token' <<< "$token_json")" 93 | 94 | # Get user ID 95 | uid="$(< "$uid_cache")" 96 | if [ -z "$uid" ]; then 97 | echo "Fetching user ID for $KITSU_USERNAME..." 98 | uid="$(curl -sfg \ 99 | "$api/users\ 100 | ?fields[users]=id\ 101 | &filter[name]=$KITSU_USERNAME" |\ 102 | jq -r '.data[0].id')" 103 | maybe_exit "$uid" 'Failed to get user ID.' 104 | fi 105 | 106 | # Fetch entries 107 | echo "Fetching library entries..." 108 | entries="$(curl -sfg \ 109 | "$api/library-entries\ 110 | ?page[limit]=500\ 111 | &include=anime\ 112 | &fields[libraryEntries]=progress,anime\ 113 | &fields[anime]=canonicalTitle,episodeCount\ 114 | &filter[status]=current\ 115 | &filter[userId]=$uid" |\ 116 | jq -r '( 117 | .included | 118 | map({key: .id, 119 | value: {title: .attributes.canonicalTitle, 120 | eps: .attributes.episodeCount}}) | from_entries 121 | ) as $index | .data[] | $index[.relationships.anime.data.id] as $entry | 122 | "\(.id)\t\(.attributes.progress)/\($entry.eps // "?")\t\($entry.title)"')" 123 | maybe_exit "$entries" "No entries found for $KITSU_USERNAME." 0 124 | 125 | # Get user selection 126 | selection="$(fzf --prompt "Series to increment: " \ 127 | --with-nth 2.. <<< "$entries")" 128 | maybe_exit "$selection" "Cancelling." 0 129 | id="$(cut -f1 <<< "$selection")" 130 | ep_stats="$(cut -f2 <<< "$selection")" 131 | anime="$(cut -f3- <<< "$selection")" 132 | next_ep="$((${ep_stats%%/*} + 1))" 133 | final_ep="${ep_stats##*/}" 134 | 135 | # Request rating if final episode 136 | rating_twenty= 137 | rating_info= 138 | if [ "$next_ep" == "$final_ep" ]; then 139 | echo "Final episode, requesting rating." 140 | rating="$(seq 1 20 |\ 141 | awk '{print $1 "\t" $1 / 2}' |\ 142 | fzf --prompt "Rating: " \ 143 | --with-nth 2..)" 144 | maybe_exit "$rating" "No rating provided." 145 | rating_twenty="ratingTwenty: $(cut -f1 <<< "$rating")," 146 | rating_info=", rated $(cut -f2 <<< "$rating")" 147 | fi 148 | 149 | json_patch="$(jq -r \ 150 | '. = { 151 | access_token: "'"$token"'", 152 | data: { 153 | type: "library-entries", 154 | id: '"$id"', 155 | attributes: { 156 | '"$rating_twenty"' 157 | progress: '"$next_ep"' 158 | } 159 | } 160 | }' <<< '{}')" 161 | 162 | curl -sfgX PATCH \ 163 | -d "$json_patch" \ 164 | -H 'Content-Type: application/vnd.api+json' \ 165 | "$api/library-entries/$id" &>/dev/null && 166 | echo "Updated $anime to episode ${next_ep}${rating_info}." || 167 | echo "Failed to update $anime to episode $next_ep." 168 | -------------------------------------------------------------------------------- /aquote: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Notify with anime quotes. 3 | # 4 | # Author: metakirby5 5 | 6 | usage() { 7 | echo "USAGE: $(basename "$0") [hummingbird.me anime id]" 8 | exit 1 9 | } 10 | 11 | [ "$#" -ne 1 ] && usage 12 | 13 | anime="$(echo "$1" |\ 14 | tr '[:upper:]' '[:lower:]' | awk '{$1=$1};1' | tr ' ' '-')" 15 | len=50 16 | 17 | notify() { 18 | if type notify-send &>/dev/null; then 19 | notify-send -a 'aquote' "$1" "$2" 20 | elif type osascript &>/dev/null; then 21 | osascript -e "display notification \"$(tr -d \" <<< "$2")\" \ 22 | with title \"$(tr -d \" <<< "$1")\"" 23 | else 24 | echo 'No notifier available.' 25 | exit 1 26 | fi 27 | } 28 | 29 | json="$(curl -s \ 30 | -H 'Accept: application/json' \ 31 | -H 'X-Requested-With: XMLHttpRequest' \ 32 | "https://hummingbird.me/quotes?anime_id=$anime")" 33 | 34 | num_quotes="$(echo "$json" | jq '.quotes | length')" 35 | if [ "$num_quotes" -eq 0 ]; then 36 | notify "Anime \"$anime\" not found!" 37 | exit 1 38 | fi 39 | 40 | selected_num="$((RANDOM % $num_quotes))" 41 | selected="$(echo "$json" | jq ".quotes[$selected_num]")" 42 | quote="$(echo "$selected" | jq -r '.content' | fold -sw "$len")" 43 | who="$(echo "$selected" | jq -r '.character_name')" 44 | 45 | notify "$(echo "$anime" | sed 's/\b\(.\)/\u\1/g' | tr '-' ' ')" \ 46 | "$quote\n\n\t-$who" 47 | 48 | -------------------------------------------------------------------------------- /autozb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs colorz on an image file to get 6 colors, then stuffs those colors 3 | # through zenbu. 4 | # 5 | # Author: metakirby5 6 | 7 | usage() { 8 | echo "USAGE: $(basename "$0") [image file / URL] (primary color) (secondary color)" 9 | echo "Resources will be saved at ~/.local/zenbu/auto/" 10 | echo "Available colors: red, green, yellow," 11 | echo " blue, magenta, cyan" 12 | echo "Defaults: primary = red, secondary = blue" 13 | exit 1 14 | } 15 | 16 | # Sanity checks, getting args 17 | [ "$#" -lt 1 ] || [ "$#" -gt 3 ] && usage 18 | 19 | RES=~/.local/zenbu/auto/ 20 | SRC="$RES/wall.png" 21 | 22 | COLORS=( 23 | red 24 | green 25 | yellow 26 | blue 27 | magenta 28 | cyan 29 | ) 30 | 31 | is_a_color() { 32 | [[ " ${COLORS[*]} " == *" $1 "* ]] 33 | return $? 34 | } 35 | 36 | read -r -d '' TEMPLATE << EOM 37 | wallpapers: "%s" 38 | 39 | colors: 40 | name: "%s" 41 | primary: "%s" 42 | secondary: "%s" 43 | red: 44 | normal: "%s" 45 | bold: "%s" 46 | green: 47 | normal: "%s" 48 | bold: "%s" 49 | yellow: 50 | normal: "%s" 51 | bold: "%s" 52 | blue: 53 | normal: "%s" 54 | bold: "%s" 55 | magenta: 56 | normal: "%s" 57 | bold: "%s" 58 | cyan: 59 | normal: "%s" 60 | bold: "%s" 61 | EOM 62 | 63 | mkdir -p "$RES" 64 | 65 | if [ ! -f "$1" ]; then 66 | [[ "$1" != http* ]] && usage 67 | 68 | curl "$1" -o "$SRC" 2>/dev/null || (echo "URL invalid." && exit 1) 69 | else 70 | cp "$1" "$SRC" 2>/dev/null 71 | fi 72 | 73 | if [ -z "$2" ]; then 74 | # Default 75 | primary="red" 76 | else 77 | is_a_color "$2" && primary="$2" || usage 78 | fi 79 | 80 | if [ -z "$3" ]; then 81 | # Default 82 | secondary="blue" 83 | else 84 | is_a_color "$3" && secondary="$3" || usage 85 | fi 86 | 87 | # Starting... 88 | echo "Using primary = $primary, secondary = $secondary..." 89 | echo 90 | 91 | colors="$(colorz --no-preview -n 6 "$SRC")" 92 | [ "${PIPESTATUS[0]}" -ne 0 ] && exit 1 93 | 94 | yaml="$(echo \ 95 | "$(readlink -f "$SRC")" "$(basename "$1" | cut -f 1 -d .)" \ 96 | "$primary" "$secondary" \ 97 | "$colors" |\ 98 | xargs printf "$TEMPLATE")" 99 | 100 | echo "Generated YAML:" 101 | echo "$yaml" | tee "$RES/colors.yaml" 102 | echo 103 | 104 | echo "Running zenbu..." 105 | zenbu -e <(echo "$yaml") 106 | -------------------------------------------------------------------------------- /bat-notify-daemon: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Sends a notification once per 30 seconds if the battery is at or below 15% 3 | # and is not charging. 4 | # 5 | # Author: metakirby5 6 | 7 | DUNSTIFY_ID="/tmp/bat-notify_dunstify_id" 8 | 9 | notify() { 10 | info="$(upower -i /org/freedesktop/UPower/devices/battery_BAT1)" 11 | percent="$(echo "$info" | awk '/percentage/{ gsub(/%/, ""); print $2 }')" 12 | charging="$(echo "$info" | awk '/state/{ print $2 }')" 13 | 14 | if [[ "$percent" -le 15 && "$charging" != 'charging' ]]; then 15 | # Get the dunstify id 16 | [ ! -z "$(cat "$DUNSTIFY_ID")" ] && id_arg="-r $(cat "$DUNSTIFY_ID")" 17 | 18 | dunstify \ 19 | -a "bat-notify" \ 20 | -p $id_arg > "$DUNSTIFY_ID" \ 21 | -u C "Battery at ${percent}%!" 22 | fi 23 | } 24 | 25 | acpi_listen | while read -r line && [[ "$line" == ac_adapter* ]]; do 26 | sleep 5 27 | notify 28 | done & 29 | 30 | while true; do 31 | notify 32 | sleep 30 33 | done & 34 | 35 | wait 36 | -------------------------------------------------------------------------------- /bw-pw: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # List bitwarden passwords in sorted order. 3 | 4 | bw sync 5 | bw list items | 6 | jq -r ' 7 | sort_by(.login.password) | 8 | .[] | [.name, .login.password // "-", .revisionDate] | @tsv 9 | ' | 10 | column -ts $'\t' | less 11 | -------------------------------------------------------------------------------- /c-abcdef: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Autor: Ivo 4 | # ANSI Color -- use these variables to easily have different color 5 | # and format output. Make sure to output the reset sequence after 6 | # colors (f = foreground, b = background), and use the 'off' 7 | # feature for anything you turn on. 8 | # 9 | 10 | initializeANSI() 11 | { 12 | esc="" 13 | 14 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 15 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 16 | cyanf="${esc}[36m"; whitef="${esc}[37m" whitef="${esc}[37m" 17 | 18 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 19 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 20 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 21 | 22 | boldon="${esc}[1m"; boldoff="${esc}[22m" 23 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 24 | ulon="${esc}[4m"; uloff="${esc}[24m" 25 | invon="${esc}[7m"; invoff="${esc}[27m" 26 | 27 | reset="${esc}[0m" 28 | } 29 | 30 | # note in this first use that switching colors doesn't require a reset 31 | # first - the new color overrides the old one. 32 | 33 | initializeANSI 34 | 35 | cat << EOF 36 | 37 | ${boldon}${redf} ██████ ${reset} ${boldon}${greenf}██████ ${reset}${boldon}${yellowf} ██████${reset} ${boldon}${bluef}██████ ${reset} ${boldon}${purplef} ██████${reset} ${boldon}${cyanf} ███████${reset} 38 | ${boldon}${redf} ████████${reset} ${boldon}${greenf}██ ██ ${reset}${boldon}${yellowf}██ ${reset} ${boldon}${bluef}██ ██${reset} ${boldon}${purplef}██████ ${reset} ${boldon}${cyanf}█████████${reset} 39 | ${redf} ██ ████${reset} ${greenf}██ ████ ${reset}${yellowf}████ ${reset} ${bluef}████ ██${reset} ${purplef}████ ${reset} ${cyanf}█████ ${reset} 40 | ${redf} ██ ██${reset} ${greenf}██████ ${reset}${yellowf}████████${reset} ${bluef}██████ ${reset} ${purplef}████████${reset} ${cyanf}██ ${reset} 41 | 42 | EOF -------------------------------------------------------------------------------- /c-bars: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo 4 | for f in {0..6}; do 5 | echo -en "\033[$((f+41))m\033[$((f+30))m██▓▒░" 6 | done 7 | echo -en "\033[37m██" 8 | 9 | echo -e "\033[0m" 10 | 11 | for f in {0..6}; do 12 | echo -en "\033[$((f+41))m\033[1;$((f+30))m██▓▒░" 13 | done 14 | echo -en "\033[1;37m██" 15 | 16 | echo -e "\033[0m" 17 | echo 18 | -------------------------------------------------------------------------------- /c-batman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # ANSI color scheme script by pfh 4 | # 5 | # Initializing mod by lolilolicon from Archlinux 6 | # 7 | 8 | f=3 b=4 9 | for j in f b; do 10 | for i in {0..7}; do 11 | printf -v $j$i %b "\e[${!j}${i}m" 12 | done 13 | done 14 | bld=$'\e[1m' 15 | rst=$'\e[0m' 16 | inv=$'\e[7m' 17 | 18 | cat << EOF 19 | 20 | $f3 ██████████████████████████████████████ 21 | $f3 ██████████████████████████████████████████ 22 | $f3 ██████ ████████████████████████████ ██████ 23 | $f3 █████ ████████████ ████ ████████████ █████ 24 | $f3 ███ ████████████ ████████████ ███ 25 | $f3 ███ ███ 26 | $f3 ███ ███ 27 | $f3 ███ █████████ ████ ████ █████████ ███ 28 | $f3 █████ ███████████████ ███████████████ █████ 29 | $f3 ██████ ████████████████████████████ ██████ 30 | $f3 ██████████████████████████████████████████ 31 | $f3 ██████████████████████████████████████ 32 | $rst 33 | EOF -------------------------------------------------------------------------------- /c-blocks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${redf}▀ █${reset} ${boldon}${redf}█ ▀${reset} ${greenf}▀ █${reset} ${boldon}${greenf}█ ▀${reset} ${yellowf}▀ █${reset} ${boldon}${yellowf}█ ▀${reset} ${bluef}▀ █${reset} ${boldon}${bluef}█ ▀${reset} ${purplef}▀ █${reset} ${boldon}${purplef}█ ▀${reset} ${cyanf}▀ █${reset} ${boldon}${cyanf}█ ▀${reset} 36 | ${redf}██${reset} ${boldon}${redf} ██${reset} ${greenf}██${reset} ${boldon}${greenf}██${reset} ${yellowf}██${reset} ${boldon}${yellowf}██${reset} ${bluef}██${reset} ${boldon}${bluef}██${reset} ${purplef}██${reset} ${boldon}${purplef}██${reset} ${cyanf}██${reset} ${boldon}${cyanf}██${reset} 37 | ${redf}▄ █${reset}${boldon}${redf} █ ▄ ${reset} ${greenf}▄ █ ${reset}${boldon}${greenf}█ ▄${reset} ${yellowf}▄ █ ${reset}${boldon}${yellowf}█ ▄${reset} ${bluef}▄ █ ${reset}${boldon}${bluef}█ ▄${reset} ${purplef}▄ █ ${reset}${boldon}${purplef}█ ▄${reset} ${cyanf}▄ █ ${reset}${boldon}${cyanf}█ ▄${reset} 38 | 39 | EOF -------------------------------------------------------------------------------- /c-blocks2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${redf}▒▒▒▒${reset} ${boldon}${redf}▒▒${reset} ${greenf}▒▒▒▒${reset} ${boldon}${greenf}▒▒${reset} ${yellowf}▒▒▒▒${reset} ${boldon}${yellowf}▒▒${reset} ${bluef}▒▒▒▒${reset} ${boldon}${bluef}▒▒${reset} ${purplef}▒▒▒▒${reset} ${boldon}${purplef}▒▒${reset} ${cyanf}▒▒▒▒${reset} ${boldon}${cyanf}▒▒${reset} 36 | ${redf}▒▒ ■${reset} ${boldon}${redf}▒▒${reset} ${greenf}▒▒ ■${reset} ${boldon}${greenf}▒▒${reset} ${yellowf}▒▒ ■${reset} ${boldon}${yellowf}▒▒${reset} ${bluef}▒▒ ■${reset} ${boldon}${bluef}▒▒${reset} ${purplef}▒▒ ■${reset} ${boldon}${purplef}▒▒${reset} ${cyanf}▒▒ ■${reset} ${boldon}${cyanf}▒▒${reset} 37 | ${redf}▒▒ ${reset}${boldon}${redf}▒▒▒▒${reset} ${greenf}▒▒ ${reset}${boldon}${greenf}▒▒▒▒${reset} ${yellowf}▒▒ ${reset}${boldon}${yellowf}▒▒▒▒${reset} ${bluef}▒▒ ${reset}${boldon}${bluef}▒▒▒▒${reset} ${purplef}▒▒ ${reset}${boldon}${purplef}▒▒▒▒${reset} ${cyanf}▒▒ ${reset}${boldon}${cyanf}▒▒▒▒${reset} 38 | 39 | EOF -------------------------------------------------------------------------------- /c-cirno: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | 5 |  ████ ████ 6 |  ██████████ ██████████ 7 |  ██████████████████████████████████ 8 |  ██████████████████████████████████████ 9 |  ██████████████████████████████████████ 10 |  ██████████████████████████████████████ 11 |  ██████████████████████████████████████ 12 |  ██████████████████████████████████████ 13 |  ██████████████████████████████████████ 14 |  ██████████████████████████████████ 15 |  ██████████████████████████████████████████ 16 | ██████████████████████████████████████████████ 17 |  ██████████████████████████████████████████ 18 |  ██████████████████████████████████████ 19 |  ██████████████████████████████████ 20 |  ██████████████████████████ 21 |  ██ ██ ██████████ ██ ██ 22 |  ██████ ██████████████ ██████ 23 | ██████████ ██████████████ ██████████ 24 |  ██████ ██████████████████ ██████ 25 |  ██ ██████████████████████ ██  26 |  ██████████████████  27 |  ██████████████  28 |  ██████████  29 |  ██████████ 30 |  31 | EOF 32 | -------------------------------------------------------------------------------- /c-determination: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://github.com/roberoonska/dotfiles/tree/master/colorscripts 3 | 4 | f=3 b=4 5 | for j in f b; do 6 | for i in {0..7}; do 7 | printf -v $j$i %b "\e[${!j}${i}m" 8 | done 9 | done 10 | bld=$'\e[1m' 11 | rst=$'\e[0m' 12 | inv=$'\e[7m' 13 | cat << EOF 14 | 15 | ${f1} ▄▄ ▄▄ ${f2} ▄▄ ▄▄ ${f3} ▄▄ ▄▄ ${f4} ▄▄ ▄▄ ${f5} ▄▄ ▄▄ ${f6} ▄▄ ▄▄ 16 | ${f1}▄█████▄ ▄█████▄ ${f2}▄█████▄ ▄█████▄ ${f3}▄█████▄ ▄█████▄ ${f4}▄█████▄ ▄█████▄ ${f5}▄█████▄ ▄█████▄ ${f6}▄█████▄ ▄█████▄ 17 | ${f1}███████▄▄███████ ${f2}███████▄▄███████ ${f3}███████▄▄███████ ${f4}███████▄▄███████ ${f5}███████▄▄███████ ${f6}███████▄▄███████ 18 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 19 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 20 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 21 | ${f1} ████████████ ${f2} ████████████ ${f3} ████████████ ${f4} ████████████ ${f5} ████████████ ${f6} ████████████ 22 | ${f1} ████████ ${f2} ████████ ${f3} ████████ ${f4} ████████ ${f5} ████████ ${f6} ████████ 23 | ${f1} ████ ${f2} ████ ${f3} ████ ${f4} ████ ${f5} ████ ${f6} ████ $bld 24 | ${f1} ▄▄ ▄▄ ${f2} ▄▄ ▄▄ ${f3} ▄▄ ▄▄ ${f4} ▄▄ ▄▄ ${f5} ▄▄ ▄▄ ${f6} ▄▄ ▄▄ 25 | ${f1}▄█████▄ ▄█████▄ ${f2}▄█████▄ ▄█████▄ ${f3}▄█████▄ ▄█████▄ ${f4}▄█████▄ ▄█████▄ ${f5}▄█████▄ ▄█████▄ ${f6}▄█████▄ ▄█████▄ 26 | ${f1}███████▄▄███████ ${f2}███████▄▄███████ ${f3}███████▄▄███████ ${f4}███████▄▄███████ ${f5}███████▄▄███████ ${f6}███████▄▄███████ 27 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 28 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 29 | ${f1}████████████████ ${f2}████████████████ ${f3}████████████████ ${f4}████████████████ ${f5}████████████████ ${f6}████████████████ 30 | ${f1} ████████████ ${f2} ████████████ ${f3} ████████████ ${f4} ████████████ ${f5} ████████████ ${f6} ████████████ 31 | ${f1} ████████ ${f2} ████████ ${f3} ████████ ${f4} ████████ ${f5} ████████ ${f6} ████████ 32 | ${f1} ████ ${f2} ████ ${f3} ████ ${f4} ████ ${f5} ████ ${f6} ████ $rst 33 | 34 | You're filled with DETERMINATION. 35 | 36 | EOF 37 | -------------------------------------------------------------------------------- /c-digdug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${boldon}${whitef} ▄▄▄${reset} 36 | ${boldon}${whitef} ▄█████▄▄ ${reset} 37 | ${boldon}${whitef}███${cyanb}▀▀▀▀${blackb}▀${cyanb}▀${blackb}▀${cyanb}▀${reset} 38 | ${boldon}${whitef}███${cyanb}▄ ${boldoff}${blackf}▀ ▀${reset}${cyanf}▀${reset} 39 | ${boldon}${whitef} ▄${cyanb} ${reset}${boldon}${whitef}█████▄ ${boldoff}${redf}█▄${reset} 40 | ${boldoff}${redf}▀▀${reset}${boldon}${redb}${whitef}▄${cyanb}▄ ${redb}▄▄▄${reset}${boldoff}${redf}▀██▀${reset} 41 | ${boldon}${whitef} ██▀▀▀██▀ ${boldoff}${redf}▀${reset} 42 | ${boldon}${whitef} ▀▀▀▀ ▀▀▀▀${reset} 43 | 44 | EOF 45 | -------------------------------------------------------------------------------- /c-dna: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ANSI color scheme script by pfh 4 | # 5 | # Initializing mod by lolilolicon from Archlinux 6 | # 7 | 8 | f=3 b=4 9 | for j in f b; do 10 | for i in {0..7}; do 11 | printf -v $j$i %b "\e[${!j}${i}m" 12 | done 13 | done 14 | bld=$'\e[1m' 15 | rst=$'\e[0m' 16 | inv=$'\e[7m' 17 | 18 | cat << EOF 19 | 20 | ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} 21 | ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} 22 | ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} 23 | ${f1} █${rst} ${f2} █${rst} ${f3} █${rst} ${f4} █${rst} ${f5} █${rst} ${f6} █${rst} 24 | ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █_${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} 25 | ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} 26 | ${f1}${bld} █-----${rst}${f1}█${rst} ${f2}${bld} █-----${rst}${f2}█${rst} ${f3}${bld} █-----${rst}${f3}█${rst} ${f4}${bld} █-----${rst}${f4}█${rst} ${f5}${bld} █-----${rst}${f5}█${rst} ${f6}${bld} █-----${rst}${f6}█${rst} 27 | ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} 28 | ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █-${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} 29 | ${f1}${bld} █${rst} ${f2}${bld} █${rst} ${f3}${bld}█${rst} ${f4}${bld} █${rst} ${f5}${bld} █${rst} ${f6}${bld} █${rst} 30 | ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} 31 | ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} 32 | ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} 33 | ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} 34 | ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} 35 | ${f1} █${rst} ${f2}█${rst} ${f3} █${rst} ${f4} █${rst} ${f5} █${rst} ${f6} █${rst} 36 | ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █_${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} 37 | ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} 38 | ${f1}${bld} █-----${rst}${f1}█${rst} ${f2}${bld} █-----${rst}${f2}█${rst} ${f3}${bld} █-----${rst}${f3}█${rst} ${f4}${bld} █-----${rst}${f4}█${rst} ${f5}${bld} █-----${rst}${f5}█${rst} ${f6}${bld} █-----${rst}${f6}█${rst} 39 | ${f1}${bld} █---${rst}${f1}█${rst} ${f2}${bld} █---${rst}${f2}█${rst} ${f3}${bld} █---${rst}${f3}█${rst} ${f4}${bld} █---${rst}${f4}█${rst} ${f5}${bld} █---${rst}${f5}█${rst} ${f6}${bld} █---${rst}${f6}█${rst} 40 | ${f1}${bld} █-${rst}${f1}█${rst} ${f2}${bld} █-${rst}${f2}█${rst} ${f3}${bld} █-${rst}${f3}█${rst} ${f4}${bld} █-${rst}${f4}█${rst} ${f5}${bld} █-${rst}${f5}█${rst} ${f6}${bld} █-${rst}${f6}█${rst} 41 | ${f1}${bld} █${rst} ${f2}${bld} █${rst} ${f3}${bld} █${rst} ${f4}${bld} █${rst} ${f5}${bld} █${rst} ${f6}${bld} █${rst} 42 | ${f1} █-${bld}█${rst} ${f2} █-${bld}█${rst} ${f3} █-${bld}█${rst} ${f4} █-${bld}█${rst} ${f5} █-${bld}█${rst} ${f6} █-${bld}█${rst} 43 | ${f1} █---${bld}█${rst} ${f2} █---${bld}█${rst} ${f3} █---${bld}█${rst} ${f4} █---${bld}█${rst} ${f5} █---${bld}█${rst} ${f6} █---${bld}█${rst} 44 | ${f1} █-----${bld}█ ${rst}${f2} █-----${bld}█${rst} ${f3} █-----${bld}█${rst} ${f4} █-----${bld}█${rst} ${f5} █-----${bld}█${rst} ${f6} █-----${bld}█${rst} 45 | 46 | EOF 47 | -------------------------------------------------------------------------------- /c-double: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${blackf}████${reset}${boldon}${blackf}████${reset} ${redf}████${reset}${boldon}${redf}████${reset} ${greenf}████${reset}${boldon}${greenf}████${reset} ${yellowf}████${reset}${boldon}${yellowf}████${reset} ${bluef}████${reset}${boldon}${bluef}████${reset} ${purplef}████${reset}${boldon}${purplef}████${reset} ${cyanf}████${reset}${boldon}${cyanf}████${reset} ${whitef}████${reset}${boldon}${whitef}████${reset} 36 | ${blackf}████${reset}${boldon}${blackf}████${reset} ${redf}████${reset}${boldon}${redf}████${reset} ${greenf}████${reset}${boldon}${greenf}████${reset} ${yellowf}████${reset}${boldon}${yellowf}████${reset} ${bluef}████${reset}${boldon}${bluef}████${reset} ${purplef}████${reset}${boldon}${purplef}████${reset} ${cyanf}████${reset}${boldon}${cyanf}████${reset} ${whitef}████${reset}${boldon}${whitef}████${reset} 37 | ${blackf}████${reset}${boldon}${blackf}████${reset} ${redf}████${reset}${boldon}${redf}████${reset} ${greenf}████${reset}${boldon}${greenf}████${reset} ${yellowf}████${reset}${boldon}${yellowf}████${reset} ${bluef}████${reset}${boldon}${bluef}████${reset} ${purplef}████${reset}${boldon}${purplef}████${reset} ${cyanf}████${reset}${boldon}${cyanf}████${reset} ${whitef}████${reset}${boldon}${whitef}████${reset} 38 | 39 | EOF 40 | -------------------------------------------------------------------------------- /c-faces: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${white}╔══════════════════════════════════════════════════════════════════╗ 36 | ${white}║ ${redf} ▄█ █▄${reset} ${greenf} ▄█ █▄${reset} ${yellowf} ▄█ █▄${reset} ${bluef} ▄█ █▄${reset} ${purplef} ▄█ █▄${reset} ${cyanf} ▄█ █▄${reset} ${white}║ 37 | ${white}║ ${boldon}${redf}▄█◄► ◄►█▄${reset} ${boldon}${greenf}▄█◄► ◄►█▄${reset} ${boldon}${yellowf}▄█◄► ◄►█▄${reset} ${boldon}${bluef}▄█◄► ◄►█▄${reset} ${boldon}${purplef}▄█◄► ◄►█▄${reset} ${boldon}${cyanf}▄█◄► ◄►█▄${reset} ${white}║ 38 | ${white}║ ${boldon}${redf}▀█  █▀${reset} ${boldon}${greenf}▀█  █▀${reset} ${boldon}${yellowf}▀█  █▀${reset} ${boldon}${bluef}▀█  █▀${reset} ${boldon}${purplef}▀█  █▀${reset} ${boldon}${cyanf}▀█  █▀${reset} ${white}║ 39 | ${white}║ ${redf} ▀█ █▀${reset} ${greenf} ▀█ █▀${reset} ${yellowf} ▀█ █▀${reset} ${bluef} ▀█ █▀${reset} ${purplef} ▀█ █▀${reset} ${cyanf} ▀█ █▀${reset} ${white}║ 40 | ${white}╚══════════════════════════════════════════════════════════════════╝ 41 | 42 | EOF 43 | -------------------------------------------------------------------------------- /c-hash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[0;30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | echo 34 | echo "${reset}${redf} ██ ██ ${reset}${greenf} ██ ██ ${reset}${yellowf} ██ ██ ${reset}${bluef} ██ ██ ${reset}${purplef} ██ ██ ${reset}${cyanf} ██ ██ ${reset}" 35 | echo "${reset}${redf}██████████ ${reset}${greenf} ██████████ ${reset}${yellowf} ██████████ ${reset}${bluef} ██████████ ${reset}${purplef} ██████████ ${reset} ${cyanf}██████████ ${reset}" 36 | echo "${reset}${redf} ██${boldon}██${boldoff}██ ${reset}${greenf} ██${boldon}██${boldoff}██ ${reset}${yellowf} ██${boldon}██${boldoff}██ ${reset}${bluef} ██${boldon}██${boldoff}██ ${reset}${purplef} ██${boldon}██${boldoff}██ ${reset}${cyanf} ██${boldon}██${boldoff}██ ${reset}" 37 | echo "${reset}${redf}██████████ ${reset}${greenf} ██████████ ${reset}${yellowf} ██████████ ${bluef} ██████████ ${purplef} ██████████ ${reset}${cyanf} ██████████${reset}" 38 | echo "${reset}${redf} ██ ██ ${reset}${greenf} ██ ██ ${reset}${yellowf} ██ ██ ${reset}${bluef} ██ ██ ${reset}${purplef} ██ ██ ${reset}${cyanf} ██ ██ ${reset}" 39 | echo "${reset}" 40 | -------------------------------------------------------------------------------- /c-hashbang: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${reset}${redf}▄█▄█▄ ${reset}${boldon}${redf}█ ${reset}${greenf}▄█▄█▄ ${reset}${boldon}${greenf}█ ${reset}${yellowf}▄█▄█▄ ${reset}${boldon}${yellowf}█ ${reset}${bluef}▄█▄█▄ ${reset}${boldon}${bluef}█ ${reset}${purplef}▄█▄█▄ ${reset}${boldon}${purplef}█ ${reset}${cyanf}▄█▄█▄ ${reset}${boldon}${cyanf}█${reset} 36 | ${reset}${redf}▄█▄█▄ ${reset}${boldon}${redf}▀ ${reset}${greenf}▄█▄█▄ ${reset}${boldon}${greenf}▀ ${reset}${yellowf}▄█▄█▄ ${reset}${boldon}${yellowf}▀ ${reset}${bluef}▄█▄█▄ ${reset}${boldon}${bluef}▀ ${reset}${purplef}▄█▄█▄ ${reset}${boldon}${purplef}▀ ${reset}${cyanf}▄█▄█▄ ${reset}${boldon}${cyanf}▀${reset} 37 | ${reset}${redf} ▀ ▀ ${reset}${boldon}${redf}▀ ${reset}${greenf} ▀ ▀ ${reset}${boldon}${greenf}▀ ${reset}${yellowf} ▀ ▀ ${reset}${boldon}${yellowf}▀ ${reset}${bluef} ▀ ▀ ${reset}${boldon}${bluef}▀ ${reset}${purplef} ▀ ▀ ${reset}${boldon}${purplef}▀ ${reset}${cyanf} ▀ ▀ ${reset}${boldon}${cyanf}▀${reset} 38 | 39 | EOF 40 | -------------------------------------------------------------------------------- /c-hypnotoad: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # script by karabaja4 4 | # mail: karabaja4@archlinux.us 5 | 6 | my $blackFG_yellowBG = "\e[30;43m"; 7 | my $blackFG_redBG = "\e[30;41m"; 8 | my $blackFG_purpleBG = "\e[30;45m"; 9 | 10 | my $yellowFG_blackBG = "\e[1;33;40m"; 11 | my $yellowFG_redBG = "\e[1;33;41m"; 12 | 13 | my $redFG_yellowBG = "\e[31;43m"; 14 | 15 | my $purpleFG_yellowBG = "\e[35;43m"; 16 | my $purpleFG_blueBG = "\e[1;35;44m"; 17 | 18 | my $end = "\e[0m"; 19 | 20 | print " 21 | ${blackFG_yellowBG},'${blackFG_redBG}`${blackFG_yellowBG}`.._${end} ${blackFG_yellowBG},'${blackFG_redBG}`${end}${blackFG_yellowBG}`.${end} 22 | ${blackFG_yellowBG}:${blackFG_redBG},${yellowFG_blackBG}--.${end}${blackFG_redBG}_${blackFG_yellowBG}:)\\,:${blackFG_redBG},${yellowFG_blackBG}._,${end}${yellowFG_redBG}.${end}${blackFG_yellowBG}:${end} 23 | ${blackFG_yellowBG}:`-${yellowFG_blackBG}-${end}${blackFG_yellowBG},${blackFG_yellowBG}''${end}${redFG_yellowBG}@@\@${end}${blackFG_yellowBG}:`.${yellowFG_redBG}.${end}${blackFG_yellowBG}.';\\${end} All Glory to 24 | ${blackFG_yellowBG}`,'${end}${redFG_yellowBG}@@@@@@\@${end}${blackFG_yellowBG}`---'${redFG_yellowBG}@\@${end}${blackFG_yellowBG}`.${end} the HYPNOTOAD! 25 | ${blackFG_yellowBG}/${redFG_yellowBG}@@@@@@@@@@@@@@@@\@${end}${blackFG_yellowBG}:${end} 26 | ${blackFG_yellowBG}/${redFG_yellowBG}@@@@@@@@@@@@@@@@@@\@${end}${blackFG_yellowBG}\\${end} 27 | ${blackFG_yellowBG},'${redFG_yellowBG}@@@@@@@@@@@@@@@@@@@@\@${end}${purpleFG_yellowBG}:\\${end}${blackFG_yellowBG}.___,-.${end} 28 | ${blackFG_yellowBG}`...,---'``````-..._${redFG_yellowBG}@@@\@${end}${blackFG_purpleBG}|:${end}${redFG_yellowBG}@@@@@@\@${end}${blackFG_yellowBG}\\${end} 29 | ${blackFG_yellowBG}( )${end}${redFG_yellowBG}@@\@${end}${blackFG_purpleBG};:${end}${redFG_yellowBG}@@@\@)@@\@${end}${blackFG_yellowBG}\\${end} ${blackFG_yellowBG}_,-.${end} 30 | ${blackFG_yellowBG}`. (${end}${redFG_yellowBG}@@\@${end}${blackFG_purpleBG}//${end}${redFG_yellowBG}@@@@@@@@@\@${end}${blackFG_yellowBG}`'${end}${redFG_yellowBG}@@@\@${end}${blackFG_yellowBG}\\${end} 31 | ${blackFG_yellowBG}: `.${end}${blackFG_purpleBG}//${end}${redFG_yellowBG}@@)@@@@@@)@@@@@,\@${end}${blackFG_yellowBG};${end} 32 | ${blackFG_purpleBG}|`${purpleFG_yellowBG}.${blackFG_yellowBG} ${end}${purpleFG_yellowBG}_${end}${purpleFG_yellowBG},${blackFG_purpleBG}'/${end}${redFG_yellowBG}@@@@@@@)@@@@)@,'\@${end}${blackFG_yellowBG},'${end} 33 | ${blackFG_yellowBG}:${end}${blackFG_purpleBG}`.`${end}${purpleFG_yellowBG}-..____..=${end}${blackFG_purpleBG}:.-${end}${blackFG_yellowBG}':${end}${redFG_yellowBG}@@@@@.@@@@\@_,@@,'${end} 34 | ${redFG_yellowBG},'${end}${blackFG_yellowBG}\\ ${end}${blackFG_purpleBG}``--....${end}${purpleFG_blueBG}-)='${end}${blackFG_yellowBG} `.${end}${redFG_yellowBG}_,@\@${end}${blackFG_yellowBG}\\${end} ${redFG_yellowBG})@@\@'``._${end} 35 | ${redFG_yellowBG}/\@${end}${redFG_yellowBG}_${end}${redFG_yellowBG}\@${end}${blackFG_yellowBG}`.${end}${blackFG_yellowBG} ${end}${blackFG_redBG}(@)${end}${blackFG_yellowBG} /${end}${redFG_yellowBG}@@@@\@${end}${blackFG_yellowBG})${end} ${redFG_yellowBG}; / \\ \\`-.'${end} 36 | ${redFG_yellowBG}(@@\@${end}${redFG_yellowBG}`-:${end}${blackFG_yellowBG}`. ${end}${blackFG_yellowBG}`' ___..'${end}${redFG_yellowBG}@\@${end}${blackFG_yellowBG}_,-'${end} ${redFG_yellowBG}|/${end} ${redFG_yellowBG}`.)${end} 37 | ${redFG_yellowBG}`-. `.`.${end}${blackFG_yellowBG}``-----``--${end}${redFG_yellowBG},@\@.'${end} 38 | ${redFG_yellowBG}|/`.\\`'${end} ${redFG_yellowBG},',');${end} 39 | ${redFG_yellowBG}`${end} ${redFG_yellowBG}(/${end} ${redFG_yellowBG}(/${end} 40 | 41 | "; 42 | -------------------------------------------------------------------------------- /c-invaders: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${boldon}${redf}▀▄ ▄▀ ${reset} ${boldon}${greenf}▄▄▄████▄▄▄ ${reset} ${boldon}${yellowf} ▄██▄ ${reset} ${boldon}${bluef}▀▄ ▄▀ ${reset} ${boldon}${purplef}▄▄▄████▄▄▄ ${reset} ${boldon}${cyanf} ▄██▄ ${reset} 36 | ${boldon}${redf}▄█▀███▀█▄ ${reset} ${boldon}${greenf}███▀▀██▀▀███${reset} ${boldon}${yellowf}▄█▀██▀█▄${reset} ${boldon}${bluef}▄█▀███▀█▄ ${reset} ${boldon}${purplef}███▀▀██▀▀███${reset} ${boldon}${cyanf}▄█▀██▀█▄${reset} 37 | ${boldon}${redf}█▀███████▀█${reset} ${boldon}${greenf}▀▀▀██▀▀██▀▀▀${reset} ${boldon}${yellowf}▀▀█▀▀█▀▀${reset} ${boldon}${bluef}█▀███████▀█${reset} ${boldon}${purplef}▀▀▀██▀▀██▀▀▀${reset} ${boldon}${cyanf}▀▀█▀▀█▀▀${reset} 38 | ${boldon}${redf}▀ ▀▄▄ ▄▄▀ ▀${reset} ${boldon}${greenf}▄▄▀▀ ▀▀ ▀▀▄▄${reset} ${boldon}${yellowf}▄▀▄▀▀▄▀▄${reset} ${boldon}${bluef}▀ ▀▄▄ ▄▄▀ ▀${reset} ${boldon}${purplef}▄▄▀▀ ▀▀ ▀▀▄▄${reset} ${boldon}${cyanf}▄▀▄▀▀▄▀▄${reset} 39 | 40 | ${redf}▀▄ ▄▀ ${reset} ${greenf}▄▄▄████▄▄▄ ${reset} ${yellowf} ▄██▄ ${reset} ${bluef}▀▄ ▄▀ ${reset} ${purplef}▄▄▄████▄▄▄ ${reset} ${cyanf} ▄██▄ ${reset} 41 | ${redf}▄█▀███▀█▄ ${reset} ${greenf}███▀▀██▀▀███${reset} ${yellowf}▄█▀██▀█▄${reset} ${bluef}▄█▀███▀█▄ ${reset} ${purplef}███▀▀██▀▀███${reset} ${cyanf}▄█▀██▀█▄${reset} 42 | ${redf}█▀███████▀█${reset} ${greenf}▀▀▀██▀▀██▀▀▀${reset} ${yellowf}▀▀█▀▀█▀▀${reset} ${bluef}█▀███████▀█${reset} ${purplef}▀▀▀██▀▀██▀▀▀${reset} ${cyanf}▀▀█▀▀█▀▀${reset} 43 | ${redf}▀ ▀▄▄ ▄▄▀ ▀${reset} ${greenf}▄▄▀▀ ▀▀ ▀▀▄▄${reset} ${yellowf}▄▀▄▀▀▄▀▄${reset} ${bluef}▀ ▀▄▄ ▄▄▀ ▀${reset} ${purplef}▄▄▀▀ ▀▀ ▀▀▄▄${reset} ${cyanf}▄▀▄▀▀▄▀▄${reset} 44 | 45 | 46 | ${whitef}▌${reset} 47 | 48 | ${whitef}▌${reset} 49 | ${whitef}${reset} 50 | ${whitef}▄█▄${reset} 51 | ${whitef}▄█████████▄${reset} 52 | ${whitef}▀▀▀▀▀▀▀▀▀▀▀${reset} 53 | 54 | EOF 55 | -------------------------------------------------------------------------------- /c-lines: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${redf}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ ${greenf}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ ${yellowf}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ 36 | ${boldon}${redf}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝ ${greenf}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝ ${yellowf}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝${reset} 37 | ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ 38 | ${bluef}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ ${purplef}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ ${cyanf}╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ 39 | ${boldon}${bluef}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝ ${purplef}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝ ${cyanf}╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝${reset} 40 | 41 | EOF 42 | -------------------------------------------------------------------------------- /c-pacman: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${yellowf} ▄███████▄${reset} ${redf} ▄██████▄${reset} ${greenf} ▄██████▄${reset} ${bluef} ▄██████▄${reset} ${purplef} ▄██████▄${reset} ${cyanf} ▄██████▄${reset} 36 | ${yellowf}▄█████████▀▀${reset} ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄${reset} ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄${reset} ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄${reset} ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄${reset} ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset} 37 | ${yellowf}███████▀${reset} ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███${reset} ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███${reset} ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███${reset} ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███${reset} ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset} 38 | ${yellowf}███████▄${reset} ${redf}████████████${reset} ${greenf}████████████${reset} ${bluef}████████████${reset} ${purplef}████████████${reset} ${cyanf}████████████${reset} 39 | ${yellowf}▀█████████▄▄${reset} ${redf}██▀██▀▀██▀██${reset} ${greenf}██▀██▀▀██▀██${reset} ${bluef}██▀██▀▀██▀██${reset} ${purplef}██▀██▀▀██▀██${reset} ${cyanf}██▀██▀▀██▀██${reset} 40 | ${yellowf} ▀███████▀${reset} ${redf}▀ ▀ ▀ ▀${reset} ${greenf}▀ ▀ ▀ ▀${reset} ${bluef}▀ ▀ ▀ ▀${reset} ${purplef}▀ ▀ ▀ ▀${reset} ${cyanf}▀ ▀ ▀ ▀${reset} 41 | 42 | ${boldon}${yellowf} ▄███████▄ ${redf} ▄██████▄ ${greenf} ▄██████▄ ${bluef} ▄██████▄ ${purplef} ▄██████▄ ${cyanf} ▄██████▄${reset} 43 | ${boldon}${yellowf}▄█████████▀▀ ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄ ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄ ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄ ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄ ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset} 44 | ${boldon}${yellowf}███████▀ ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███ ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███ ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███ ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███ ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset} 45 | ${boldon}${yellowf}███████▄ ${redf}████████████ ${greenf}████████████ ${bluef}████████████ ${purplef}████████████ ${cyanf}████████████${reset} 46 | ${boldon}${yellowf}▀█████████▄▄ ${redf}██▀██▀▀██▀██ ${greenf}██▀██▀▀██▀██ ${bluef}██▀██▀▀██▀██ ${purplef}██▀██▀▀██▀██ ${cyanf}██▀██▀▀██▀██${reset} 47 | ${boldon}${yellowf} ▀███████▀ ${redf}▀ ▀ ▀ ▀ ${greenf}▀ ▀ ▀ ▀ ${bluef}▀ ▀ ▀ ▀ ${purplef}▀ ▀ ▀ ▀ ${cyanf}▀ ▀ ▀ ▀${reset} 48 | 49 | EOF 50 | -------------------------------------------------------------------------------- /c-poke: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # https://github.com/roberoonska/dotfiles/blob/master/colorscripts/poke 3 | 4 | initializeANSI() 5 | { 6 | esc="" 7 | 8 | Bf="${esc}[30m"; rf="${esc}[31m"; gf="${esc}[32m" 9 | yf="${esc}[33m" bf="${esc}[34m"; pf="${esc}[35m" 10 | cf="${esc}[36m"; wf="${esc}[37m" 11 | 12 | Bb="${esc}[40m"; rb="${esc}[41m"; gb="${esc}[42m" 13 | yb="${esc}[43m" bb="${esc}[44m"; pb="${esc}[45m" 14 | cb="${esc}[46m"; wb="${esc}[47m" 15 | 16 | ON="${esc}[1m"; OFF="${esc}[22m" 17 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 18 | ulon="${esc}[4m"; uloff="${esc}[24m" 19 | invon="${esc}[7m"; invoff="${esc}[27m" 20 | 21 | reset="${esc}[0m" 22 | } 23 | 24 | initializeANSI 25 | 26 | cat << EOF 27 | 28 | ${Bf}██████ ${Bf}████████ ██ ${Bf}████████ ████████ 29 | ${Bf}██${gf}${ON}██████${OFF}${Bf}██ ${Bf}██${rf}${ON}██████${OFF}██${Bf}██ ██${rf}██${Bf}██ ${Bf}██${bf}${ON}██████${OFF}██${Bf}████ ██${bf}${ON}████████${OFF}${Bf}██ 30 | ${Bf}██████${gf}${ON}██████${OFF}${Bf}██ ${Bf}██${rf}${ON}██████████${OFF}██${Bf}██ ██${rf}████${Bf}██ ${Bf}██${bf}${ON}████████████${OFF}██${Bf}████ ████${bf}${ON}██████${OFF}████${Bf}██ 31 | ${Bf}████${gf}${ON}████${OFF}██${ON}████${OFF}██${ON}██${OFF}${Bf}████ ${Bf}██${rf}${ON}████████████${OFF}${Bf}██ ██${rf}████${Bf}██ ${Bf}██${bf}${ON}██████████████${OFF}${Bf}██${pf}██${Bf}████ ██${bf}${ON}████${OFF}██${Bf}██${bf}████${Bf}██ 32 | ${Bf}██ ██${gf}${ON}██████${OFF}████${ON}████${OFF}██${ON}██████${OFF}${Bf}██ ${Bf}██${rf}${ON}██████████████${OFF}██${Bf}██ ██${rf}████${yf}██${rf}██${Bf}██ ${Bf}██${bf}${ON}████████████████${OFF}██${pf}██${ON}██${OFF}██${Bf}██${bf}██${ON}██${OFF}██${Bf}██${bf}██████${Bf}██ 33 | ${Bf}██${cf}${ON}██${OFF}${Bf}██████${gf}${ON}████${OFF}██${ON}██${OFF}██${ON}██████${OFF}██${ON}██████${OFF}${Bf}██ ${Bf}██${rf}${ON}████████${wf}██${OFF}${Bf}██${rf}${ON}████${OFF}██${Bf}██ ██${rf}██${yf}██${ON}██${OFF}${rf}██${Bf}██ ${Bf}██${bf}${ON}████████${wf}${ON}██${OFF}${Bf}██${bf}${ON}████${OFF}██${wf}${ON}██${OFF}${pf}${ON}████${OFF}██${Bf}██${bf}████${Bf}██${bf}████${Bf}██ 34 | ${Bf}██${cf}${ON}██████${OFF}${Bf}████${gf}██${ON}██${OFF}██${ON}██████████${OFF}██${ON}████${OFF}${Bf}██ ${Bf}██${rf}${ON}████████${OFF}${Bf}████${rf}${ON}██${OFF}██████${Bf}██ ██${rf}██${yf}${ON}████${OFF}${rf}██${Bf}██ ${Bf}██${bf}██${ON}██████${OFF}${Bf}████${bf}${ON}██${OFF}████${wf}${ON}██${pf}██████${OFF}${Bf}██${bf}██${Bf}████████ 35 | ${Bf}██${cf}${ON}████████${OFF}██${Bf}██${gf}${ON}██${OFF}██${ON}██████████${OFF}██${ON}████${OFF}${Bf}██ ${Bf}██${rf}${ON}████████${OFF}${Bf}████${rf}${ON}██${OFF}██████${Bf}██ ██${yf}${ON}██${OFF}${Bf}████ ${Bf}██${bf}████${ON}██${OFF}${Bf}████${bf}██████${Bf}██${wf}${ON}████${pf}██${OFF}██${Bf}████ 36 | ${Bf}██${cf}${ON}████${OFF}██${ON}██${OFF}████${ON}██${OFF}${Bf}██████${gf}${ON}████████${OFF}██${ON}██${OFF}${Bf}██ ${Bf}██${rf}██${ON}████████${OFF}██████████${Bf}██ ██${rf}${ON}██${OFF}${Bf}██ ${Bf}████${bf}████████${Bf}████${bf}${ON}████${wf}██${OFF}${pf}████${Bf}██ 37 | ${Bf}████${cf}██${ON}████████████████${OFF}${Bf}██${gf}██████${Bf}████████ ${Bf}████${rf}██████████████████${Bf}██ ██${rf}${ON}████${OFF}${Bf}██ ${Bf}██${bf}${ON}██${OFF}${Bf}████████${bf}${ON}██████${OFF}██${wf}${ON}██${OFF}${pf}████${Bf}██ 38 | ${Bf}██${cf}████${ON}██████${OFF}██${ON}██████${OFF}${Bf}██${cf}██${Bf}██████${cf}██████${Bf}██ ${Bf}██████${rf}████${Bf}██${rf}██████${Bf}████${rf}██${ON}██${OFF}${Bf}██ ${Bf}████${yf}${ON}████${OFF}${Bf}██${bf}${ON}████${OFF}██${Bf}██${wf}${ON}██${OFF}${pf}████${Bf}██ 39 | ${Bf}██${cf}${ON}████████${OFF}██${ON}██${OFF}${Bf}████${cf}${ON}██${OFF}██████████${Bf}██${cf}██${wf}${ON}██${OFF}${Bf}██ ${Bf}██${yf}${ON}████${OFF}${Bf}██${rf}${ON}████${OFF}${rf}██████${Bf}██${rf}██${ON}██${OFF}${Bf}██ ${Bf}██${yf}████${Bf}████████${wf}${ON}██${OFF}${pf}████${Bf}██ 40 | ${Bf}██${cf}██${ON}████████${OFF}${Bf}██${rf}${ON}██${wf}████${OFF}${cf}████${Bf}██${cf}████${Bf}██████ ${Bf}██${yf}${ON}██████${OFF}${Bf}████${rf}██████${Bf}██${rf}██${Bf}██ ${Bf}██${bf}██${Bf}██${pf}██${yf}██████${pf}██${Bf}██${wf}${ON}██${OFF}${Bf}██ 41 | ${Bf}██${cf}██${ON}██████${OFF}${Bf}██${rf}${ON}██${wf}██${cf}██${OFF}██${Bf}██${cf}████${Bf}██ ${Bf}██${wf}${ON}██${OFF}${Bf}██${yf}${ON}██████${OFF}${rf}████████${Bf}████ ${Bf}████████${pf}████${bf}██${Bf}██${wf}${ON}██${OFF}${Bf}██ 42 | ${Bf}████${cf}████████████${Bf}██${cf}██████${Bf}██ ${Bf}██████${yf}████${rf}██████${Bf}████ ${Bf}██████${bf}██${Bf}████ 43 | ${Bf}██████████████${wf}${ON}██${OFF}${cf}██${wf}${ON}██${OFF}${Bf}██ ${Bf}██████${rf}██${Bf}████ ${Bf}██${bf}██████${Bf}██ 44 | ${Bf}██████ ${Bf}██${wf}${ON}██${OFF}${rf}██${wf}${ON}██${OFF}${Bf}██ ${Bf}██████ 45 | ${Bf}██████ 46 | ${reset} 47 | EOF 48 | -------------------------------------------------------------------------------- /c-rupees: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # https://github.com/roberoonska/dotfiles/tree/master/colorscripts 3 | 4 | initializeANSI() 5 | { 6 | esc="" 7 | 8 | Bf="${esc}[30m"; rf="${esc}[31m"; gf="${esc}[32m" 9 | yf="${esc}[33m" bf="${esc}[34m"; pf="${esc}[35m" 10 | cf="${esc}[36m"; wf="${esc}[37m" 11 | 12 | Bb="${esc}[40m"; rb="${esc}[41m"; gb="${esc}[42m" 13 | yb="${esc}[43m" bb="${esc}[44m"; pb="${esc}[45m" 14 | cb="${esc}[46m"; wb="${esc}[47m" 15 | 16 | ON="${esc}[1m"; OFF="${esc}[22m" 17 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 18 | ulon="${esc}[4m"; uloff="${esc}[24m" 19 | invon="${esc}[7m"; invoff="${esc}[27m" 20 | 21 | reset="${esc}[0m" 22 | } 23 | 24 | initializeANSI 25 | 26 | cat << EOF 27 | 28 | ${Bf}██ ${Bf}████ ${Bf}████ ${Bf}████ ${Bf}████ ${Bf}████ 29 | ${Bf}██${yf}██${Bf}██ ${Bf}██${gf}${ON}██${OFF}██${Bf}██ ${Bf}██${bf}${ON}██${OFF}██${Bf}██ ${Bf}██${rf}${ON}██${OFF}██${Bf}██ ${Bf}██${pf}${ON}██${OFF}██${Bf}██ ${Bf}██${cf}${ON}██${OFF}██${Bf}██ 30 | ${Bf}██${yf}██████${Bf}██ ${Bf}██${gf}${ON}████${OFF}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}████${Bf}██ 31 | ${Bf}██${yf}${ON}██${OFF}████${Bf}██ ${Bf}██${gf}${ON}██████${OFF}██████${Bf}██ ${Bf}██${bf}${ON}██████${OFF}██████${Bf}██ ${Bf}██${rf}${ON}██████${OFF}██████${Bf}██ ${Bf}██${pf}${ON}██████${OFF}██████${Bf}██ ${Bf}██${cf}${ON}██████${OFF}██████${Bf}██ 32 | ${Bf}██${yf}██${ON}████${OFF}████${Bf}██ ${Bf}██${gf}${ON}██${OFF}██${ON}██${OFF}██${Bf}██${gf}██${Bf}██${gf}██${Bf}██ ${Bf}██${bf}${ON}██${OFF}██${ON}██${OFF}██${Bf}██${bf}██${Bf}██${bf}██${Bf}██ ${Bf}██${rf}${ON}██${OFF}██${ON}██${OFF}██${Bf}██${rf}██${Bf}██${rf}██${Bf}██ ${Bf}██${pf}${ON}██${OFF}██${ON}██${OFF}██${Bf}██${pf}██${Bf}██${pf}██${Bf}██ ${Bf}██${cf}${ON}██${OFF}██${ON}██${OFF}██${Bf}██${cf}██${Bf}██${cf}██${Bf}██ 33 | ${Bf}██${yf}████${ON}██${OFF}████${Bf}██ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 34 | ${Bf}██${yf}██████${ON}████${OFF}████${Bf}██ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 35 | ${Bf}██${yf}████████${ON}██${OFF}████${Bf}██ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 36 | ${Bf}██████████████████████ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 37 | ${Bf}██${yf}██${Bf}██ ██${yf}██${Bf}██ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 38 | ${Bf}██${yf}██████${Bf}██ ██${yf}██████${Bf}██ ${Bf}██${gf}${ON}████${OFF}██████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}████${OFF}██████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}████${OFF}██████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}████${OFF}██████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}████${OFF}██████${Bf}██${cf}████${Bf}██ 39 | ${Bf}██${yf}██████${Bf}██ ██${yf}${ON}██${OFF}████${Bf}██ ${Bf}██${gf}${ON}██${OFF}██${ON}██${OFF}████${Bf}██${gf}████${Bf}██ ${Bf}██${bf}${ON}██${OFF}██${ON}██${OFF}████${Bf}██${bf}████${Bf}██ ${Bf}██${rf}${ON}██${OFF}██${ON}██${OFF}████${Bf}██${rf}████${Bf}██ ${Bf}██${pf}${ON}██${OFF}██${ON}██${OFF}████${Bf}██${pf}████${Bf}██ ${Bf}██${cf}${ON}██${OFF}██${ON}██${OFF}████${Bf}██${cf}████${Bf}██ 40 | ${Bf}██${yf}██████████${Bf}██ ██${yf}██${ON}████${OFF}████${Bf}██ ${Bf}██${gf}██████${ON}██${OFF}${Bf}██${gf}██${Bf}██${gf}██${Bf}██ ${Bf}██${bf}██████${ON}██${OFF}${Bf}██${bf}██${Bf}██${bf}██${Bf}██ ${Bf}██${rf}██████${ON}██${OFF}${Bf}██${rf}██${Bf}██${rf}██${Bf}██ ${Bf}██${pf}██████${ON}██${OFF}${Bf}██${pf}██${Bf}██${pf}██${Bf}██ ${Bf}██${cf}██████${ON}██${OFF}${Bf}██${cf}██${Bf}██${cf}██${Bf}██ 41 | ${Bf}██${yf}${ON}██${OFF}████████${Bf}██ ██${yf}████${ON}██${OFF}████${Bf}██ ${Bf}██${gf}████████████${Bf}██ ${Bf}██${bf}████████████${Bf}██ ${Bf}██${rf}████████████${Bf}██ ${Bf}██${pf}████████████${Bf}██ ${Bf}██${cf}████████████${Bf}██ 42 | ${Bf}██${yf}██${ON}████${OFF}████████${Bf}██ ██${yf}██████${ON}████${OFF}████${Bf}██ ${Bf}██${gf}████████${Bf}██ ${Bf}██${bf}████████${Bf}██ ${Bf}██${rf}████████${Bf}██ ${Bf}██${pf}████████${Bf}██ ${Bf}██${cf}████████${Bf}██ 43 | ${Bf}██${yf}████${ON}██${OFF}████████${Bf}██ ██${yf}████████${ON}██${OFF}████${Bf}██ ${Bf}██${gf}████${Bf}██ ${Bf}██${bf}████${Bf}██ ${Bf}██${rf}████${Bf}██ ${Bf}██${pf}████${Bf}██ ${Bf}██${cf}████${Bf}██ 44 | ${Bf}██████████████████████████████████████ ${Bf}████ ${Bf}████ ${Bf}████ ${Bf}████ ${Bf}████${reset} 45 | 46 | EOF 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /c-scheme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Original: http://frexx.de/xterm-256-notes/ [dead link 2013-11-21] 3 | # http://frexx.de/xterm-256-notes/data/colortable16.sh [dead link 2013-11-21] 4 | # Modified by Aaron Griffin 5 | # and further by Kazuo Teramoto 6 | FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ') 7 | BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT') 8 | 9 | echo 10 | echo " ┌──────────────────────────────────────────────────────────────────────────┐" 11 | for b in {0..8}; do 12 | ((b>0)) && bg=$((b+39)) 13 | 14 | echo -en "\033[0m ${BGNAMES[b]} │ " 15 | 16 | for f in {0..7}; do 17 | echo -en "\033[${bg}m\033[$((f+30))m ${FGNAMES[f]} " 18 | done 19 | 20 | echo -en "\033[0m │" 21 | echo -en "\033[0m\n\033[0m │ " 22 | 23 | for f in {0..7}; do 24 | echo -en "\033[${bg}m\033[1;$((f+30))m ${FGNAMES[f]} " 25 | done 26 | 27 | echo -en "\033[0m │" 28 | echo -e "\033[0m" 29 | 30 | ((b<8)) && 31 | echo " ├──────────────────────────────────────────────────────────────────────────┤" 32 | done 33 | echo " └──────────────────────────────────────────────────────────────────────────┘" 34 | echo 35 | -------------------------------------------------------------------------------- /c-skulls: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ANSI color scheme script by pfh 4 | # 5 | # Initializing mod by lolilolicon from Archlinux 6 | # https://github.com/roberoonska/dotfiles/tree/master/colorscripts 7 | # 8 | 9 | f=3 b=4 10 | for j in f b; do 11 | for i in {0..7}; do 12 | printf -v $j$i %b "\e[${!j}${i}m" 13 | done 14 | done 15 | bld=$'\e[1m' 16 | rst=$'\e[0m' 17 | inv=$'\e[7m' 18 | w=$'\e[37m' 19 | cat << EOF 20 | 21 | ${f1} ▄▄▄▄▄▄▄ ${f2} ▄▄▄▄▄▄▄ ${f3} ▄▄▄▄▄▄▄ ${f4} ▄▄▄▄▄▄▄ ${f5} ▄▄▄▄▄▄▄ ${f6} ▄▄▄▄▄▄▄ 22 | ${f1}▄█▀ ▀█▄ ${f2}▄█▀ ▀█▄ ${f3}▄█▀ ▀█▄ ${f4}▄█▀ ▀█▄ ${f5}▄█▀ ▀█▄ ${f6}▄█▀ ▀█▄ 23 | ${f1}█ █ ${f2}█ █ ${f3}█ █ ${f4}█ █ ${f5}█ █ ${f6}█ █ 24 | ${f1}███ ▄ ██ █ ${f2}███ ▄ ██ █ ${f3}███ ▄ ██ █ ${f4}███ ▄ ██ █ ${f5}███ ▄ ██ █ ${f6}███ ▄ ██ █ 25 | ${f1}█▄ ▄▄██ ${f2}█▄ ▄▄██ ${f3}█▄ ▄▄██ ${f4}█▄ ▄▄██ ${f5}█▄ ▄▄██ ${f6}█▄ ▄▄██ 26 | ${f1} █▄█▄█▄██▀ ${f2} █▄█▄█▄██▀ ${f3} █▄█▄█▄██▀ ${f4} █▄█▄█▄██▀ ${f5} █▄█▄█▄██▀ ${f6} █▄█▄█▄██▀ $bld 27 | ${f1} ▄▄▄▄▄▄▄ ${f2} ▄▄▄▄▄▄▄ ${f3} ▄▄▄▄▄▄▄ ${f4} ▄▄▄▄▄▄▄ ${f5} ▄▄▄▄▄▄▄ ${f6} ▄▄▄▄▄▄▄ 28 | ${f1}▄█▀ ▀█▄ ${f2}▄█▀ ▀█▄ ${f3}▄█▀ ▀█▄ ${f4}▄█▀ ▀█▄ ${f5}▄█▀ ▀█▄ ${f6}▄█▀ ▀█▄ 29 | ${f1}█ █ ${f2}█ █ ${f3}█ █ ${f4}█ █ ${f5}█ █ ${f6}█ █ 30 | ${f1}███ ▄ ██ █ ${f2}███ ▄ ██ █ ${f3}███ ▄ ██ █ ${f4}███ ▄ ██ █ ${f5}███ ▄ ██ █ ${f6}███ ▄ ██ █ 31 | ${f1}█▄ ▄▄██ ${f2}█▄ ▄▄██ ${f3}█▄ ▄▄██ ${f4}█▄ ▄▄██ ${f5}█▄ ▄▄██ ${f6}█▄ ▄▄██ 32 | ${f1} █▄█▄█▄██▀ ${f2} █▄█▄█▄██▀ ${f3} █▄█▄█▄██▀ ${f4} █▄█▄█▄██▀ ${f5} █▄█▄█▄██▀ ${f6} █▄█▄█▄██▀ 33 | $rst 34 | EOF 35 | -------------------------------------------------------------------------------- /c-skulls2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://github.com/roberoonska/dotfiles/tree/master/colorscripts 3 | 4 | f=3 b=4 5 | for j in f b; do 6 | for i in {0..7}; do 7 | printf -v $j$i %b "\e[${!j}${i}m" 8 | done 9 | done 10 | bld=$'\e[1m' 11 | rst=$'\e[0m' 12 | inv=$'\e[7m' 13 | cat << EOF 14 | 15 | ${f1}▄█ █▄ ${f2}▄█ █▄ ${f3}▄█ █▄ ${f4}▄█ █▄ ${f5}▄█ █▄ ${f6}▄█ █▄ 16 | ${f1} ▄█████▄ ${f2} ▄█████▄ ${f3} ▄█████▄ ${f4} ▄█████▄ ${f5} ▄█████▄ ${f6} ▄█████▄ 17 | ${f1} █▄▄█▄▄█ ${f2} █▄▄█▄▄█ ${f3} █▄▄█▄▄█ ${f4} █▄▄█▄▄█ ${f5} █▄▄█▄▄█ ${f6} █▄▄█▄▄█ 18 | ${f1}▄▄ █▀█▀█ ▄▄ ${f2}▄▄ █▀█▀█ ▄▄ ${f3}▄▄ █▀█▀█ ▄▄ ${f4}▄▄ █▀█▀█ ▄▄ ${f5}▄▄ █▀█▀█ ▄▄ ${f6}▄▄ █▀█▀█ ▄▄ 19 | ${f1} ▀ ▀ ${f2} ▀ ▀ ${f3} ▀ ▀ ${f4} ▀ ▀ ${f5} ▀ ▀ ${f6} ▀ ▀ $bld 20 | ${f1}▄█ █▄ ${f2}▄█ █▄ ${f3}▄█ █▄ ${f4}▄█ █▄ ${f5}▄█ █▄ ${f6}▄█ █▄ 21 | ${f1} ▄█████▄ ${f2} ▄█████▄ ${f3} ▄█████▄ ${f4} ▄█████▄ ${f5} ▄█████▄ ${f6} ▄█████▄ 22 | ${f1} █▄▄█▄▄█ ${f2} █▄▄█▄▄█ ${f3} █▄▄█▄▄█ ${f4} █▄▄█▄▄█ ${f5} █▄▄█▄▄█ ${f6} █▄▄█▄▄█ 23 | ${f1}▄▄ █▀█▀█ ▄▄ ${f2}▄▄ █▀█▀█ ▄▄ ${f3}▄▄ █▀█▀█ ▄▄ ${f4}▄▄ █▀█▀█ ▄▄ ${f5}▄▄ █▀█▀█ ▄▄ ${f6}▄▄ █▀█▀█ ▄▄ 24 | ${f1} ▀ ▀ ${f2} ▀ ▀ ${f3} ▀ ▀ ${f4} ▀ ▀ ${f5} ▀ ▀ ${f6} ▀ ▀ $rst 25 | 26 | EOF 27 | -------------------------------------------------------------------------------- /c-slendy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | initializeANSI() 4 | { 5 | esc="" 6 | 7 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 8 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 9 | cyanf="${esc}[36m"; whitef="${esc}[37m" 10 | 11 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 12 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 13 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 14 | 15 | boldon="${esc}[1m"; boldoff="${esc}[22m" 16 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 17 | ulon="${esc}[4m"; uloff="${esc}[24m" 18 | invon="${esc}[7m"; invoff="${esc}[27m" 19 | 20 | reset="${esc}[0m" 21 | } 22 | 23 | initializeANSI 24 | 25 | cat << EOF 26 | 27 | ${reset}${blackf}| | | | |${reset} 28 | ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset} 29 | ${redf}███████${reset} ${blackf}|${reset} ${greenf}███████${reset} ${blackf}|${reset} ${yellowf}███████${reset} ${blackf}|${reset} ${bluef}███████${reset} ${blackf}|${reset} ${purplef}███████${reset} ${blackf}|${reset} ${cyanf}███████${reset} 30 | ${redf}███${boldon}${redb}██${reset}${redf}█${boldon}${redb}██${reset}${redf}███${reset} ${blackf}|${reset} ${greenf}███${boldon}${greenb}██${reset}${greenf}█${boldon}${greenb}██${reset}${greenf}███${reset} ${blackf}|${reset} ${yellowf}███${boldon}${yellowb}██${reset}${yellowf}█${boldon}${yellowb}██${reset}${yellowf}███${reset} ${blackf}|${reset} ${bluef}███${boldon}${blueb}██${reset}${bluef}█${boldon}${blueb}██${reset}${bluef}███${reset} ${blackf}|${reset} ${purplef}███${boldon}${purpleb}██${reset}${purplef}█${boldon}${purpleb}██${reset}${purplef}███${reset} ${blackf}|${reset} ${cyanf}███${boldon}${cyanb}██${reset}${cyanf}█${boldon}${cyanb}██${reset}${cyanf}███${reset} 31 | ${redf}████${boldon}${redb}█${reset}${redf}████${reset} ${blackf}|${reset} ${greenf}████${boldon}${greenb}█${reset}${greenf}████${reset} ${blackf}|${reset} ${yellowf}████${boldon}${yellowb}█${reset}${yellowf}████${reset} ${blackf}|${reset} ${bluef}████${boldon}${blueb}█${reset}${bluef}████${reset} ${blackf}|${reset} ${purplef}████${boldon}${purpleb}█${reset}${purplef}████${reset} ${blackf}|${reset} ${cyanf}████${boldon}${cyanb}█${reset}${cyanf}████${reset} 32 | ${redf}█ █ ${boldon}█${reset} ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █ ${boldon}█${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █ ${boldon}█${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █ ${boldon}█${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █ ${boldon}█${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █ ${boldon}█${reset} ${cyanf}█ █${reset} 33 | ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset} 34 | ${blackf}| | | | |${reset} 35 | 36 | EOF 37 | -------------------------------------------------------------------------------- /c-spooky: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # ANSI color scheme script by pfh 4 | # 5 | # Initializing mod by lolilolicon from Archlinux 6 | # 7 | 8 | f=3 b=4 9 | for j in f b; do 10 | for i in {0..7}; do 11 | printf -v $j$i %b "\e[${!j}${i}m" 12 | done 13 | done 14 | bld=$'\e[1m' 15 | rst=$'\e[0m' 16 | inv=$'\e[7m' 17 | cat << EOF 18 | 19 | $f1 ▄▄▄ $f2 ▄▄▄ $f3 ▄▄▄ $f4 ▄▄▄ $f5 ▄▄▄ $f6 ▄▄▄ 20 | $f1 ▀█▀██ ▄ $f2 ▀█▀██ ▄ $f3 ▀█▀██ ▄ $f4 ▀█▀██ ▄ $f5 ▀█▀██ ▄ $f6 ▀█▀██ ▄ 21 | $f1 ▀▄██████▀ $f2 ▀▄██████▀ $f3 ▀▄██████▀ $f4 ▀▄██████▀ $f5 ▀▄██████▀ $f6 ▀▄██████▀ 22 | $f1 ▀█████ $f2 ▀█████ $f3 ▀█████ $f4 ▀█████ $f5 ▀█████ $f6 ▀█████ 23 | $f1 ▀▀▀▀▄ $f2 ▀▀▀▀▄ $f3 ▀▀▀▀▄ $f4 ▀▀▀▀▄ $f5 ▀▀▀▀▄ $f6 ▀▀▀▀▄ 24 | $bld 25 | $f1 ▄▄▄ $f2 ▄▄▄ $f3 ▄▄▄ $f4 ▄▄▄ $f5 ▄▄▄ $f6 ▄▄▄ 26 | $f1 ▀█▀██ ▄ $f2 ▀█▀██ ▄ $f3 ▀█▀██ ▄ $f4 ▀█▀██ ▄ $f5 ▀█▀██ ▄ $f6 ▀█▀██ ▄ 27 | $f1 ▀▄██████▀ $f2 ▀▄██████▀ $f3 ▀▄██████▀ $f4 ▀▄██████▀ $f5 ▀▄██████▀ $f6 ▀▄██████▀ 28 | $f1 ▀█████ $f2 ▀█████ $f3 ▀█████ $f4 ▀█████ $f5 ▀█████ $f6 ▀█████ 29 | $f1 ▀▀▀▀▄ $f2 ▀▀▀▀▄ $f3 ▀▀▀▀▄ $f4 ▀▀▀▀▄ $f5 ▀▀▀▀▄ $f6 ▀▀▀▀▄ 30 | $rst 31 | EOF 32 | -------------------------------------------------------------------------------- /c-streaks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # ANSI color scheme script by pfh 4 | # 5 | # Initializing mod by lolilolicon from Archlinux 6 | # 7 | 8 | f=3 b=4 9 | for j in f b; do 10 | for i in {0..7}; do 11 | printf -v $j$i %b "\e[${!j}${i}m" 12 | done 13 | done 14 | bld=$'\e[1m' 15 | rst=$'\e[0m' 16 | inv=$'\e[7m' 17 | 18 | cat << EOF 19 | 20 | $f1 ▀■▄ $f2 ▀■▄ $f3 ▀■▄ $f4 ▀■▄ $f5 ▀■▄ $f6 ▀■▄ 21 | $bld$f1 ▀■▄ $f2 ▀■▄ $f3 ▀■▄ $f4 ▀■▄ $f5 ▀■▄ $f6 ▀■▄ $rst 22 | 23 | EOF -------------------------------------------------------------------------------- /c-table: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file echoes a bunch of color codes to the 4 | # terminal to demonstrate what's available. Each 5 | # line is the color code of one foreground color, 6 | # out of 17 (default + 16 escapes), followed by a 7 | # test use of that color on all nine background 8 | # colors (default + 8 escapes). 9 | # 10 | 11 | T=' x ' # The test text 12 | 13 | echo -e "\n 40m 41m 42m 43m\ 14 | 44m 45m 46m 47m"; 15 | 16 | for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \ 17 | '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \ 18 | ' 36m' '1;36m' ' 37m' '1;37m'; 19 | do FG=${FGs// /} 20 | echo -en " $FGs \033[$FG $T " 21 | for BG in 40m 41m 42m 43m 44m 45m 46m 47m; 22 | do echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; 23 | done 24 | echo; 25 | done 26 | echo -------------------------------------------------------------------------------- /c-tanks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ANSI Color -- use these variables to easily have different color 4 | # and format output. Make sure to output the reset sequence after 5 | # colors (f = foreground, b = background), and use the 'off' 6 | # feature for anything you turn on. 7 | 8 | initializeANSI() 9 | { 10 | esc="" 11 | 12 | blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" 13 | yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" 14 | cyanf="${esc}[36m"; whitef="${esc}[37m" 15 | 16 | blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" 17 | yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" 18 | cyanb="${esc}[46m"; whiteb="${esc}[47m" 19 | 20 | boldon="${esc}[1m"; boldoff="${esc}[22m" 21 | italicson="${esc}[3m"; italicsoff="${esc}[23m" 22 | ulon="${esc}[4m"; uloff="${esc}[24m" 23 | invon="${esc}[7m"; invoff="${esc}[27m" 24 | 25 | reset="${esc}[0m" 26 | } 27 | 28 | # note in this first use that switching colors doesn't require a reset 29 | # first - the new color overrides the old one. 30 | 31 | initializeANSI 32 | 33 | cat << EOF 34 | 35 | ${boldon}${redf} █ ${reset} ${boldon}${greenf} █ ${reset} ${boldon}${yellowf} █ ${reset} ${boldon}${bluef} █ ${reset} ${boldon}${purplef} █ ${reset} ${boldon}${cyanf} █ ${reset} 36 | ${boldon}${redf}▄▄ █ ▄▄${reset} ${boldon}${greenf}▄▄ █ ▄▄${reset} ${boldon}${yellowf}▄▄ █ ▄▄${reset} ${boldon}${bluef}▄▄ █ ▄▄${reset} ${boldon}${purplef}▄▄ █ ▄▄${reset} ${boldon}${cyanf}▄▄ █ ▄▄${reset} 37 | ${boldon}${redf}███▀▀▀███${reset} ${boldon}${greenf}███▀▀▀███${reset} ${boldon}${yellowf}███▀▀▀███${reset} ${boldon}${bluef}███▀▀▀███${reset} ${boldon}${purplef}███▀▀▀███${reset} ${boldon}${cyanf}███▀▀▀███${reset} 38 | ${boldon}${redf}███ █ ███${reset} ${boldon}${greenf}███ █ ███${reset} ${boldon}${yellowf}███ █ ███${reset} ${boldon}${bluef}███ █ ███${reset} ${boldon}${purplef}███ █ ███${reset} ${boldon}${cyanf}███ █ ███${reset} 39 | ${boldon}${redf}██ ▀▀▀ ██${reset} ${boldon}${greenf}██ ▀▀▀ ██${reset} ${boldon}${yellowf}██ ▀▀▀ ██${reset} ${boldon}${bluef}██ ▀▀▀ ██${reset} ${boldon}${purplef}██ ▀▀▀ ██${reset} ${boldon}${cyanf}██ ▀▀▀ ██${reset} 40 | 41 | ${redf} █ ${reset} ${greenf} █ ${reset} ${yellowf} █ ${reset} ${bluef} █ ${reset} ${purplef} █ ${reset} ${cyanf} █ ${reset} 42 | ${redf}▄▄ █ ▄▄${reset} ${greenf}▄▄ █ ▄▄${reset} ${yellowf}▄▄ █ ▄▄${reset} ${bluef}▄▄ █ ▄▄${reset} ${purplef}▄▄ █ ▄▄${reset} ${cyanf}▄▄ █ ▄▄${reset} 43 | ${redf}███▀▀▀███${reset} ${greenf}███▀▀▀███${reset} ${yellowf}███▀▀▀███${reset} ${bluef}███▀▀▀███${reset} ${purplef}███▀▀▀███${reset} ${cyanf}███▀▀▀███${reset} 44 | ${redf}███ █ ███${reset} ${greenf}███ █ ███${reset} ${yellowf}███ █ ███${reset} ${bluef}███ █ ███${reset} ${purplef}███ █ ███${reset} ${cyanf}███ █ ███${reset} 45 | ${redf}██ ▀▀▀ ██${reset} ${greenf}██ ▀▀▀ ██${reset} ${yellowf}██ ▀▀▀ ██${reset} ${bluef}██ ▀▀▀ ██${reset} ${purplef}██ ▀▀▀ ██${reset} ${cyanf}██ ▀▀▀ ██${reset} 46 | 47 | EOF 48 | -------------------------------------------------------------------------------- /c-tv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo 4 | 5 | for n in '0' '1' '2' '3' '4' '5' '6' \ 6 | '7' '8' '9' '10' '11' '12' '13'; 7 | do 8 | for BG in 47m 43m 46m 42m 45m 41m 44m; 9 | do echo -en "$EINS\033[$BG \033[0m"; 10 | done 11 | echo; 12 | done 13 | 14 | 15 | for FGs in '0' '1'; 16 | do FG=${FGs// /} 17 | for BG in 44m 40m 45m 40m 46m 40m 47m; 18 | do echo -en "$EINS\033[$BG \033[0m"; 19 | done 20 | echo; 21 | done 22 | 23 | for FGs in '0' '1' '2' '3' '4'; 24 | do FG=${FGs// /} 25 | for BG in 44m 44m 44m 44m 44m 47m 47m 47m 47m 47m 45m 45m 45m 45m 45m 40m 40m 40m 40m 40m 40m 40m 40m 40m 40m 40m 40m 40m; 26 | do echo -en "$EINS\033[$BG \033[0m"; 27 | done 28 | echo; 29 | done 30 | echo 31 | -------------------------------------------------------------------------------- /c-tvs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://github.com/roberoonska/dotfiles/tree/master/colorscripts 3 | 4 | f=3 b=4 5 | for j in f b; do 6 | for i in {0..7}; do 7 | printf -v $j$i %b "\e[${!j}${i}m" 8 | done 9 | done 10 | bld=$'\e[1m' 11 | rst=$'\e[0m' 12 | inv=$'\e[7m' 13 | w=$'\e[37m' 14 | cat << EOF 15 | 16 | ${f1} ▀▄ ▄▀ ${f2} ▀▄ ▄▀ ${f3} ▀▄ ▄▀ ${f4} ▀▄ ▄▀ ${f5} ▀▄ ▄▀ ${f6} ▀▄ ▄▀ 17 | ${f1} ▄▄█▄█▄▄ ${f2} ▄▄█▄█▄▄ ${f3} ▄▄█▄█▄▄ ${f4} ▄▄█▄█▄▄ ${f5} ▄▄█▄█▄▄ ${f6} ▄▄█▄█▄▄ 18 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 19 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 20 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 21 | ${f1} ▀▀▀▀▀▀▀ ${f2} ▀▀▀▀▀▀▀ ${f3} ▀▀▀▀▀▀▀ ${f4} ▀▀▀▀▀▀▀ ${f5} ▀▀▀▀▀▀▀ ${f6} ▀▀▀▀▀▀▀ $bld 22 | 23 | ${f1} ▀▄ ▄▀ ${f2} ▀▄ ▄▀ ${f3} ▀▄ ▄▀ ${f4} ▀▄ ▄▀ ${f5} ▀▄ ▄▀ ${f6} ▀▄ ▄▀ 24 | ${f1} ▄▄█▄█▄▄ ${f2} ▄▄█▄█▄▄ ${f3} ▄▄█▄█▄▄ ${f4} ▄▄█▄█▄▄ ${f5} ▄▄█▄█▄▄ ${f6} ▄▄█▄█▄▄ 25 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 26 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 27 | ${f1}█${w}██████${f1}██ ${f2}█${w}██████${f2}██ ${f3}█${w}██████${f3}██ ${f4}█${w}██████${f4}██ ${f5}█${w}██████${f5}██ ${f6}█${w}██████${f6}██ 28 | ${f1} ▀▀▀▀▀▀▀ ${f2} ▀▀▀▀▀▀▀ ${f3} ▀▀▀▀▀▀▀ ${f4} ▀▀▀▀▀▀▀ ${f5} ▀▀▀▀▀▀▀ ${f6} ▀▀▀▀▀▀▀ $rst 29 | 30 | EOF 31 | -------------------------------------------------------------------------------- /c-wheel: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | printf "\033[0m 4 | \033[49;35m|\033[49;31m|\033[101;31m|\033[41;97m|\033[49;91m|\033[49;93m|\033[0m 5 | \033[105;35m|\033[45;97m|\033[49;97m||\033[100;97m||\033[49;37m||\033[103;33m|\033[43;97m|\033[0m 6 | \033[49;95m|\033[49;94m|\033[100;37m||\033[40;97m||\033[40;37m||\033[49;33m|\033[49;32m|\033[0m 7 | \033[104;34m|\033[44;97m|\033[49;90m||\033[40;39m||\033[49;39m||\033[102;32m|\033[42;97m|\033[0m 8 | \033[49;34m|\033[49;36m|\033[106;36m|\033[46;97m|\033[49;96m|\033[49;92m|\033[0m 9 | 10 | " -------------------------------------------------------------------------------- /ccast: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Uses castnow and provides embedded subtitles. 3 | # 4 | # Author: metakirby5 5 | 6 | vtt="$(mktemp).vtt" 7 | ffmpeg -i "$1" -f webvtt -y "$vtt" 2>/dev/null 8 | caffeinate -is castnow "$@" --subtitles "$vtt" \ 9 | --subtitle-color '#FFFFFFFF' 10 | rm "$vtt" 11 | -------------------------------------------------------------------------------- /crop-gif: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This is used to crop the excess background of a gif out. 3 | # 4 | # Author: metakirby5 5 | 6 | [ $# -ne 1 ] && exit 1 7 | 8 | file="$1" 9 | bgcolor="$(convert "$file[0]" -format "%[pixel:u.p{0,0}]" info:)" 10 | convert "$file" -trim -layers TrimBounds out-%03d.miff 11 | mogrify -background "$bgcolor" -layers flatten out-*.miff 12 | convert -dispose previous -delay 10 out-*.miff -loop 0 "out-$file" 13 | rm out-*.miff 14 | -------------------------------------------------------------------------------- /debloat-fossil-sport: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Unintalls bloatware from the Fossil Sport smartwatch. 3 | 4 | apps=( 5 | com.amberweather.watch 6 | com.dianping.v1 7 | com.eg.android.AlipayGphone 8 | com.fossil.charge.darter 9 | com.fossil.wearables.ds 10 | com.fossil.wearables.ks 11 | com.fossil.wearables.mk 12 | com.fossil.wearables.ms 13 | com.fossil.wearables.pu 14 | com.google.android.inputmethod.pinyin 15 | com.gotokeep.androidwear 16 | com.mobvoi.ticwear.aw.appstore 17 | com.mobvoi.ticwear.sidewearvoicesearch 18 | com.mobvoi.wear.account.aw 19 | com.mobvoi.wear.appsservice 20 | com.mobvoi.wear.fitness.aw 21 | com.mobvoi.wear.health.aw 22 | com.mobvoi.wear.neteasemusic.aw 23 | com.mobvoi.wear.social.aw 24 | com.nike.plusgps 25 | com.safetrekapp.safetrek 26 | com.sdu.didi.psnger 27 | com.sogou.map.android.maps 28 | com.spotify.music 29 | ctrip.android.view 30 | ) 31 | 32 | pm() { 33 | adb shell pm "$@" 34 | } 35 | 36 | for app in ${apps[@]}; do 37 | echo "=== $app" 38 | echo "Uninstall: $(pm uninstall --user 0 "$app")" 39 | echo "Disable: $(pm disable-user --user 0 "$app" 2>/dev/null || echo "Skipped")" 40 | done 41 | -------------------------------------------------------------------------------- /dmenu_counter: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | description = """ 4 | Counts how many times a dmenu entry has been run and 5 | reorders accordingly. Executes dmenu as provided by 6 | the remaining arguments. 7 | 8 | Author: metakirby5 9 | """ 10 | 11 | import os 12 | import sys 13 | import json 14 | import codecs 15 | import argparse 16 | from subprocess import Popen, PIPE 17 | from collections import defaultdict 18 | 19 | # Get dmenu and counter_file 20 | parser = argparse.ArgumentParser(description=description, 21 | usage="%(prog)s [--help] [-counter COUNTER] dmenu ...", 22 | add_help=False) 23 | parser.add_argument('--help', 24 | help="show this help message and exit", 25 | action='help') 26 | parser.add_argument('-counter', 27 | help=""" 28 | the file to use for counting the number of times 29 | a program has executed. Uses ~/.dmenu_counter.json 30 | by default. 31 | """, 32 | type=str, 33 | default=os.path.join(os.getenv('HOME'), '.dmenu_counter.json')) 34 | args, dmenu = parser.parse_known_args() 35 | 36 | counter_file = args.counter 37 | 38 | # Check if we have a dmenu 39 | if not len(dmenu): 40 | parser.error("No dmenu provided!") 41 | 42 | counter = defaultdict(int) 43 | 44 | # Try to load existing dictionary 45 | try: 46 | with codecs.open(counter_file, 'r', 'utf-8') as f: 47 | counter.update(json.load(f)) 48 | 49 | # Does not exist - proceed with an empty dict 50 | except IOError: 51 | pass 52 | 53 | # Add stdin items to dict 54 | for line in codecs.getreader('utf-8')(sys.stdin): 55 | line = line.rstrip('\n') 56 | if line not in counter: 57 | counter[line] = 0 58 | 59 | # Get a list of sorted items 60 | items = [k for k, v in sorted( 61 | counter.iteritems(), 62 | # Sort decreasing val, then increasing key 63 | key=lambda x: (-x[1], x[0]), 64 | )] 65 | 66 | # Open up dmenu and get its output 67 | dmenu_proc = Popen(dmenu, stdin=PIPE, stdout=PIPE) 68 | selected = dmenu_proc.communicate( 69 | '\n'.join(items).encode('utf-8'))[0].split('\n')[0] 70 | 71 | # Record the results 72 | if selected: 73 | counter[selected] += 1 74 | with codecs.open(counter_file, 'w+', 'utf-8') as f: 75 | json.dump(counter, f, indent=2) 76 | 77 | # Output our selection 78 | print(selected) 79 | -------------------------------------------------------------------------------- /extsub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs a command with two arguments: 3 | # $1, and $1 with the extension substituted for $2. 4 | # 5 | # Author: metakirby5 6 | 7 | usage() { 8 | echo "Usage: $(basename "$0") [source file] [extension] [command...]" 9 | exit 1 10 | } 11 | 12 | [ "$#" -lt 2 ] && usage 13 | 14 | src="$1" 15 | dest="${src%.*}.$2" 16 | shift; shift 17 | "$@" "$src" "$dest" 18 | -------------------------------------------------------------------------------- /fetch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fetch info about your system 3 | # 4 | # Original by Dylan Araps 5 | # https://github.com/dylanaraps/dotfiles/ 6 | # Created by Ethan Chan 7 | # https://github.com/metakirby5/dotfiles/ 8 | 9 | # Config file to source 10 | # Can contain: 11 | # FETCH_TITLE=text 12 | # FETCH_UNDERLINE=text 13 | # FETCH_PRIMARY_N=0-7 14 | # FETCH_SECONDARY_N=0-7 15 | # FETCH_PRIMARY_CHAR=character to mark primary color with 16 | # FETCH_SECONDARY_CHAR=character to mark secondary color with 17 | # FETCH_OTHER_CHAR=character to mark other colors with 18 | # FETCH_CHARHEIGHT=number 19 | # FETCH_CHARWIDTH=number 20 | # FETCH_ADDITIONAL_PADDING=number 21 | # FETCH_IMGDIR=/some/path/ 22 | # 23 | # # Anything before the first colon is colored $FETCH_SECONDARY. 24 | # FETCH_INFO=( 25 | # "OS: $(cat /etc/*ease | awk -F= '/^NAME=/{ print $2 }')" 26 | # "Kernel: $(uname -r)" 27 | # "Uptime: $(uptime -p | sed 's/ou\|ute//g')" 28 | # # etc. 29 | # ) 30 | 31 | fetch_config=~/.config/fetch/config 32 | 33 | # === DO NOT EDIT BELOW THIS LINE === 34 | 35 | usage() { 36 | echo "USAGE: $(basename "$0") [-h] [-i] [-r] [-f FUZZ]" 37 | echo " -h help" 38 | echo " -l list available images" 39 | echo " -i IMG_SRC image source" 40 | echo " -r remake image" 41 | echo " -m use imagemagick instead of smartcrop" 42 | echo " -f FUZZ fuzz to use in imagemagick cropping" 43 | exit 1 44 | } 45 | 46 | [ -f "$fetch_config" ] && source "$fetch_config" 47 | 48 | # Parse args 49 | while getopts ":hli:rmf:" opt; do 50 | case $opt in 51 | h) usage ;; 52 | l) list_img=1 ;; 53 | i) img_src="$OPTARG" ;; 54 | r) remake_img=1 ;; 55 | m) use_imagemagick=1 ;; 56 | f) fuzz="$OPTARG" ;; 57 | \?) echo "Invalid option: -$OPTARG" >&2; usage ;; 58 | :) echo "Option -$OPTARG requires an argument." >&2; usage ;; 59 | esac 60 | done 61 | 62 | # Other actions 63 | if [ -n "$list_img" ]; then 64 | ls "$imgdir" 65 | exit 0 66 | fi 67 | 68 | # Defaults 69 | title="${FETCH_TITLE:-"$(whoami)"}" 70 | underline="${FETCH_UNDERLINE:-"$(printf "%${#title}s" | tr ' ' '=')="}" 71 | primary_n="${FETCH_PRIMARY_N:-1}" 72 | secondary_n="${FETCH_SECONDARY_N:-4}" 73 | primary_char="${FETCH_PRIMARY_CHAR:-"."}" 74 | secondary_char="${FETCH_SECONDARY_CHAR:-"_"}" 75 | other_char="${FETCH_OTHER_CHAR:-" "}" 76 | charheight="${FETCH_CHARHEIGHT:-31}" 77 | charwidth="${FETCH_CHARWIDTH:-"$(($charheight / 2))"}" 78 | additional_padding="${FETCH_ADDITIONAL_PADDING:-2}" 79 | imgdir="${FETCH_IMGDIR:-"$HOME/.fetch_crops/"}" 80 | 81 | img_src="${img_src:-"$(cat ~/.fehbg | cut -d\' -f2)"}" 82 | fuzz="${fuzz:-15%}" 83 | 84 | [ -n "${FETCH_INFO+1}" ] && info=("${FETCH_INFO[@]}") || info=( 85 | "OS: $(cat /etc/*ease | awk -F= '/^NAME=/{ print $2 }')" 86 | "Kernel: $(uname -r)" 87 | "Uptime: $(uptime -p | sed 's/ou\|ute//g')" 88 | "Shell: $(basename "$SHELL")" 89 | "Window Manager: $(wmctrl -m | awk '/^Name:/{ print $2}')" 90 | "CPU: $(cat /proc/cpuinfo |\ 91 | awk -F: '/^model name/{ gsub(/^\s+/, "", $2); print $2; exit }')" 92 | "Speed: $(lscpu |\ 93 | awk -F: '/^CPU MHz:/{ print "scale=1;" $2 "/ 1000" }' | bc -l)GHz" 94 | "Memory: $(free -m | awk '/^Mem:/{ print $3 "/" $2 " MB" }')" 95 | ) 96 | 97 | # Calculate sizing info 98 | numlines="$((${#info[@]} + 5))" # title + underline + 3x color info = 5 99 | isize="$(($numlines * $charheight))" 100 | padlen="$(($isize / $charwidth + $additional_padding))" 101 | linelen="$(($(tput cols) - $padlen))" 102 | colorlen="$(($linelen / 8))" # 8 colors 103 | 104 | # Sizing-dependent strings 105 | pad="$(printf "%${padlen}s")" 106 | color="$(printf "%${colorlen}s")" 107 | markerseq="$(seq 1 $(($colorlen - 2)))" # space at start and end 108 | pmarker=" $(printf "$primary_char%.0s" $markerseq) " 109 | smarker=" $(printf "$secondary_char%.0s" $markerseq) " 110 | omarker=" $(printf "$other_char%.0s" $markerseq) " 111 | 112 | # Colors 113 | primary="$(tput setaf $primary_n)" 114 | secondary="$(tput setaf $secondary_n)" 115 | bold="$(tput bold)" 116 | clear="$(tput sgr0)" 117 | 118 | put_color_header() { 119 | local text 120 | for i in `seq 0 7`; do 121 | case "$i" in 122 | "$primary_n") text="$pmarker" ;; 123 | "$secondary_n") text="$smarker" ;; 124 | *) text="$omarker" ;; 125 | esac 126 | 127 | echo -n "$(tput setaf $i)$bold$text$clear" 128 | done 129 | } 130 | 131 | put_colors() { 132 | for i in `seq $1 $2`; do 133 | echo -n "$(tput setab $i)$color$clear" 134 | done 135 | } 136 | 137 | # Prepare the image 138 | img="${imgdir%/}/$(basename "$img_src")" 139 | if [ ! -f "$img" ] || [ -n "$remake_img" ]; then 140 | if [ ! -d "$imgdir" ]; then 141 | mkdir "$imgdir" || exit "$?" 142 | fi 143 | 144 | # Should we use smartcrop? 145 | if [ -z "$use_imagemagick" ] && command -v smartcrop &>/dev/null; then 146 | smartcrop "$img_src" "$img" &>/dev/null 147 | 148 | # If we failed, it's probably b/c we had no extension 149 | if [ $? -eq 1 ]; then 150 | smartcrop "$img_src" "${img}.png" &>/dev/null 151 | mv "${img}.png" "$img" 152 | fi 153 | else # Use imagemagick 154 | # Trim 155 | convert "$img_src" -crop "$(convert "$img_src" \ 156 | -fuzz "$fuzz" -trim -format '%wx%h%O' info: 2>/dev/null)" \ 157 | +repage "$img" &>/dev/null 158 | 159 | wsize="$(identify -format '%[fx:min(w,h)]' "$img" 2>/dev/null)" 160 | mogrify -crop "$wsize"x"$wsize"+0+0 -gravity center "$img" &>/dev/null 161 | fi 162 | 163 | if [ ! -f "$img" ]; then 164 | echo "Image \"$img_src\" not found!" 165 | exit 1 166 | fi 167 | fi 168 | 169 | # Print info 170 | clear 171 | tput civis 172 | echo "$pad$bold$primary$title$clear" 173 | echo "$pad$primary$underline$clear" 174 | 175 | for line in "${info[@]}"; do 176 | # If it has a colon, add some colors 177 | if [[ "$line" == *:* ]]; then 178 | cur="$bold$secondary${line%%:*}$clear:${line#*:}" 179 | else 180 | cur="$line" 181 | fi 182 | 183 | # Do some truncation 184 | len="$(echo -n "$line" | wc -c)" 185 | clen="$(($(echo -n "$cur" | wc -c) - $len))" 186 | if [ "$len" -gt "$linelen" ]; then 187 | # Need to account for length of non-printing characters 188 | cur="$(echo "$cur" | cut -c-$(($linelen + $clen - 1)))…" 189 | fi 190 | 191 | echo "$pad$cur" 192 | done 193 | 194 | echo "$pad$(put_color_header)" 195 | echo "$pad$(put_colors 0 7)" 196 | echo "$pad$(put_colors 8 15)" 197 | printf "0;1;$xoffset;$yoffset;$isize;$isize;;;;;$img\n4;\n3;" |\ 198 | /usr/lib/w3m/w3mimgdisplay 199 | tput cnorm 200 | 201 | -------------------------------------------------------------------------------- /fzmp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # https://github.com/DanielFGray/dotfiles/blob/master/bash_utils 3 | 4 | mapfile -t songs < <(mpc listall | sort -r | fzf --reverse -m -e +s) 5 | if (( ${#songs[@]} > 0 )); then 6 | printf '%s\n' "${songs[@]}" | mpc -q add 7 | index=$(mpc playlist | wc -l) 8 | if (( ${#songs[@]} > 1 )); then 9 | index=$(( $index - ${#songs[@]} + 1)) 10 | fi 11 | mpc -q play "$index" 12 | fi 13 | -------------------------------------------------------------------------------- /get-battery-status: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Get the battery percent, along with the charging status and time. 3 | 4 | upower -i /org/freedesktop/UPower/devices/battery_BAT1 |\ 5 | awk -F: '/time/ { 6 | gsub(/^ +|ou|ute/, "", $2); 7 | s = $2 " " (match($1, /empty/) ? "↓" : "↑") " "; 8 | } /percentage/ { 9 | gsub(/^ +/, "", $2); 10 | print s $2; 11 | }' 12 | 13 | -------------------------------------------------------------------------------- /get-truncated-window-title: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Get the currently focused window's title, truncated to 40 characters. 3 | # https://maxammann.github.io/2015/03/07/conky-window-title/ 4 | 5 | xprop -id \ 6 | $(xprop -root _NET_ACTIVE_WINDOW | cut -d\ -f5) _NET_WM_NAME |\ 7 | awk -v len=100 ' 8 | { 9 | gsub(/^.* = "|"$|\\/, "", $0) 10 | if (length($0) > len) 11 | print substr($0, 0, len-1) "…" 12 | else 13 | print $0 14 | } 15 | ' 16 | 17 | -------------------------------------------------------------------------------- /gitlab-api: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Calls a gitlab endpoint based on the repo information. 3 | # 4 | # Dependencies: git, urlencode, curl 5 | # Environment variables: $GITLAB_TOKEN 6 | # 7 | # Usage: gitlab-api (endpoint) (curl args) 8 | # 9 | # Author: metakirby5 10 | 11 | log() { 12 | echo "$@" >/dev/stderr 13 | } 14 | 15 | fail() { 16 | log "$@" 17 | exit 1 18 | } 19 | 20 | checkdep() { 21 | type "$1" &>/dev/null || echo " $1" 22 | } 23 | 24 | missing="$(checkdep git)$(checkdep urlencode)$(checkdep curl)" 25 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 26 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 27 | 28 | remote="$(git remote get-url --push origin)" 29 | no_user="${remote##*@}" 30 | host="${no_user%%:*}" 31 | project_git="${no_user##*:}" 32 | project="$(urlencode "${project_git%%.*}")" 33 | base="$host/api/v4/projects/$project" 34 | 35 | curl -L --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$base/$1" "${@:2}" 36 | -------------------------------------------------------------------------------- /gitlab-artifacts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Gets artifacts from a GitLab job, e.g. 3 | # https://gitlab.domain.com/user/project/-/jobs/12345 4 | # 5 | # Dependencies: urlencode, curl 6 | # Environment variables: $GITLAB_TOKEN 7 | # 8 | # Author: metakirby5 9 | 10 | log() { 11 | echo "$@" >/dev/stderr 12 | } 13 | 14 | fail() { 15 | log "$@" 16 | exit 1 17 | } 18 | 19 | checkdep() { 20 | type "$1" &>/dev/null || echo " $1" 21 | } 22 | 23 | missing="$(checkdep urlencode)$(checkdep curl)" 24 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 25 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 26 | 27 | usage() { 28 | echo "Usage: $(basename "$0") [job URL] [output filename] (artifact path)" 29 | exit 1 30 | } 31 | 32 | [ "$#" -lt 2 ] && usage 33 | 34 | protocol="${1%%://*}" 35 | strip_protocol="${1##*://}" 36 | base="$protocol://${strip_protocol%%/*}" 37 | strip_base="${strip_protocol#*/}" 38 | project="${strip_base%%/-*}" 39 | job="${strip_base##*/}" 40 | 41 | endpoint="$base/api/v4/projects/$(urlencode "$project")/jobs/$job/artifacts/$3" 42 | echo "Retrieving: $endpoint" 43 | 44 | curl -o "$2" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$endpoint" 45 | -------------------------------------------------------------------------------- /gitlab-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs an apk found in GitLab job artifacts, e.g. 3 | # https://gitlab.domain.com/user/project/-/jobs/12345 4 | # 5 | # Dependencies: mktemp, unzip, adb, gitlab-artifacts 6 | # Environment variables: $GITLAB_TOKEN 7 | # 8 | # Author: metakirby5 9 | 10 | log() { 11 | echo "$@" >/dev/stderr 12 | } 13 | 14 | fail() { 15 | log "$@" 16 | exit 1 17 | } 18 | 19 | checkdep() { 20 | type "$1" &>/dev/null || echo " $1" 21 | } 22 | 23 | missing="$(checkdep mktemp)$(checkdep unzip)$(checkdep adb)$(checkdep gitlab-artifacts)" 24 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 25 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 26 | 27 | usage() { 28 | echo "Usage: $(basename "$0") [job URL] (name pattern) (installer...)" 29 | echo " For iOS: $(basename "$0") [job URL] '*.ipa' ideviceinstaller -i" 30 | exit 1 31 | } 32 | 33 | [ "$#" -lt 1 ] && usage 34 | 35 | job="$1"; shift 36 | name_pat="$1"; shift 37 | 38 | artifacts="$(mktemp).zip" 39 | artifacts_dir="$(mktemp)_extracted" 40 | finish() { 41 | rm -rf "$artifacts" "$artifacts_dir" 42 | } 43 | trap finish EXIT 44 | 45 | gitlab-artifacts "$job" "$artifacts" || exit 1 46 | unzip "$artifacts" -d "$artifacts_dir" 47 | default_cmd=( "adb" "install" "-r" "-d" ) 48 | find "$artifacts_dir" -name "${name_pat:-*.apk}" | xargs "${@:-"${default_cmd[@]}"}" || exit 1 49 | -------------------------------------------------------------------------------- /gitlab-job-action: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs a task for a gitlab job. 3 | # API calls inferred from repo information. 4 | # 5 | # Dependencies: gitlab-api, git, urlencode, curl, jq 6 | # Environment variables: $GITLAB_TOKEN 7 | # 8 | # Usage: gitlab-job [action] [job id] 9 | # 10 | # Author: metakirby5 11 | 12 | log() { 13 | echo "$@" >/dev/stderr 14 | } 15 | 16 | fail() { 17 | log "$@" 18 | exit 1 19 | } 20 | 21 | checkdep() { 22 | type "$1" &>/dev/null || echo " $1" 23 | } 24 | 25 | missing="\ 26 | $(checkdep gitlab-api)\ 27 | $(checkdep git)\ 28 | $(checkdep urlencode)\ 29 | $(checkdep curl)\ 30 | $(checkdep jq)\ 31 | " 32 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 33 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 34 | 35 | usage() { 36 | echo "Usage: ${0##*/} [action] [job id]" 37 | echo "Actions: name, info, artifacts, logs, cancel, retry, play" 38 | echo 39 | exit 1 40 | } 41 | 42 | [ "$#" -ne 2 ] && usage 43 | 44 | call() { 45 | gitlab-api "$@" 2>/dev/null 46 | } 47 | 48 | post() { 49 | call "$@" --request POST 50 | } 51 | 52 | parse() { 53 | jq -r "$@" 2>/dev/null 54 | } 55 | 56 | parse-status() { 57 | parse '"\(.id)\t\(.status)\t\(.web_url)"' 58 | } 59 | 60 | base="jobs/$2" 61 | case "$1" in 62 | name) 63 | call "$base" | parse '.name' 64 | ;; 65 | info) 66 | call "$base" | jq -r ' 67 | def date: if . then sub("\\.[^Z]*"; "") | fromdate | strftime("%c") else "-" end; 68 | " 69 | \(.name) (\(.id)): \(.status) 70 | \(.pipeline.ref) (\(.pipeline.sha)) 71 | \(.web_url) 72 | Runner:\t\(.runner.description // "-") 73 | Created:\t\(.created_at | date) 74 | Started:\t\(.started_at | date) 75 | Finished:\t\(.finished_at | date) 76 | " 77 | ' 78 | ;; 79 | artifacts) 80 | gitlab-api "$base/artifacts" -o artifacts.zip 81 | ;; 82 | logs) 83 | call "$base/trace" | less -r 84 | ;; 85 | cancel) 86 | post "$base/cancel" | parse-status 87 | ;; 88 | retry) 89 | post "$base/retry" | parse-status 90 | ;; 91 | play) 92 | post "$base/play" | parse-status 93 | ;; 94 | *) 95 | usage 96 | ;; 97 | esac 98 | -------------------------------------------------------------------------------- /gitlab-job-id: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Prints a gitlab job ID. 3 | # API calls inferred from repo information. 4 | # 5 | # Dependencies: gitlab-api, git, urlencode, curl, jq, fzf 6 | # Environment variables: $GITLAB_TOKEN, $NO_CACHE 7 | # 8 | # Usage: gitlab-job-id (git ref) 9 | # 10 | # Author: metakirby5 11 | 12 | log() { 13 | echo "$@" >/dev/stderr 14 | } 15 | 16 | fail() { 17 | log "$@" 18 | exit 1 19 | } 20 | 21 | checkdep() { 22 | type "$1" &>/dev/null || echo " $1" 23 | } 24 | 25 | missing="\ 26 | $(checkdep gitlab-api)\ 27 | $(checkdep git)\ 28 | $(checkdep urlencode)\ 29 | $(checkdep curl)\ 30 | $(checkdep jq)\ 31 | $(checkdep fzf)\ 32 | " 33 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 34 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 35 | 36 | maybe_fail() { 37 | [ "$?" -ne 0 ] && fail "$@" 38 | } 39 | 40 | maybe_exit() { 41 | [ -z "$1" ] && fail "$2" 42 | } 43 | 44 | call() { 45 | gitlab-api "$@" 2>/dev/null 46 | } 47 | 48 | parse() { 49 | jq -r "$1 // \"\"" 2>/dev/null 50 | } 51 | 52 | cache=/tmp/gitlab-job-id 53 | mkdir -p "$cache" 54 | 55 | commit="$(git rev-parse --short=8 "${1:-HEAD}")" 56 | 57 | # Use cached pipeline info if we can, and cache it if we look it up. 58 | cached="$cache/$commit" 59 | [ -z "$NO_CACHE" ] && pipeline="$(cat "$cached" 2>/dev/null)" && [ "$pipeline" ] || 60 | pipeline="$(call "repository/commits/$commit" | parse '.last_pipeline.id')" && 61 | <<<"$pipeline" cat > "$cached" 62 | 63 | maybe_fail "Pipeline API failed." 64 | maybe_exit "$pipeline" "No pipeline ID for $commit." 65 | log "Pipeline: $pipeline" 66 | 67 | jobz="$(call "pipelines/$pipeline/jobs" | parse '.[] | "\(.id)\t\(.status)\t\(.name)"')" 68 | maybe_fail "Jobs API failed." 69 | maybe_exit "$jobz" "No jobs for $pipeline at $commit." 70 | 71 | job="$(<<<"$jobz" fzf --prompt 'Job: ')" 72 | maybe_exit "$job" "No job selected." 73 | 74 | <<<"$job" cut -f 1 75 | -------------------------------------------------------------------------------- /gitlab-job-interactive: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Interactive interface for gitlab jobs. 3 | # API calls inferred from repo information. 4 | # 5 | # Dependencies: gitlab-job-id, gitlab-job-action, gitlab-job-monitor, 6 | # gitlab-api, git, urlencode, curl, jq, fzf, ntfy 7 | # Environment variables: $GITLAB_TOKEN 8 | # 9 | # Usage: gitlab-job-interactive (git ref) 10 | # 11 | # Author: metakirby5 12 | 13 | set -e 14 | 15 | log() { 16 | echo "$@" >/dev/stderr 17 | } 18 | 19 | fail() { 20 | log "$@" 21 | exit 1 22 | } 23 | 24 | checkdep() { 25 | type "$1" &>/dev/null || echo " $1" 26 | } 27 | 28 | missing="\ 29 | $(checkdep gitlab-job-id)\ 30 | $(checkdep gitlab-job-action)\ 31 | $(checkdep gitlab-job-monitor)\ 32 | $(checkdep gitlab-api)\ 33 | $(checkdep git)\ 34 | $(checkdep urlencode)\ 35 | $(checkdep curl)\ 36 | $(checkdep jq)\ 37 | $(checkdep fzf)\ 38 | $(checkdep ntfy)\ 39 | " 40 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 41 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 42 | 43 | job="$(gitlab-job-id "$@")" 44 | name="$(gitlab-job-action name "$job")" 45 | log "Job: $name ($job)" 46 | 47 | monitor-and-notify() { 48 | gitlab-job-monitor "$1" 49 | ntfy send "$name done!" 50 | } 51 | 52 | action="$(fzf --prompt "$name: " </dev/stderr 15 | } 16 | 17 | fail() { 18 | log "$@" 19 | exit 1 20 | } 21 | 22 | checkdep() { 23 | type "$1" &>/dev/null || echo " $1" 24 | } 25 | 26 | missing="\ 27 | $(checkdep gitlab-api)\ 28 | $(checkdep git)\ 29 | $(checkdep urlencode)\ 30 | $(checkdep curl)\ 31 | $(checkdep jq)\ 32 | " 33 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 34 | [ -z "$GITLAB_TOKEN" ] && fail 'Missing $GITLAB_TOKEN!' 35 | 36 | usage() { 37 | echo "Usage: ${0##*/} [job ids...]" 38 | echo 39 | exit 1 40 | } 41 | 42 | [ "$#" -lt 1 ] && usage 43 | 44 | call() { 45 | gitlab-api "$@" 2>/dev/null 46 | } 47 | 48 | parse() { 49 | jq -r '.status' 2>/dev/null 50 | } 51 | 52 | # Loading spinner: https://unix.stackexchange.com/a/225183 53 | i=1 54 | sp="/-\|" 55 | spin() { 56 | printf "\b${sp:i++%${#sp}:1}" 57 | } 58 | end_spin() { 59 | printf "\b$*\n" 60 | } 61 | 62 | while [ "$#" -gt 0 ]; do 63 | job=${1##*/} 64 | echo -n "Monitoring job ID $job... " 65 | 66 | while :; do 67 | job_info="$(call "jobs/$job")" || fail 'Jobs API failed.' 68 | job_status="$(parse <<<"$job_info")" || fail 'Jobs status parse failed.' 69 | 70 | case "$job_status" in 71 | failed|success|canceled) 72 | end_spin "$job_status" 73 | break 74 | ;; 75 | null) 76 | end_spin 'Response: No job status.' 77 | echo "$job_info" 78 | break 79 | ;; 80 | esac 81 | 82 | for i in {1..100}; do 83 | spin 84 | sleep 0.1 85 | done 86 | done 87 | 88 | echo 89 | shift 90 | done 91 | -------------------------------------------------------------------------------- /global-entry-interviews: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Simple script to check global entry interview times. 3 | # 4 | # Dependencies: curl, jq 5 | # 6 | # Usage: global-entry-interviews [location ID] [date description...] 7 | # 8 | # Author: metakirby5 9 | 10 | set -e 11 | 12 | log() { 13 | echo "$@" >/dev/stderr 14 | } 15 | 16 | fail() { 17 | log "$@" 18 | exit 1 19 | } 20 | 21 | checkdep() { 22 | type "$1" &>/dev/null || echo " $1" 23 | } 24 | 25 | missing="\ 26 | $(checkdep curl)\ 27 | $(checkdep jq)\ 28 | " 29 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 30 | 31 | usage() { 32 | echo "Usage: ${0##*/} [location ID] [date description...]" 33 | echo "Date description: e.g. '7 days'" 34 | echo 35 | exit 1 36 | } 37 | 38 | [ "$#" -lt 2 ] && usage 39 | 40 | location_id="$1" 41 | shift 42 | 43 | date="$(date -d "$*" '+%Y-%m-%d')" 44 | url="https://ttp.cbp.dhs.gov/schedulerapi/slots?\ 45 | orderBy=soonest&\ 46 | locationId=$location_id&\ 47 | filterTimestampBy=before&\ 48 | timestamp=$date" 49 | 50 | curl "$url" 2>/dev/null | 51 | jq -r '.[] | "\(.startTimestamp):00Z" | fromdate | strftime("%c")' 52 | -------------------------------------------------------------------------------- /gspick: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # gsutil file picker. 3 | # 4 | # Author: metakirby5 5 | 6 | fail() { 7 | echo "$@" 8 | exit 1 9 | } 10 | 11 | checkdep() { 12 | type "$1" &>/dev/null || echo " $1" 13 | } 14 | 15 | missing="$(checkdep gsutil)$(checkdep fzf)" 16 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 17 | 18 | gsutil ls "$@" | fzf \ 19 | --header 'Tab / Shift-Tab to navigate' \ 20 | --bind 'tab:clear-query+reload(gsutil ls {})' \ 21 | --bind 'btab:clear-query+reload(bash -c "gsutil ls $(dirname $(dirname {}))")' 22 | -------------------------------------------------------------------------------- /hack: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if [ -z $1 ] 5 | then 6 | echo -e "Please use the script along with a valid website as an argument.\nexample: ./$0 www.google.com\nDo not use http:// or trailing /, DOMAIN ONLY." 7 | exit 1 8 | fi 9 | 10 | dot () { 11 | for ((i = 0; i < $1; i++)); do echo -n "."; sleep 0.04; done; echo -e '[\033[00;32mCOMPLETE\033[00;0m]';sleep 0.6 12 | } 13 | echo -n "Enumerating Target" 14 | dot 40 15 | echo -e " [+] Host: $1\n [+] IPv4: 192.168.13.37" 16 | echo -n "Opening SOCK5 ports on infected hosts" 17 | dot 21 18 | echo " [+] SSL entry point on 127.0.0.1:1337" 19 | echo -n "Chaining proxies" 20 | dot 42 21 | echo ' [+] 7/7 proxies chained {BEL>AUS>JAP>CHI>NOR>FIN>UKR}' 22 | echo -n "Launching port knocking sequence" 23 | dot 26 24 | echo " [+] Knock on TCP<143,993,587,456,25,587,993,80>" 25 | echo -n "Sending PCAP datagrams for fragmentation overlap" 26 | dot 10 27 | echo " [+] Stack override ***** w00t w00t g0t r00t!" 28 | echo -en '\n[' 29 | for i in $(seq 1 65); do echo -n "="; sleep 0.01; done 30 | echo -e '>]\n' 31 | sleep 0.5 32 | echo -n "root@$1:~# " 33 | sleep 60 34 | echo "" 35 | exit 0 36 | -------------------------------------------------------------------------------- /haxxor: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | --The infamous UR-COMPUTER-IS-MY-SLAVE haxxor thing 3 | function draw() 4 | nissue = { 5 | "\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[1;33m", 6 | ",~~~~~~~~~~~~~, \027[0;31m..:::::::::.. \027[1;33m ,~~~~~~~~~~~~~,\027[1;33m", 7 | "\027[1;33m:\027[1;32m .-======-,\027[1;33m : \027[0;31m ..:::\027[1;37maad8888888baa\027[0;31m:::.. \027[1;33m:\027[1;34mExploit-the \027[1;33m :\027[1;32m", 8 | "\027[1;33m:\027[1;32m ||\027[0;31mH4CK3R\027[1;32m|# \027[1;33m : \027[0;31m .::::\027[1;37md:?88888888888?::8b\027[0;31m::::. \027[1;33m :\027[0;31m.-------,./|\027[1;33m :\027[1;32m", 9 | "\027[1;33m:\027[1;32m ||______|| \027[1;33m :\027[1;34m&&&& \027[0;31m.:::\027[1;37md8888:?88888888??a888888b\027[0;31m:::. \027[1;34m &&&&\027[1;33m:\027[0;31m{ \027[1;33m VIRUS \027[0;31m /\027[1;33m :\027[1;33m", 10 | "\027[1;33m:\027[1;32m | ___ | \027[1;33m : \027[1;34m + \027[0;31m.:::\027[1;37md8888888a8888888aa8888888888b\027[0;31m:::. \027[1;34m + \027[1;33m :\027[0;31m \\\027[1;33m DROPPER\027[0;31m 7\027[1;33m :\027[1;33m", 11 | "\027[1;33m:\027[1;32m | |\027[1;35m[]\027[1;32m | | \027[1;33m : \027[1;34m &\027[0;31m::::\027[1;37mdP\027[0;31m\023\022\021\020\019\018\017\016\027[1;37m88888888888\027[0;31m\023\022\021\020\019\018\017\016\027[1;37mYb\027[0;31m::::\027[1;34m&&\027[1;33m :\027[0;31m ~. ,--.( \027[1;33m :\027[1;33m", 12 | "\027[1;33m:\027[1;32m `-------' \027[1;33m : \027[0;31m::::\027[1;37mdP\027[0;31m\024:::::::\015\027[1;37mY888888888P\027[0;31m\024:::::::\015\027[1;37mYb\027[0;31m::::\027[1;33m : \027[0;31m '~ `;\027[1;33m :\027[1;33m", 13 | "\027[1;33m:\027[0;31mReverse- \027[1;33m : \027[0;31m::::\027[1;37md8\027[0;31m\001:::::::::\014\027[1;37mY8888888P\027[0;31m\001:::::::::\014\027[1;37m8b\027[0;31m::::\027[1;33m :\027[1;34mNation's-\027[0;31mData\027[1;33m:\027[1;33m", 14 | "\027[1;33m:\027[0;31mEngineering \027[1;33m: \027[0;31m.::::\027[1;37m88\027[0;31m\002\003\004\005\006\007\008\009\010\011\012\013\027[1;37mY88888P\027[0;31m\002\003\004\005\006\007\008\009\010\011\012\013\027[1;37m88\027[0;31m::::.\027[1;33m `~~~~~~~~~~~~'\027[1;33m", 15 | "\027[1;33m `~~~~~~~~~~~~' \027[0;31m:::::\027[1;37mY8baaaaaaaaaa88P\027[0;31m:\027[1;37mT\027[0;31m:\027[1;37mY88aaaaaaaaaad8P\027[0;31m::::: \027[0;31m", 16 | "\027[0;31m :::::::\027[1;37mY88888888888P\027[0;31m::\027[1;37m|\027[0;31m::\027[1;37mY88888888888P\027[0;31m::::::: \027[0;31m", 17 | "\027[1;33m,~~~~~~~~~~~~~, \027[0;31m::::::::::::::::\027[1;37m888\027[0;31m:::\027[1;37m|\027[0;31m:::\027[1;37m888\027[0;31m::::::::::::::::\027[1;33m ,~~~~~~~~~~~~~,\027[1;33m", 18 | "\027[1;33m:\027[1;34m R00T-KITS \027[1;33m : \027[0;31m`:::::::::::::::\027[1;37m8888888888888b\027[0;31m::::::::::::::' \027[1;33m :\027[0;31mHoM3-$w33t\027[1;33m :\027[1;37m", 19 | "\027[1;33m:\027[0;31m ____ \027[1;37m __ \027[1;33m : \027[0;31m:::::::::::::::\027[1;37m88888888888888\027[0;31m:::::::::::::: \027[1;33m :\027[1;34m (I\027[1;33m :\027[1;33m", 20 | "\027[1;33m: \027[0;31m| |\027[1;37m |\027[0;31m-_\027[1;37m| \027[1;33m:\027[0;31m :::::::::::::\027[1;37md88888888888888\027[0;31m::::::::::::: \027[1;33m :\027[1;36m^^^\027[1;34m |\027[1;36m ^^^\027[1;33m:\027[1;33m", 21 | "\027[1;33m:\027[0;31m |____|\027[1;33m_\027[1;37m|\027[0;31m=_\027[1;37m|\027[1;33m :\027[0;31m ::::::::::::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m:::\027[1;37m88\027[0;31m::::::::::::\027[1;33m :\027[1;34m|u|_\027[1;36m^^^^^\027[1;34m_|u|\027[1;33m:\027[1;33m", 22 | "\027[1;33m:\027[1;37m ____\027[1;33m)\027[1;37m_\027[1;37m.\027[1;37m___\027[1;33m : \027[0;31m`::::::::::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m:::\027[1;37m88\027[0;31m::::::::::' \027[1;33m :\027[1;34m|_ u _ u _|\027[1;33m:\027[1;33m", 23 | "\027[1;33m: \027[1;37m/\027[1;34m:::::;\027[1;37m|\027[1;34m _\027[1;37m)\027[1;33m:\027[1;34m &\027[0;31m`:::::::::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m::\027[1;37mP\027[0;31m::::\027[1;37m88\027[0;31m:::::::::'\027[1;34m& \027[1;33m:\027[1;34m |__|\027[1;37m;\027[1;34m|__| \027[1;33m :\027[1;33m", 24 | "\027[1;33m:\027[1;37m `======'\027[1;34m |_|\027[1;33m: \027[1;34m+ \027[0;31m `:::::::\027[1;37m88\027[0;31m::\027[1;37m88\027[0;31m:::::::\027[1;37m88\027[0;31m:::::::' \027[1;34m + \027[1;33m :\027[1;34m /_/ \027[1;33m :\027[1;33m", 25 | "\027[1;33m:\027[1;34mUr-Computer-\027[1;33m :\027[1;34m&&&&&&& \027[0;31m ``:::::::::::::::::::::::''\027[1;34m &&&&&&&\027[1;33m:\027[0;31mH4x0r-HoM3- \027[1;33m :\027[1;33m", 26 | "\027[1;33m:\027[1;34mis-MY-\027[0;31mSlave \027[1;33m : \027[0;31m ``::::::::::::::''\027[1;33m :\027[0;31m *\027[1;37m127\027[0;31m.\027[1;37m0\027[0;31m.\027[1;37m0\027[0;31m.\027[1;37m1\027[0;31m* \027[1;33m:\027[1;33m", 27 | "\027[1;33m `~~~~~~~~~~~~' `~~~~~~~~~~~~'\027[1;33m", 28 | "\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[0;31m=\027[1;37m-\027[1;37m", 29 | "\027[0;31m -======- \027[1;37m +\027[0;31mWARNING\027[1;37m+\027[1;33m\"\027[0;31mIllegal\027[1;37m_\027[0;31mNetwork\027[1;37m_\027[0;31mConnections\027[1;37m_\027[0;31mBeyond\027[1;37m_\027[0;31mLogin\027[1;33m\" \027[0;31m -======-\027[0;31m", 30 | "\027[0;31m |\027[1;32mH\027[1;34m4\027[1;33mC\027[1;35mK\027[1;36m3\027[1;37mR\027[0;31m| \027[1;34m -== \027[1;37m You are at the point of \027[0;31mNO RETURN \027[1;34m ==- \027[0;31m |\027[1;32mH\027[1;34m4\027[1;33mC\027[1;35mK\027[1;36m3\027[1;37mR\027[0;31m|\027[0;31m", 31 | "\027[0;31m |______|\027[0;31mYour Activities\027[1;37m:\027[1;33mWill\027[1;37m_\027[1;33mbe\027[1;37m_\027[1;33mKeylogged\027[1;37m_\027[1;33mand\027[1;37m_\027[1;33mTimestamped \027[1;34m\"\027[0;31mUSER_BEWARE\027[1;34m\"\027[0;31m|______|\027[0;31m", 32 | "\027[0;31mHacking Sites\027[1;37m:\027[0;31m https\027[1;37m:\027[1;33m//\027[0;31msites\027[1;37m.\027[0;31mgoogle\027[1;37m.\027[0;31mcom\027[1;33m/\027[0;31msite\027[1;33m/\027[0;31mlazyboxx \027[1;35m*\027[0;31m http\027[1;37m:\027[1;33m//\027[0;31mwww\027[1;37m.\027[0;31mfreebsd\027[1;37m.\027[0;31morg \027[1;33m" 33 | } 34 | io.write("\027[1;1H") --reset cursor 35 | for a = 7,11 do 36 | for b = 1,24 do 37 | if b == position then 38 | nissue[a] = string.gsub(nissue[a],string.char(b),"\027[1;31m@\027[0;31m") 39 | else 40 | nissue[a] = string.gsub(nissue[a],string.char(b),":") 41 | end 42 | end 43 | end 44 | for a = 5,21 do 45 | if bool then 46 | nissue[a] = string.gsub(nissue[a],"&","\027[31;1m=\027[37;1m") 47 | nissue[a] = string.gsub(nissue[a],"+","\027[31;1m|\027[37;1m") 48 | else 49 | nissue[a] = string.gsub(nissue[a],"&","=") 50 | nissue[a] = string.gsub(nissue[a],"+","|") 51 | end 52 | end 53 | for i = 1,28 do 54 | print(nissue[i]) 55 | end 56 | bool = not bool 57 | end 58 | function changepos(num) 59 | if position == 24 and num == 1 then 60 | position = 1 61 | elseif position == 1 and num == -1 then 62 | position = 24 63 | else 64 | position = position + num 65 | end 66 | end 67 | position = 14 68 | bool = true 69 | dirs = {1,-1} 70 | draw() 71 | while true do 72 | move = math.random(1,6) 73 | dir = dirs[math.random(1,2)] 74 | draw() 75 | for m = 1,move do 76 | changepos(dir) 77 | draw() 78 | os.execute("sleep 0.1") --Replace it with some other way to wait one tenth of a second if you're using Windows or don't have "sleep" 79 | end --On the subject of Windows compatibility, Ansicon is a perfect way to make the Ansi escape codes work. 80 | end 81 | -------------------------------------------------------------------------------- /i3-focus-last: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import socket 5 | import selectors 6 | import threading 7 | from argparse import ArgumentParser 8 | import i3ipc 9 | 10 | SOCKET_FILE = '/tmp/i3_focus_last' 11 | MAX_WIN_HISTORY = 15 12 | 13 | 14 | class FocusWatcher: 15 | 16 | def __init__(self): 17 | self.i3 = i3ipc.Connection() 18 | self.i3.on('window::focus', self.on_window_focus) 19 | self.listening_socket = socket.socket(socket.AF_UNIX, 20 | socket.SOCK_STREAM) 21 | if os.path.exists(SOCKET_FILE): 22 | os.remove(SOCKET_FILE) 23 | self.listening_socket.bind(SOCKET_FILE) 24 | self.listening_socket.listen(1) 25 | self.window_list = [] 26 | self.window_list_lock = threading.RLock() 27 | 28 | def on_window_focus(self, i3conn, event): 29 | with self.window_list_lock: 30 | window_id = event.container.props.id 31 | if window_id in self.window_list: 32 | self.window_list.remove(window_id) 33 | self.window_list.insert(0, window_id) 34 | if len(self.window_list) > MAX_WIN_HISTORY: 35 | del self.window_list[MAX_WIN_HISTORY:] 36 | 37 | def launch_i3(self): 38 | self.i3.main() 39 | 40 | def launch_server(self): 41 | selector = selectors.DefaultSelector() 42 | 43 | def accept(sock): 44 | conn, addr = sock.accept() 45 | selector.register(conn, selectors.EVENT_READ, read) 46 | 47 | def read(conn): 48 | data = conn.recv(1024) 49 | if data == b'switch': 50 | with self.window_list_lock: 51 | tree = self.i3.get_tree() 52 | windows = set(w.id for w in tree.leaves()) 53 | for window_id in self.window_list[1:]: 54 | if window_id not in windows: 55 | self.window_list.remove(window_id) 56 | else: 57 | self.i3.command('[con_id=%s] focus' % window_id) 58 | break 59 | elif not data: 60 | selector.unregister(conn) 61 | conn.close() 62 | 63 | selector.register(self.listening_socket, selectors.EVENT_READ, accept) 64 | 65 | while True: 66 | for key, event in selector.select(): 67 | callback = key.data 68 | callback(key.fileobj) 69 | 70 | def run(self): 71 | t_i3 = threading.Thread(target=self.launch_i3) 72 | t_server = threading.Thread(target=self.launch_server) 73 | for t in (t_i3, t_server): 74 | t.start() 75 | 76 | if __name__ == '__main__': 77 | parser = ArgumentParser(prog='focus-last.py', 78 | description=''' 79 | Focus last focused window. 80 | 81 | This script should be launch from the .xsessionrc without argument. 82 | 83 | Then you can bind this script with the `--switch` option to one of your 84 | i3 keybinding. 85 | ''') 86 | parser.add_argument('--switch', dest='switch', action='store_true', 87 | help='Switch to the previous window', default=False) 88 | args = parser.parse_args() 89 | 90 | if not args.switch: 91 | focus_watcher = FocusWatcher() 92 | focus_watcher.run() 93 | else: 94 | client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 95 | client_socket.connect(SOCKET_FILE) 96 | client_socket.send(b'switch') 97 | client_socket.close() 98 | -------------------------------------------------------------------------------- /i3-for-window: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # https://faq.i3wm.org/question/2172/how-do-i-find-the-criteria-for-use-with-i3-config-commands-like-for_window-eg-to-force-splashscreens-and-dialogs-to-show-in-floating-mode/?answer=2174#post-id-2174 4 | 5 | # i3-get-window-criteria - Get criteria for use with i3 config commands 6 | 7 | # To use, run this script, then click on a window. 8 | # Output is in the format: [= = ...] 9 | 10 | # Known problem: when WM_NAME is used as fallback for the 'title=""' criterion, 11 | # quotes in "" are not escaped properly. This is a problem with the output of `xprop`, 12 | # reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807 13 | 14 | PROGNAME=`basename "$0"` 15 | 16 | # Check for xwininfo and xprop 17 | for cmd in xwininfo xprop; do 18 | if ! type $cmd > /dev/null 2>&1; then 19 | echo "$PROGNAME: $cmd: command not found" >&2 20 | exit 1 21 | fi 22 | done 23 | 24 | match_int='[0-9][0-9]*' 25 | match_string='".*"' 26 | match_qstring='"[^"\\]*(\\.[^"\\]*)*"' # NOTE: Adds 1 backreference 27 | 28 | { 29 | # Run xwininfo, get window id 30 | window_id=`xwininfo -int | sed -nre "s/^xwininfo: Window id: ($match_int) .*$/\1/p"` 31 | echo "id=$window_id" 32 | 33 | # Run xprop, transform its output into i3 criteria. Handle fallback to 34 | # WM_NAME when _NET_WM_NAME isn't set 35 | xprop -id $window_id | 36 | sed -nr \ 37 | -e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \ 38 | -e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \ 39 | -e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \ 40 | -e "/^_NET_WM_NAME\(UTF8_STRING\) = ($match_qstring)$/{s//title=\1/; h}" \ 41 | -e '${g; p}' 42 | } | sort | tr "\n" " " | sed -r 's/^(.*) $/[\1]\n/' 43 | -------------------------------------------------------------------------------- /imgt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # z3bra -- 2014-01-21 4 | # http://blog.z3bra.org/2014/01/images-in-terminal.html 5 | 6 | test -f "$1" || exit 1 7 | 8 | W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" 9 | FILENAME=$1 10 | FONTH=31 # Size of one terminal row 11 | FONTW=15 # Size of one terminal column 12 | COLUMNS=`tput cols` 13 | LINES=`tput lines` 14 | 15 | read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` 16 | 17 | max_width=$(($FONTW * $COLUMNS)) 18 | max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt 19 | 20 | if test $width -gt $max_width; then 21 | height=$(($height * $max_width / $width)) 22 | width=$max_width 23 | fi 24 | if test $height -gt $max_height; then 25 | width=$(($width * $max_height / $height)) 26 | height=$max_height 27 | fi 28 | 29 | w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;" 30 | 31 | clear 32 | tput cup $(($height/$FONTH)) 0 33 | echo -e $w3m_command|$W3MIMGDISPLAY 34 | echo "$(tput setaf 4)$FILENAME$(tput sgr0)" 35 | echo 36 | -------------------------------------------------------------------------------- /ix: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Uploads stdin to ix.io. 3 | 4 | curl -sfF 'f:1=<-' ix.io 5 | -------------------------------------------------------------------------------- /let-ssh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Bail on error 4 | set -e 5 | 6 | # Print in a color 7 | color() { 8 | c="$1" 9 | shift 10 | echo -e "\x1B[${c}m${@}\x1B[0m" 11 | } 12 | 13 | # Display usage 14 | print_usage () { 15 | echo 16 | echo "Usage: let-ssh [GITHUB USERNAME]..." 17 | echo 18 | } 19 | 20 | # Display help if requested 21 | while getopts h opt; do 22 | case "$opt" in 23 | *) 24 | echo "Temporarily allow SSH access by GitHub username." 25 | print_usage 26 | exit 27 | ;; 28 | esac 29 | done 30 | shift $((OPTIND - 1)) 31 | 32 | # Check for usernames 33 | if [[ $# -lt 1 ]]; then 34 | color 31 "At least one username is required." 35 | print_usage 36 | exit 1 37 | fi 38 | 39 | USERKEYS=() 40 | ERRS=false 41 | 42 | # Get user keys from GitHub 43 | for USERNAME in "$@"; do 44 | USERKEY="$(curl -s "https://github.com/$USERNAME.keys")" 45 | 46 | if [[ "$?" != 0 ]]; then 47 | color 31 "Could not connect to GitHub." 48 | exit 1 49 | elif [[ -z "$USERKEY" ]]; then 50 | color 31 "$USERNAME: has no keys in GitHub." 51 | ERRS=true 52 | elif [[ "$USERKEY" == "Not Found" ]]; then 53 | color 31 "$USERNAME: not found in GitHub." 54 | ERRS=true 55 | elif ! ssh-keygen -lf <(echo "$USERKEY") &> /dev/null; then 56 | color 31 "$USERNAME: keys are invalid." 57 | ERRS=true 58 | else 59 | color 32 "$USERNAME: keys retrieved" 60 | USERKEYS+=("$USERKEY") 61 | fi 62 | done 63 | echo 64 | 65 | [[ "$ERRS" == true ]] && exit 1 66 | 67 | USERKEYS_STR="$(printf '%s\n' "${USERKEYS[@]}")" 68 | KEYS_FILE=~/.ssh/authorized_keys 69 | 70 | # Make a backup and add the keys 71 | mkdir -p "$(dirname "$KEYS_FILE")" 72 | touch "$KEYS_FILE" 73 | cp "$KEYS_FILE" "$KEYS_FILE.bak" 74 | echo "$USERKEYS_STR" >> "$KEYS_FILE" 75 | 76 | teardown() { 77 | local DEAUTHED="$(grep -vFf <(echo "$USERKEYS_STR") "$KEYS_FILE")" 78 | echo "$DEAUTHED" > "$KEYS_FILE" 79 | echo 80 | echo 81 | } 82 | trap "teardown; exit 0" SIGHUP SIGINT SIGTERM 83 | 84 | echo "Authorized keys for GitHub users:" 85 | printf ' %s\n' "$@" 86 | echo "Your local IP is $(ipconfig getifaddr en0)." 87 | echo "A backup of $KEYS_FILE" 88 | echo "is stored at $KEYS_FILE.bak." 89 | echo "Press ^C to deauthorize and exit." 90 | 91 | sleep infinity & 92 | wait 93 | -------------------------------------------------------------------------------- /letsencrypt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Updates letsencrypt domains by nginx vhost server_name. 3 | # 4 | # Author: metakirby5 5 | 6 | LE_BIN='/opt/letsencrypt/letsencrypt-auto' 7 | NGINX_ROOT='/etc/nginx/' 8 | domains=$(grep -hro '^\s*server_name\(\s\+[a-zA-Z0-9.-]\+\)\+' "$NGINX_ROOT" | 9 | awk '{ $1 = ""; print $0 }' | tr '[:space:]' '\n' | 10 | awk '{ print length($0), $0 }' | sort -n | 11 | uniq | cut -d ' ' -f 2-) 12 | 13 | echo "Running \"$LE_BIN\" for vhosts found in \"$NGINX_ROOT\":" 14 | echo "$domains" 15 | echo 16 | 17 | "$LE_BIN" certonly -a webroot --webroot-path=/var/www/ssl \ 18 | $(xargs printf ' -d %s' <<< "$domains") 19 | -------------------------------------------------------------------------------- /lightsOn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # lightsOn.sh 3 | 4 | # Copyright (c) 2013 iye.cba at gmail com 5 | # url: https://github.com/iye/lightsOn 6 | # This script is licensed under GNU GPL version 2.0 or above 7 | 8 | # Description: Bash script that prevents the screensaver and display power 9 | # management (DPMS) to be activated when you are watching Flash Videos 10 | # fullscreen on Firefox and Chromium. 11 | # Can detect mplayer, minitube, and VLC when they are fullscreen too. 12 | # Also, screensaver can be prevented when certain specified programs are running. 13 | # lightsOn.sh needs xscreensaver or kscreensaver to work. 14 | 15 | 16 | # HOW TO USE: Start the script with the number of seconds you want the checks 17 | # for fullscreen to be done. Example: 18 | # "./lightsOn.sh 120 &" will Check every 120 seconds if Mplayer, Minitube 19 | # VLC, Firefox or Chromium are fullscreen and delay screensaver and Power Management if so. 20 | # You want the number of seconds to be ~10 seconds less than the time it takes 21 | # your screensaver or Power Management to activate. 22 | # If you don't pass an argument, the checks are done every 50 seconds. 23 | # 24 | # An optional array variable exists here to add the names of programs that will delay the screensaver if they're running. 25 | # This can be useful if you want to maintain a view of the program from a distance, like a music playlist for DJing, 26 | # or if the screensaver eats up CPU that chops into any background processes you have running, 27 | # such as realtime music programs like Ardour in MIDI keyboard mode. 28 | # If you use this feature, make sure you use the name of the binary of the program (which may exist, for instance, in /usr/bin). 29 | 30 | 31 | # Modify these variables if you want this script to detect if Mplayer, 32 | # VLC, Minitube, or Firefox or Chromium Flash Video are Fullscreen and disable 33 | # xscreensaver/kscreensaver and PowerManagement. 34 | mplayer_detection=1 35 | vlc_detection=1 36 | firefox_flash_detection=1 37 | chromium_flash_detection=1 38 | minitube_detection=1 39 | 40 | # Names of programs which, when running, you wish to delay the screensaver. 41 | delay_progs=('mpv') # For example ('ardour2' 'gmpc') 42 | 43 | 44 | # YOU SHOULD NOT NEED TO MODIFY ANYTHING BELOW THIS LINE 45 | 46 | 47 | # enumerate all the attached screens 48 | displays="" 49 | while read id 50 | do 51 | displays="$displays $id" 52 | done < <(xvinfo | sed -n 's/^screen #\([0-9]\+\)$/\1/p') 53 | 54 | # Detect screensaver been used (xscreensaver, kscreensaver, gnome-screensaver or none) 55 | if [ `pgrep -l xscreensaver | grep -wc xscreensaver` -ge 1 ];then 56 | screensaver=xscreensaver 57 | elif [ `pgrep -l gnome-screensav | grep -wc gnome-screensav` -ge 1 ];then 58 | screensaver=gnome-screensav 59 | elif [ `pgrep -l kscreensaver | grep -wc kscreensaver` -ge 1 ];then 60 | screensaver=kscreensaver 61 | elif [ `pgrep -l xautolock | grep -wc xautolock` -ge 1 ];then 62 | screensaver=xautolock 63 | else 64 | screensaver=None 65 | echo "No screensaver detected" 66 | fi 67 | 68 | checkDelayProgs() 69 | { 70 | for prog in "${delay_progs[@]}"; do 71 | if [ `pgrep -lfc "$prog"` -ge 1 ]; then 72 | echo "Delaying the screensaver because a program on the delay list, \"$prog\", is running..." 73 | delayScreensaver 74 | break 75 | fi 76 | done 77 | } 78 | 79 | checkFullscreen() 80 | { 81 | # loop through every display looking for a fullscreen window 82 | for display in $displays 83 | do 84 | #get id of active window and clean output 85 | activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW` 86 | #activ_win_id=${activ_win_id#*# } #gives error if xprop returns extra ", 0x0" (happens on some distros) 87 | activ_win_id=${activ_win_id:40:9} 88 | 89 | # Skip invalid window ids (commented as I could not reproduce a case 90 | # where invalid id was returned, plus if id invalid 91 | # isActivWinFullscreen will fail anyway.) 92 | #if [ "$activ_win_id" = "0x0" ]; then 93 | # continue 94 | #fi 95 | 96 | # Check if Active Window (the foremost window) is in fullscreen state 97 | isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN` 98 | if [[ "$isActivWinFullscreen" = *NET_WM_STATE_FULLSCREEN* ]];then 99 | isAppRunning 100 | var=$? 101 | if [[ $var -eq 1 ]];then 102 | delayScreensaver 103 | fi 104 | fi 105 | done 106 | } 107 | 108 | 109 | 110 | 111 | 112 | # check if active windows is mplayer, vlc or firefox 113 | #TODO only window name in the variable activ_win_id, not whole line. 114 | #Then change IFs to detect more specifically the apps "" and if process name exist 115 | 116 | isAppRunning() 117 | { 118 | #Get title of active window 119 | activ_win_title=`xprop -id $activ_win_id | grep "WM_CLASS(STRING)"` # I used WM_NAME(STRING) before, WM_CLASS more accurate. 120 | 121 | 122 | 123 | # Check if user want to detect Video fullscreen on Firefox, modify variable firefox_flash_detection if you dont want Firefox detection 124 | if [ $firefox_flash_detection == 1 ];then 125 | if [[ "$activ_win_title" = *unknown* || "$activ_win_title" = *plugin-container* ]];then 126 | # Check if plugin-container process is running 127 | flash_process=`pgrep -l plugin-containe | grep -wc plugin-containe` 128 | #(why was I using this line avobe? delete if pgrep -lc works ok) 129 | #flash_process=`pgrep -lc plugin-containe` 130 | if [[ $flash_process -ge 1 ]];then 131 | return 1 132 | fi 133 | fi 134 | fi 135 | 136 | 137 | # Check if user want to detect Video fullscreen on Chromium, modify variable chromium_flash_detection if you dont want Chromium detection 138 | if [ $chromium_flash_detection == 1 ];then 139 | if [[ "$activ_win_title" = *exe* ]];then 140 | # Check if Chromium/Chrome Flash process is running 141 | flash_process=`pgrep -lfc ".*((c|C)hrome|chromium).*flashp.*"` 142 | if [[ $flash_process -ge 1 ]];then 143 | return 1 144 | fi 145 | fi 146 | fi 147 | 148 | 149 | #check if user want to detect mplayer fullscreen, modify variable mplayer_detection 150 | if [ $mplayer_detection == 1 ];then 151 | if [[ "$activ_win_title" = *mplayer* || "$activ_win_title" = *MPlayer* ]];then 152 | #check if mplayer is running. 153 | #mplayer_process=`pgrep -l mplayer | grep -wc mplayer` 154 | mplayer_process=`pgrep -lc mplayer` 155 | if [ $mplayer_process -ge 1 ]; then 156 | return 1 157 | fi 158 | fi 159 | fi 160 | 161 | 162 | # Check if user want to detect vlc fullscreen, modify variable vlc_detection 163 | if [ $vlc_detection == 1 ];then 164 | if [[ "$activ_win_title" = *vlc* ]];then 165 | #check if vlc is running. 166 | #vlc_process=`pgrep -l vlc | grep -wc vlc` 167 | vlc_process=`pgrep -lc vlc` 168 | if [ $vlc_process -ge 1 ]; then 169 | return 1 170 | fi 171 | fi 172 | fi 173 | 174 | # Check if user want to detect minitube fullscreen, modify variable minitube_detection 175 | if [ $minitube_detection == 1 ];then 176 | if [[ "$activ_win_title" = *minitube* ]];then 177 | #check if minitube is running. 178 | #minitube_process=`pgrep -l minitube | grep -wc minitube` 179 | minitube_process=`pgrep -lc minitube` 180 | if [ $minitube_process -ge 1 ]; then 181 | return 1 182 | fi 183 | fi 184 | fi 185 | 186 | return 0 187 | } 188 | 189 | 190 | delayScreensaver() 191 | { 192 | 193 | # reset inactivity time counter so screensaver is not started 194 | if [ "$screensaver" == "xscreensaver" ]; then 195 | xscreensaver-command -deactivate > /dev/null 196 | elif [ "$screensaver" == "kscreensaver" ]; then 197 | qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity > /dev/null 198 | fi 199 | 200 | # wiggle mouse just in case 201 | xdotool mousemove --sync 9999 9999 \ 202 | mousemove restore 203 | 204 | #Check if DPMS is on. If it is, deactivate and reactivate again. If it is not, do nothing. 205 | dpmsStatus=`xset -q | grep -ce 'DPMS is Enabled'` 206 | if [ $dpmsStatus == 1 ];then 207 | xset -dpms 208 | xset dpms 209 | fi 210 | 211 | } 212 | 213 | 214 | 215 | delay=$1 216 | 217 | 218 | # If argument empty, use 50 seconds as default. 219 | if [ -z "$1" ];then 220 | delay=50 221 | fi 222 | 223 | 224 | # If argument is not integer quit. 225 | if [[ $1 = *[^0-9]* ]]; then 226 | echo "The Argument \"$1\" is not valid, not an integer" 227 | echo "Please use the time in seconds you want the checks to repeat." 228 | echo "You want it to be ~10 seconds less than the time it takes your screensaver or DPMS to activate" 229 | exit 1 230 | fi 231 | 232 | 233 | while true 234 | do 235 | checkDelayProgs 236 | checkFullscreen 237 | sleep $delay 238 | done 239 | 240 | 241 | exit 0 242 | -------------------------------------------------------------------------------- /mkgif: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Creates a gif using ffmpeg 3 | # 4 | # Author: metakirby5 5 | 6 | usage() { 7 | echo "USAGE: $(basename "$0") [src] [dest] (width)" 8 | exit 1 9 | } 10 | 11 | # Sanity checks 12 | [ "$#" -lt 2 ] && usage 13 | 14 | palette="$(mktemp).png" 15 | width="${3:-iw*0.5}" 16 | 17 | ffmpeg -i "$1" -vf "fps=10,scale=$width:-1:flags=lanczos,palettegen" \ 18 | "$palette" 19 | 20 | ffmpeg -i "$1" -i "$palette" -filter_complex \ 21 | "fps=10,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" \ 22 | -loop 0 "$2" 23 | 24 | rm "$palette" 25 | -------------------------------------------------------------------------------- /mobile-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Install a build on a mobile device. 3 | # Automatically detects whether it's iOS or Android. 4 | # 5 | # Author: metakirby5 6 | 7 | checkdep() { 8 | type "$1" &>/dev/null || echo " $1" 9 | } 10 | 11 | missing="$(checkdep adb)$(checkdep ideviceinstaller)" 12 | [ "$missing" ] && fail "The following dependencies are missing:$missing" 13 | 14 | usage() { 15 | echo "USAGE: ${0##*/} [file]" 16 | echo 17 | echo " Install a build on a mobile device." 18 | echo " Automatically detects whether it's iOS or Android." 19 | echo 20 | exit 1 21 | } 22 | 23 | [ "$#" -ne 1 ] && usage 24 | 25 | ext="${1##*.}" 26 | case "$ext" in 27 | apk) 28 | adb install -r -d "$1" 29 | ;; 30 | ipa) 31 | ideviceinstaller -i "$1" 32 | ;; 33 | *) 34 | echo "Unable to handle extension $ext." 35 | ;; 36 | esac 37 | -------------------------------------------------------------------------------- /mpc-art: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Display album art in term, auto-change on song change. 3 | # Note that this will make your cursor invisible. Restore with `tput cnorm`. 4 | # 5 | # Author: metakirby5 6 | 7 | CHARHEIGHT=31 8 | CHARWIDTH=15 9 | PAD=0 10 | 11 | ALBUM_ART="$(mktemp).png" 12 | NO_ART="$(mktemp).png" 13 | convert -size 1 xc:transparent "$NO_ART" 14 | 15 | put_art() { 16 | rm "$ALBUM_ART" &>/dev/null 17 | 18 | # Get album art 19 | ffmpeg -y -i "${XDG_MUSIC_DIR%%/}/$(mpc current --format '%file%')" \ 20 | "$ALBUM_ART" 2>/dev/null 21 | } 22 | 23 | display_art() { 24 | local win_width="$(($(tput cols) * $CHARWIDTH))" 25 | local win_height="$(($(tput lines) * $CHARHEIGHT))" 26 | local width="$(($win_width - 2 * $PAD))" 27 | local height="$(($win_height - 2 * $PAD))" 28 | local size="$(($width < $height ? $width : $height))" 29 | local x="$((($width - $size) / 2 + $PAD))" 30 | local y="$((($height - $size) / 2 + $PAD))" 31 | 32 | # Clears the screen 33 | clear 34 | printf "0;1;;;$win_width;$win_height;;;;;$NO_ART\n4;\n3;" |\ 35 | /usr/lib/w3m/w3mimgdisplay 36 | 37 | printf "0;1;$x;$y;$size;$size;;;;;$ALBUM_ART\n4;\n3;" |\ 38 | /usr/lib/w3m/w3mimgdisplay 39 | } 40 | 41 | # Initial display 42 | clear 43 | tput civis 44 | put_art && display_art 45 | 46 | # Connect to socket 47 | exec 3<> /dev/tcp/localhost/6600 48 | last="$(mpc current)" 49 | 50 | # Enter message loop 51 | while read -u3 msg; do 52 | # If we got an OK 53 | if [[ "$msg" == OK* ]]; then 54 | # Check if the song changed 55 | song="$(mpc current)" 56 | 57 | if [[ "$song" != "$last" ]]; then 58 | put_art 59 | display_art 60 | fi 61 | 62 | last="$song" 63 | 64 | # Listen for next change 65 | echo 'idle player playlist' >&3 66 | fi 67 | done & 68 | 69 | # Also display on screen size change 70 | prev_width="$(tput cols)" 71 | prev_height="$(tput lines)" 72 | while true; do 73 | width="$(tput cols)" 74 | height="$(tput lines)" 75 | [[ "$width" != "$prev_width" || "$height" != "$prev_height" ]] \ 76 | && display_art 77 | prev_width="$width" 78 | prev_height="$height" 79 | sleep 1 80 | done & 81 | 82 | # Also display on keypress 83 | while read -rsn1; do 84 | display_art 85 | done 86 | -------------------------------------------------------------------------------- /mpc-notify: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Sends a dunstify notification with information from mpc -f. 3 | # Adapted from https://bbs.archlinux.org/viewtopic.php?pid=684807#p684807 4 | # 5 | # Author: metakirby5 6 | 7 | DUNSTIFY_ID="/tmp/mpc-notify_dunstify_id" 8 | ALBUM_ART="$(mktemp).png" 9 | ALBUM_ART_WIDTH="125" 10 | FMT_SUMMARY="[%title%]|[%file%]" 11 | FMT_BODY="[[%artist% - ]&%album%]|[%artist%]|[%album%]" 12 | 13 | mpc_format() { 14 | args=("$@") 15 | mpc -f "${args[0]}" current 16 | } 17 | 18 | # Get album art 19 | ffmpeg -y -i "${XDG_MUSIC_DIR%%/}/$(mpc current --format '%file%')" \ 20 | "$ALBUM_ART" 2>/dev/null &&\ 21 | mogrify -resize "$ALBUM_ART_WIDTH" "$ALBUM_ART" 22 | 23 | # Get the dunstify id 24 | [ ! -z "$(cat "$DUNSTIFY_ID")" ] && id_arg="-r $(cat "$DUNSTIFY_ID")" 25 | 26 | summary="$(mpc_format "$FMT_SUMMARY")" 27 | body="$(mpc_format "$FMT_BODY")" 28 | 29 | # Summary/body can't start w/ - 30 | summary="${summary/#-/−}" 31 | body="${body/#-/−}" 32 | 33 | dunstify \ 34 | -a "ncmpcpp" \ 35 | -i "$ALBUM_ART" \ 36 | -p $id_arg > "$DUNSTIFY_ID" \ 37 | "${summary:=no tunes}" "$body" 38 | 39 | -------------------------------------------------------------------------------- /mpc-notify-daemon: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Daemon for mpc-notify. 3 | # 4 | # Author: metakirby5 5 | 6 | # Connect to socket 7 | exec 3<> /dev/tcp/localhost/6600 8 | 9 | last="$(mpc current)" 10 | 11 | # Enter message loop 12 | while read -u3 msg; do 13 | # If we got an OK 14 | if [[ "$msg" == OK* ]]; then 15 | # Check if the song changed 16 | song="$(mpc current)" 17 | [[ "$song" != "$last" ]] && mpc-notify 18 | last="$song" 19 | 20 | # Listen for next change 21 | echo 'idle player playlist' >&3 22 | fi 23 | done 24 | 25 | -------------------------------------------------------------------------------- /mpdswap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Swaps between mpd and mopidy. 3 | # 4 | # Author: metakirby5 5 | 6 | if pgrep -x mpd &>/dev/null; then 7 | echo "Starting mopidy..." 8 | killall mpd 9 | sleep 0.5 10 | mopidy &>/dev/null & 11 | elif pgrep -x mopidy &>/dev/null; then 12 | echo "Starting mpd..." 13 | killall mopidy 14 | sleep 0.5 15 | mpd &>/dev/null & 16 | else # default to mpd 17 | echo "No mpd-like daemons running, starting mpd..." 18 | mpd &>/dev/null & 19 | fi 20 | 21 | sleep 0.5 22 | startbar &>/dev/null 23 | 24 | -------------------------------------------------------------------------------- /multitest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # multitest 4 | # Author: Ethan Chan 5 | # Date: 2/6/14 6 | # 7 | # A script to test multiple input sets and arg sets for coding assignments. 8 | 9 | # -o | -e 10 | case "$1" in 11 | -o) 12 | flags="$flags -o" 13 | shift 14 | ;; 15 | -e) 16 | flags="$flags -e" 17 | shift 18 | ;; 19 | esac 20 | 21 | # Input sets 22 | while [[ ! -x "$1" && $# -gt 0 ]]; do 23 | input="$1 $input" 24 | shift 25 | done 26 | 27 | if [[ $# -lt 3 ]]; then 28 | echo 29 | echo "tester's all test cases found in provided files, with provided inputs." 30 | echo "Usage: $(basename "$0") (-o | -e) (input sets) [local prog] [solution prog] [arg sets]" 31 | echo " -o -- only test stdout" 32 | echo " -e -- only test stderr" 33 | echo 34 | exit 1 35 | fi 36 | 37 | make 38 | 39 | # Progs 40 | loc=$1 41 | shift 42 | sol=$1 43 | shift 44 | 45 | # Arg sets 46 | while [[ $# -gt 0 ]]; do 47 | if [[ -f $1 ]]; then 48 | while read line; do 49 | if [[ `echo $line | grep -v ^//` ]]; then 50 | if [[ $input ]]; then 51 | for i in $input; do 52 | eval "tester$flags $i $loc $sol $line" 53 | done 54 | else 55 | eval "tester$flags $loc $sol $line" 56 | fi 57 | fi 58 | done < $1 59 | else 60 | echo 61 | echo "File $1 not found!" 62 | fi 63 | shift 64 | done 65 | 66 | echo 67 | -------------------------------------------------------------------------------- /pipes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | declare -i f=75 s=13 r=2000 t=0 c=1 n=0 l=0 4 | declare -ir w=$(tput cols) h=$(tput lines) 5 | declare -i x=$((w/2)) y=$((h/2)) 6 | declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93" 7 | [10]="\x9b" [11]="\x81" [12]="\x93" 8 | [21]="\x97" [22]="\x83" [23]="\x9b" 9 | [30]="\x97" [32]="\x8f" [33]="\x81" ) 10 | 11 | OPTIND=1 12 | while getopts "f:s:r:h" arg; do 13 | case $arg in 14 | f) ((f=($OPTARG>19 && $OPTARG<101)?$OPTARG:$f));; 15 | s) ((s=($OPTARG>4 && $OPTARG<16 )?$OPTARG:$s));; 16 | r) ((r=($OPTARG>0)?$OPTARG:$r));; 17 | h) echo -e "Usage: pipes [OPTION]..." 18 | echo -e "Animated pipes terminal screensaver.\n" 19 | echo -e " -f [20-100]\tframerate (D=75)." 20 | echo -e " -s [5-15]\tprobability of a straight fitting (D=13)." 21 | echo -e " -r LIMIT\treset after x characters (D=2000)." 22 | echo -e " -h\t\thelp (this screen).\n" 23 | exit 0;; 24 | esac 25 | done 26 | 27 | tput smcup 28 | tput reset 29 | tput civis 30 | while true; do 31 | # New position: 32 | (($l%2)) && ((x+=($l==1)?1:-1)) 33 | ((!($l%2))) && ((y+=($l==2)?1:-1)) 34 | 35 | # Loop on edges (change color on loop): 36 | ((c=($x>$w || $x<0 || $y>$h || $y<0)?($RANDOM%7):$c)) 37 | ((x=($x>$w)?0:(($x<0)?$w:$x))) 38 | ((y=($y>$h)?0:(($y<0)?$h:$y))) 39 | 40 | # New random direction: 41 | ((n=$RANDOM%$s-1)) 42 | ((n=($n>1||$n==0)?$l:$l+$n)) 43 | ((n=($n<0)?3:$n%4)) 44 | 45 | # Print: 46 | tput cup $y $x 47 | printf "\033[1;3${c}m\xe2\x94${v[$l$n]}" 48 | (($t>$r)) && tput reset && tput civis && t=0 || ((t++)) && sleep .01 49 | l=$n 50 | done 51 | tput rmcup 52 | clear 53 | -------------------------------------------------------------------------------- /ptpb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # ptpb client. 3 | # 4 | # Author: metakirby5 5 | 6 | usage() { 7 | echo "Usage:" 8 | echo " ptpb [-h] [-o] [-u] [-p] [-s SECONDS] [-v VANITY] [FILE]" 9 | echo 10 | echo "If FILE is not provided, stdin is used." 11 | echo 12 | echo "Options:" 13 | echo " -h help" 14 | echo " -o output url only" 15 | echo " -u shorten url" 16 | echo " -p private" 17 | echo " -s seconds to expire" 18 | echo " -v vanity" 19 | echo 20 | exit 1 21 | } 22 | 23 | o= 24 | u= 25 | p= 26 | s= 27 | v= 28 | extra= 29 | while getopts 'houps:v:' opt; do 30 | case $opt in 31 | o) 32 | o="?r=1" 33 | extra="$extra -w %{redirect_url} -o /dev/null" 34 | ;; 35 | u) 36 | u="u" 37 | ;; 38 | p) 39 | extra="$extra -F p=1" 40 | ;; 41 | s) 42 | extra="$extra -F s=$OPTARG" 43 | ;; 44 | v) 45 | v="~$OPTARG" 46 | ;; 47 | h|?) 48 | usage 49 | ;; 50 | esac 51 | done 52 | 53 | if [ "$u" -a "$v" ]; then 54 | echo "ERROR: Vanity shortened urls not supported." 55 | echo 56 | usage 57 | fi 58 | 59 | shift $((OPTIND-1)) 60 | curl -sF "c=@${1:--}" "https://ptpb.pw/$u$v$o"$extra 61 | -------------------------------------------------------------------------------- /pullc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # pullc 4 | # Author: Ethan Chan 5 | # Date: 5/5/14 6 | # 7 | # A script to pull my git-maintained configs. 8 | 9 | # Pulls the directory provided as arg 1. 10 | pull_dir() { 11 | if [[ -d $1 ]]; then 12 | if [[ -d $1/.git ]]; then 13 | cd $1 14 | else 15 | echo "ERROR: $1 is not a git repository" 16 | echo 17 | errors="$errors $1" 18 | return 19 | fi 20 | else 21 | echo "ERROR: $1 is not a directory" 22 | echo 23 | errors="$errors $1" 24 | return 25 | fi 26 | 27 | echo "===Pulling $1..." 28 | git pull 29 | echo 30 | } 31 | 32 | echo 33 | 34 | IFS=':' read -ra PATHS <<< "$UPDATEC_PATH" 35 | for path in ${PATHS[@]}; do 36 | pull_dir "$path" 37 | done 38 | 39 | if [[ $errors ]]; then 40 | echo "!!! FAILED TO PULL:$errors" 41 | echo 42 | fi 43 | -------------------------------------------------------------------------------- /pushc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # pushc 4 | # Author: Ethan Chan 5 | # Date: 5/5/14 6 | # 7 | # A script to push my git-maintained configs. 8 | 9 | # Pushes the directory provided as arg 1. 10 | push_dir() { 11 | if [[ -d $1 ]]; then 12 | if [[ -d $1/.git ]]; then 13 | cd $1 14 | else 15 | echo "ERROR: $1 is not a git repository" 16 | echo 17 | errors="$errors $1" 18 | return 19 | fi 20 | else 21 | echo "ERROR: $1 is not a directory" 22 | echo 23 | errors="$errors $1" 24 | return 25 | fi 26 | 27 | echo "===Pushing $1..." 28 | if [[ $(git diff) ]] || [[ $(git log origin/master..HEAD) ]]; then 29 | git status 30 | echo 31 | if [[ $(git diff) ]]; then 32 | echo "Please enter commit message." 33 | read cmsg 34 | if [[ $cmsg ]]; then 35 | echo 36 | git commit -a -m "$cmsg" 37 | else 38 | echo "ERROR: No commit message entered." 39 | echo 40 | errors="$errors $1" 41 | return 42 | fi 43 | fi 44 | git push 45 | else 46 | echo "No updates to be made in $1." 47 | fi 48 | echo 49 | } 50 | 51 | echo 52 | 53 | IFS=':' read -ra PATHS <<< "$UPDATEC_PATH" 54 | for path in ${PATHS[@]}; do 55 | push_dir "$path" 56 | done 57 | 58 | if [[ $errors ]]; then 59 | echo "!!! FAILED TO PUSH:$errors" 60 | echo 61 | fi 62 | -------------------------------------------------------------------------------- /random-ix-io: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | key=$(cat /dev/urandom | tr -dc a-zA-Z0-9 | head -c2) 4 | url="http://ix.io/$key" 5 | 6 | echo "Random snippet brought to you by $url" 7 | echo 8 | curl "$url" 2>/dev/null | fold | head 9 | echo 10 | echo '...' 11 | -------------------------------------------------------------------------------- /relink-dots: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Relinks configs from source folders to a destination folder. 3 | # 4 | # DEPRECATED! I use GNU Stow now. 5 | # 6 | # Author: metakirby5 7 | 8 | ### CONFIG 9 | 10 | # Base directory to link from 11 | BASE_DIR=~/.dots 12 | 13 | # Associative array: to link -> real 14 | declare -A TO_LINK 15 | TO_LINK=( 16 | [home]=~ 17 | ) 18 | 19 | # Files to ignore 20 | IGNORE=( 21 | *.swp 22 | ) 23 | 24 | ### SCRIPT 25 | 26 | # Set newline delimiter in for loops 27 | IFS=$'\n' 28 | 29 | # Check for directory existence 30 | if [ ! -d "$BASE_DIR" ]; then 31 | echo "Base directory $BASE_DIR does not exist!" 32 | exit 1 33 | fi 34 | 35 | for key in "${!TO_LINK[@]}"; do 36 | 37 | # Get the path of the next directory to link 38 | dir="${BASE_DIR%%/}/$key" 39 | dir="${dir%%/}/" 40 | 41 | # Check for directory existence 42 | if [ ! -d "$dir" ]; then 43 | echo "To link directory $dir does not exist! Skipping..." 44 | continue 45 | fi 46 | 47 | # To save directories to link 48 | linkdirs=() 49 | 50 | # Print summary 51 | echo 52 | echo "LINKING: $dir -> ${TO_LINK[$key]}" 53 | echo 54 | 55 | # If directory contained ._linkdir, save for later 56 | # and ignore further matches to directory 57 | for src in `find $dir | grep "/\._linkdir$"`; do 58 | linkdir="${src%%/._linkdir}" 59 | linkdirs+=("$linkdir") 60 | IGNORE+=("$linkdir*") 61 | echo " $linkdir DIRECT LINK" 62 | echo 63 | done 64 | 65 | for src in `find $dir`; do 66 | 67 | # Skip things in ignore 68 | skip=false 69 | for pat in "${IGNORE[@]}"; do 70 | [[ "$src" == $pat ]] && skip=true 71 | done 72 | [ "$skip" = true ] && continue 73 | 74 | # Attach the value to the filename 75 | dest="${TO_LINK[$key]%%/}/${src##$dir}" 76 | 77 | # Skip directories 78 | [ -d "$dest" ] && continue 79 | 80 | echo " $src ->" 81 | echo " $dest" 82 | echo 83 | done 84 | 85 | # Ask for confirmation 86 | read -r -p " Are you sure? [y/N] " response 87 | case "$response" in 88 | [yY][eE][sS]|[yY]) 89 | echo " Proceeding..." 90 | ;; 91 | *) # Skip 92 | echo " Skipping..." 93 | echo 94 | continue 95 | ;; 96 | esac 97 | 98 | # Do the linking 99 | for src in `find $dir`; do 100 | 101 | # Skip things in ignore 102 | skip=false 103 | for pat in "${IGNORE[@]}"; do 104 | [[ "$src" == $pat ]] && skip=true 105 | done 106 | [ "$skip" = true ] && continue 107 | 108 | # Attach the value to the filename 109 | dest="${TO_LINK[$key]%%/}/${src##$dir}" 110 | 111 | # Skip directories 112 | [ -d "$src" ] && continue 113 | 114 | # Extract the directory name 115 | dest_dir="$(dirname $dest)" 116 | mkdir -p "$dest_dir" 117 | cd "$dest_dir" 118 | 119 | # Remove and link 120 | rm "$dest" 2>/dev/null 121 | ln -s "$src" 122 | done 123 | 124 | # Handle linkdirs 125 | for linkdir in "${linkdirs[@]}"; do 126 | 127 | # Attach the value to the linkdir 128 | dest="${TO_LINK[$key]%%/}/${linkdir##$dir}" 129 | 130 | # Remove and link 131 | rm -rf "$dest" 2>/dev/null 132 | cd "$(dirname "$dest")" 133 | ln -s "$linkdir" 134 | done 135 | 136 | echo " Done!" 137 | echo 138 | done 139 | -------------------------------------------------------------------------------- /reload-chrome-theme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Assumes you have chrome open and a reasonably fast computer... 3 | # This script is disgusting. 4 | # 5 | # Author: metakirby5 6 | 7 | google-chrome &>/dev/null 8 | 9 | chrome="$(xdotool getactivewindow)" 10 | 11 | xdotool key -window "$chrome" \ 12 | ctrl+l c h r o m e colon slash slash e x t e n s i o n s Return 13 | 14 | # Wait for page to load 15 | sleep 1 16 | 17 | xdotool key -window "$chrome" \ 18 | Tab Tab Return 19 | 20 | # Wait for dialog to load 21 | sleep 0.2 22 | 23 | dialog="$(xdotool getactivewindow)" 24 | 25 | xdotool mousemove --window "$dialog" 100 260 click 1 26 | 27 | xdotool key -window "$dialog" \ 28 | ctrl+a asciitilde slash period w h i z k e r s underscore o u t p u t \ 29 | slash c h r o m e underscore t h e m e slash Return 30 | 31 | # Wait for dialog to close 32 | sleep 0.2 33 | 34 | # Close the window 35 | xdotool key -window "$chrome" ctrl+w 36 | -------------------------------------------------------------------------------- /reload-desktop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Reload the desktop. 3 | # 4 | # Author: metakirby5 5 | 6 | killall compton dunst 7 | 8 | i3-msg 'restart' &>/dev/null & 9 | compton &>/dev/null & 10 | dunst &>/dev/null & 11 | 12 | xrdb -merge ~/.Xresources &>/dev/null & 13 | tmux source-file ~/.tmux.conf &>/dev/null & 14 | 15 | # Reload colors, fonts, etc. 16 | for pts in /dev/pts/*; do 17 | (echo -n "$(use-xresources < ~/.Xresources)" > $pts) 2>/dev/null & 18 | done & 19 | 20 | # GTK 21 | oomox whizkers &>/dev/null && gtkrc-reload &>/dev/null & 22 | 23 | # Chrome 24 | make-chrome-theme-images &>/dev/null & 25 | 26 | -------------------------------------------------------------------------------- /resize-video: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Uses settings from "screencast" 3 | # 4 | # Author: metakirby5 5 | 6 | usage() { 7 | echo "USAGE: $(basename "$0") [src] [dest] (height) (qmax)" 8 | exit 1 9 | } 10 | 11 | # Sanity checks 12 | [ "$#" -lt 2 ] && usage 13 | 14 | NUM_CORES=$(nproc || gnproc) 15 | 16 | ffmpeg -i "$1" -vf scale=-1:${3:-900} -c:v libvpx -qmin 1 -qmax ${4:-10} \ 17 | -an -threads $NUM_CORES -slices 8 -auto-alt-ref 1 -lag-in-frames 16 \ 18 | -f webm "$2" 19 | -------------------------------------------------------------------------------- /runall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # I think this is a poor man's xargs, I don't really remember. 3 | # 4 | # Author: metakirby5 5 | 6 | if [[ "$#" -lt 3 || "$#" -gt 4 ]]; then 7 | echo "Usage: $(basename "$0") [program] [base dir] [inputs] (done extension)" 8 | exit 0 9 | fi 10 | 11 | program=$1 12 | basedir="${2%/}/" 13 | inputs=$3 14 | ext=$4 15 | 16 | if [[ ! -d "$basedir" ]]; then 17 | echo "Base directory \"$basedir\" not a directory!" 18 | error=1 19 | fi 20 | 21 | if [[ ! -f "$inputs" ]]; then 22 | echo "Inputs \"$inputs\" not found!" 23 | error=1 24 | fi 25 | 26 | if [[ "$error" ]]; then 27 | echo "Exiting due to error(s)..." 28 | exit $error 29 | fi 30 | 31 | while read -r line; do 32 | file="$basedir$line" 33 | if [[ ! -f "$file" ]]; then 34 | echo "=== File \"$file\" not found! Skipping..." 35 | elif [[ "$ext" && -f "$file$ext" ]]; then 36 | echo "=== Completed file \"$file$ext\" found! Skipping..." 37 | else 38 | cmd="$program $file" 39 | read -p "====== Run \"$cmd\"? [y/n]: " -n 1 run < /dev/tty 40 | wait 41 | echo 42 | if [[ ! "$run" =~ [yY] ]]; then 43 | echo "=== Skipped \"$cmd\"." 44 | else 45 | echo "=== Running \"$cmd\"..." 46 | $cmd < /dev/tty 47 | wait 48 | fi 49 | fi 50 | done < $inputs 51 | 52 | echo "All files run!" 53 | -------------------------------------------------------------------------------- /scget: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Downloads a SoundCloud track, then applies these id3 tags: 3 | # Title 4 | # Artist 5 | # Art 6 | # 7 | # Dependencies: curl, grep, jq 8 | # 9 | # Required environment variables: 10 | # $SC_CLIENT: SoundCloud API client ID. 11 | # 12 | # Author: metakirby5 13 | 14 | checkdep() { 15 | type "$1" &>/dev/null || echo " $1" 16 | } 17 | 18 | missing="$(checkdep curl)$(checkdep grep)$(checkdep jq)" 19 | if [ "$missing" ]; then 20 | echo "The following dependencies are missing:$missing" 21 | exit 1 22 | fi 23 | 24 | usage() { 25 | echo "Usage: $(basename "$0") [SoundCloud url]" 26 | exit 1 27 | } 28 | 29 | # Complain if incorrect args. 30 | [ "$#" -ne 1 ] && usage 31 | 32 | maybe_exit() { 33 | if [ -z "$1" ]; then 34 | echo "$2" 35 | exit "${3:-1}" 36 | fi 37 | } 38 | 39 | echo 'Fetching song data...' 40 | data="$(curl -sfg "$1" | 41 | grep -o 'c=\[.*\],' | grep -o '\[.*\]' | 42 | jq -r '.[4].data[0]')" 43 | maybe_exit "$data" 'Failed to pull data from url.' 44 | 45 | echo 'Fetching song...' 46 | 47 | # Fetch the mp3 url 48 | mp3_data="$(curl -sfg \ 49 | "https://api.soundcloud.com/i1/tracks/$( \ 50 | <<<"$data" jq -r '.id')/streams?client_id=$SC_CLIENT")" 51 | maybe_exit "$mp3_data" 'Failed to get mp3 url from SoundCloud.' 52 | 53 | # Then fetch the mp3 54 | mp3_file="$(<<<"$data" jq -r '"\(.user.username) - \(.title)"').mp3" 55 | curl -g -o "$mp3_file" "$(<<<"$mp3_data" jq -r '.http_mp3_128_url')" 56 | 57 | echo 'Fetching image...' 58 | img_url="$(<<<"$data" jq -r '.artwork_url' | sed 's/-large/-t500x500/')" 59 | img_file="$(mktemp).${img_url##*.}" 60 | curl -g -o "$img_file" "$img_url" 61 | 62 | echo 'Writing tags...' 63 | eyeD3 "$mp3_file" \ 64 | -t "$(<<<"$data" jq -r '.title')" \ 65 | -a "$(<<<"$data" jq -r '.user.username')" \ 66 | --add-image "$img_file:FRONT_COVER" 67 | 68 | # Clean up. 69 | rm "$img_file" 70 | -------------------------------------------------------------------------------- /screencast: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Author: Twily -> Ushibro 2014 4 | # Waifu: Twily likes horses, Ushibro likes Ushi and also Mio is pretty cool 5 | # Ushi: http://www.mediafire.com/download/d6j44cb842f1tj9/ushi.torrent 6 | # Description: Records a window or the desktop and converts the video to webm format. 7 | # Requires: ffmpeg, xwininfo, libnotify, keybind in your WM to "killall ffmpeg" 8 | # Useage: $ sh screencast -h|--help 9 | # 10 | # TODO support uploading to teknik.io 11 | 12 | MODE="desktop" # Default "desktop" ["window"|"desktop"] 13 | MARGIN=0 # Margin in window mode (px) 14 | TITLEBAR=0 # Titlebar height in window mode (px) 15 | FPS=30 # Frames Per Second [12-60] 16 | PRESET="ultrafast" # Default "ultrafast" (x264 --help for preset list) 17 | CRF=10 # Constant Rate Factor [0-51] (Lower is better quality) 18 | QMAX=10 # Maximum Quantization [1-31] (Lower is better quality) 19 | FULLSCREEN="$(xdpyinfo | awk '/dimensions/{print $2}')" 20 | #DISPLAY=:0.0 # Set to record specific monitor 0.0 or 0.1? 21 | 22 | OUTPUT="$HOME/out.webm" 23 | TMP="$HOME/out.mkv" 24 | KEEP=false # Keep original mkv file after conversion [true|false] 25 | 26 | if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then 27 | echo -e "Useage: $ sh screencast [OPTIONS]\n" 28 | echo " -h|--help Display this help" 29 | echo " -m|--mode desktop Set mode [\"desktop\"|\"window\"]" 30 | echo " -s|--space 10 Set margin in window mode (px)" 31 | echo " -t|--title 24 Set titlebar height in window mode (px)" 32 | echo " -f|--fps 30 Set Frames Per Second [12-60]" 33 | echo " -c|--crf 10 Set Constant Rate Factor [0-51] (Lower is better quality)" 34 | echo " -q|--qmax 10 Set Maximum Quantization [1-31] (Lower is better quality)" 35 | echo " -p|--preset ultrafast Set preset (x264 --help for preset list)" 36 | echo " -k|--keep false Keep original mkv file after conversion [true|false]" 37 | echo " -o|--output file.webm Output webm file" 38 | echo -e "\n"; exit 0 39 | fi 40 | 41 | OPTS=`getopt -o m:s:t:o:f:c:p:q:k: --long mode:,space:,title:,output:,fps:,crf:,preset:,qmax:,keep: -- "$@"` 42 | eval set -- "$OPTS" 43 | 44 | ERROR=0 45 | 46 | while true; do 47 | case "$1" in 48 | -m|--mode) MODE="$2"; shift 2;; -s|--space) MARGIN="$2"; shift 2;; 49 | -o|--output) OUTPUT="$2"; shift 2;; -p|--preset) PRESET="$2"; shift 2;; 50 | -f|--fps) FPS="$2"; shift 2;; -c|--crf) CRF="$2"; shift 2;; 51 | -q|--qmax) QMAX="$2"; shift 2;; -k|--keep) KEEP=$2; shift 2;; 52 | -t|--title) TITLEBAR="$2" shift 2;; 53 | --) shift; break;; *) echo "Internal error!"; exit 1 54 | esac 55 | done 56 | 57 | if [ "$MODE" = "window" ]; then 58 | WINFO=$(xwininfo) 59 | 60 | WINX=$(($(echo $WINFO|grep -Po 'Absolute upper-left X: \K[^ ]*')-$MARGIN)) 61 | WINY=$(($(echo $WINFO|grep -Po 'Absolute upper-left Y: \K[^ ]*')-$MARGIN-$TITLEBAR)) 62 | WINW=$(($(echo $WINFO|grep -Po 'Width: \K[^ ]*')+($MARGIN*2))) 63 | WINH=$(($(echo $WINFO|grep -Po 'Height: \K[^ ]*')+($MARGIN*2+$TITLEBAR))) 64 | 65 | sleep 2 # Wait before recording begin 66 | notify-send "Window is now being recorded. Stop by pressing Win+X." 67 | 68 | # Record Window 69 | ffmpeg -f x11grab -s "$WINW"x"$WINH" -r $FPS -i $DISPLAY"+$WINX,$WINY" -c:v libx264 -preset $PRESET -crf $CRF "$TMP" #|| ERROR=1 70 | else 71 | sleep 2 # Wait before recording begin 72 | notify-send "Desktop is now being recorded. Stop by pressing Win+X." 73 | 74 | # Record Fullscreen 75 | ffmpeg -f x11grab -s $FULLSCREEN -r $FPS -i $DISPLAY -c:v libx264 -preset $PRESET -crf $CRF "$TMP" #|| ERROR=1 76 | fi 77 | notify-send "Desktop is no longer being recorded. Video is now being converted to webm." 78 | 79 | # Convert Video: mkv -> webm 80 | ffmpeg -i "$TMP" -c:v libvpx -qmin 1 -qmax $QMAX -an -threads 4 -slices 8 -auto-alt-ref 1 -lag-in-frames 16 -pass 1 -f webm /dev/null -y|| ERROR=1 81 | ffmpeg -i "$TMP" -c:v libvpx -qmin 1 -qmax $QMAX -an -threads 4 -slices 8 -auto-alt-ref 1 -lag-in-frames 16 -pass 2 "$OUTPUT" -y|| ERROR=1 82 | rm ffmpeg2pass*.log 83 | if [[ -f "$TMP" && "$KEEP" = false ]]; then rm -f "$TMP"; fi 84 | 85 | if [ "$ERROR" -eq 0 ]; then 86 | echo -e "\n\n\033[0;32mRecording and Converting has finished and"\ 87 | "\"\033[0;34m$OUTPUT\033[0;32m\" has been \033[1;32mSuccessfully created\033[0;32m.\033[0m\n\n"; 88 | 89 | notify-send "Video was successfully converted to webm!" 90 | exit 0 91 | else 92 | echo -e "\n\n\033[0;31mAn unexpected Error prevented the screen recorder to complete,"\ 93 | "screencast was \033[1;31mNot created\033[0;31m.\033[0m\n\n"; 94 | 95 | notify-send "An unexpected error prevented the video conversion to complete." 96 | exit 1 97 | fi 98 | -------------------------------------------------------------------------------- /sctag: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Apply these id3 tags to a track from SoundCloud: 3 | # Title 4 | # Artist 5 | # Art 6 | # 7 | # Dependencies: curl, grep, jq 8 | # 9 | # Author: metakirby5 10 | 11 | checkdep() { 12 | type "$1" &>/dev/null || echo " $1" 13 | } 14 | 15 | missing="$(checkdep curl)$(checkdep grep)$(checkdep jq)" 16 | if [ "$missing" ]; then 17 | echo "The following dependencies are missing:$missing" 18 | exit 1 19 | fi 20 | 21 | usage() { 22 | echo "Usage: $(basename "$0") [SoundCloud url] [file to tag]" 23 | exit 1 24 | } 25 | 26 | # Complain if incorrect args. 27 | [ "$#" -ne 2 ] && usage 28 | 29 | maybe_exit() { 30 | if [ -z "$1" ]; then 31 | echo "$2" 32 | exit "${3:-1}" 33 | fi 34 | } 35 | 36 | echo 'Fetching song data...' 37 | data="$(curl -sfg "$1" | 38 | grep -o 'c=\[.*\],' | grep -o '\[.*\]' | 39 | jq -r '.[].data[0] | select(.title)')" 40 | maybe_exit "$data" 'Failed to pull data from url.' 41 | 42 | echo 'Fetching image...' 43 | img="$(<<<"$data" jq -r '.artwork_url // .user.avatar_url' | 44 | sed 's/-large/-t500x500/')" 45 | dest="$(mktemp).${img##*.}" 46 | curl -sfg -o "$dest" "$img" 47 | 48 | if [ "$ART_ONLY" ]; then 49 | eyeD3 "$2" --add-image "$dest:FRONT_COVER" 50 | else 51 | eyeD3 --remove-all "$2" &>/dev/null 52 | eyeD3 --encoding utf8 "$2" \ 53 | -t "$(<<<"$data" jq -r '.title')" \ 54 | -a "$(<<<"$data" jq -r '.user.username')" \ 55 | --add-image "$dest:FRONT_COVER" 56 | fi 57 | 58 | # Clean up. 59 | rm "$dest" 60 | -------------------------------------------------------------------------------- /spin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Pipe through this to keep output to one line and add a spinner. 3 | 4 | # Loading spinner: https://unix.stackexchange.com/a/225183 5 | i=1 6 | sp="/-\|" 7 | 8 | # https://stackoverflow.com/a/42284788 9 | while IFS= read -r line; do 10 | cols="$(tput cols)" 11 | trimmed="${line:0:$(( cols - 2 ))}" 12 | 13 | # LF, whitespace, LF, content 14 | printf '\r%s\r%s%s' " ${prev//?/ }" "${sp:i++%${#sp}:1} " "$trimmed" 15 | prev="$trimmed" 16 | done 17 | echo 18 | -------------------------------------------------------------------------------- /sshh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # Original @ yudai/sshh, modified by metakirby5. 3 | # Will either copy the SSH from a tmux pane or run $SHELL. 4 | # -i flag to display info. 5 | 6 | window_index="$(tmux display-message -p '#{window_index}')" 7 | pane_index="$(tmux display-message -p '#{pane_index}')" 8 | 9 | run=true 10 | if [ "$1" == "-i" ]; then 11 | run=false 12 | shift 13 | fi 14 | 15 | if [ -n "$1" ]; then 16 | w=$(echo "$1" | awk -F ',' '{ print $1 }') 17 | p=$(echo "$1" | awk -F ',' '{ print $2 }') 18 | 19 | if [ -n "$w" ]; then 20 | window_index=$w 21 | fi 22 | if [ -n "$p" ]; then 23 | pane_index=$p 24 | fi 25 | fi 26 | 27 | pane_list="$(tmux list-panes -s -F '#{window_index},#{pane_index} #{pane_pid}')" 28 | # Non 0 if given session doesn't exist 29 | if [ $? != 0 ]; then 30 | exit 1 31 | fi 32 | 33 | target_pane=$(echo "$pane_list" | grep "$window_index,$pane_index") 34 | if [ $? != 0 ]; then 35 | echo "Pane #$pane_index of Window #$window_index not found." >&2 36 | exit 2 37 | fi 38 | 39 | pane_pid=$(echo "$target_pane" | awk '{ print $2 }') 40 | 41 | IFS=$'\n' 42 | child_cmd='' 43 | find_ssh() { 44 | cur_cmd=$(ps $1 | tail -n 1 | awk '{for(i=5;i/dev/null; then 58 | eval "reattach-to-user-namespace -l \"$SHELL\"" 59 | else 60 | eval "$SHELL -l" 61 | fi 62 | fi 63 | 64 | if [ "$child_cmd" ]; then 65 | echo "$child_cmd" 66 | exit 0 67 | else 68 | echo "No running command at Pane #$pane_index of Window #$window_index" >&2 69 | exit 5 70 | fi 71 | -------------------------------------------------------------------------------- /tek: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Uploads a file to teknik.io. 3 | # Requires jq. 4 | # 5 | # Author: metakirby5 6 | 7 | usage() { 8 | echo "USAGE: $(basename "$0") [file]" 9 | exit 1 10 | } 11 | 12 | # Sanity checks 13 | [ "$#" -ne 1 ] && usage 14 | [ ! -e "$1" ] || [ -d "$1" ] && usage 15 | 16 | curl -sfF contentType="$(file --mime "$1" | cut -d' ' -f2 | cut -d';' -f1)" \ 17 | -F file="@$1" \ 18 | https://api.teknik.io/v1/Upload |\ 19 | jq -r '.result.url' | xargs echo -n 20 | -------------------------------------------------------------------------------- /tester: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # tester 4 | # Author: Ethan Chan 5 | # Date: 2/6/14 6 | # 7 | # A script to test an input set and args for coding assignments. 8 | 9 | testdir=tester_files 10 | locfile=local.out 11 | solfile=solution.out 12 | 13 | if [[ ! -d $testdir ]]; then 14 | mkdir $testdir 15 | fi 16 | 17 | # -v 18 | if [[ "$1" == "-v" ]]; then 19 | diffmethod=vimdiff 20 | shift 21 | else 22 | diffmethod=diff 23 | fi 24 | 25 | # -o | -e 26 | case "$1" in 27 | -o) 28 | rd1=">" 29 | rd2="2> /dev/null" 30 | shift 31 | ;; 32 | -e) 33 | rd1="2>" 34 | rd2="> /dev/null" 35 | shift 36 | ;; 37 | *) 38 | rd1=">&" 39 | ;; 40 | esac 41 | 42 | # Input set 43 | if ! [[ -x "$1" ]]; then 44 | input="cat $1 | " 45 | shift 46 | fi 47 | 48 | if [[ $# -lt 2 ]]; then 49 | echo 50 | echo "Diffs program outputs if differences exist." 51 | echo "Usage: $(basename "$0") (-v) (-o | -e) (input set) [local prog] [solution prog] (args)" 52 | echo " -v -- vimdiff instead of diff" 53 | echo " -o -- only test stdout" 54 | echo " -e -- only test stderr" 55 | echo 56 | exit 1 57 | fi 58 | 59 | # Progs 60 | loc=$1 61 | shift 62 | sol=$1 63 | shift 64 | 65 | # Args 66 | while [[ $# -gt 0 ]]; do 67 | args="$args $1" 68 | shift 69 | done 70 | 71 | eval "$input$loc$args $rd1 $testdir/$locfile $rd2" 72 | ecode_loc=$? 73 | eval "$input$sol$args $rd1 $testdir/$solfile $rd2" 74 | ecode_sol=$? 75 | 76 | cd $testdir 77 | if [[ $(diff $locfile $solfile) ]]; then 78 | echo 79 | echo "!!! DIFFERENCE FOUND FOR $input$loc$args" 80 | $diffmethod $locfile $solfile 81 | else 82 | echo 83 | echo "No differences for $input$loc$args" 84 | fi 85 | 86 | if ! [[ $ecode_loc -eq $ecode_sol ]]; then 87 | echo 88 | echo "!!! EXIT CODES DIFFER!!!" 89 | fi 90 | -------------------------------------------------------------------------------- /todo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # todo 4 | # Author: Ethan Chan 5 | # Date: 5/8/14 6 | # 7 | # A script to manage my todo list. 8 | 9 | shopt -s extglob # For case pattern matching 10 | numexp='^[0-9]+$' # Pattern to match a number 11 | 12 | todofile=~/todo.txt 13 | historyfile=~/.todoHistory.txt 14 | 15 | if [[ ! -f $todofile ]]; then 16 | echo "Creating $todofile..." 17 | touch $todofile 18 | fi 19 | 20 | if [[ ! -f $historyfile ]]; then 21 | echo "Creating $historyfile..." 22 | touch $historyfile 23 | fi 24 | 25 | todolen=$(wc -l $todofile | cut -d" " -f1) 26 | str_usage="Usage: $(basename "$0") [e|w|p|p#|pq|px|up|u|u#|q|l|la|h|ha|x|hx] (task(s) | #)" 27 | 28 | # Pops from $1 onto $popped ("return value") 29 | pop() { 30 | if [[ ! -f $1 ]]; then 31 | echo "ERROR: No file \"$1\" to pop from!" 32 | error=1 33 | return 34 | fi 35 | 36 | if [[ $(cat $1) ]]; then 37 | popped=$(head -n1 $1) 38 | sed -i "1d" $1 39 | 40 | error= 41 | return 42 | else 43 | echo "ERROR: File $1 empty!" 44 | error=1 45 | return 46 | fi 47 | } 48 | 49 | # Pushes $1 onto $2 (file) 50 | # $1 MUST be enclosed in quotes! 51 | push() { 52 | if [[ $# -lt 2 ]]; then 53 | echo "ERROR: Not enough args for push!" 54 | error=1 55 | return 56 | fi 57 | 58 | if [[ ! $1 ]]; then 59 | echo "ERROR: Nothing to push!" 60 | error=1 61 | return 62 | fi 63 | 64 | if [[ ! -f $2 ]]; then 65 | echo "ERROR: Could not push onto non-file \"$2\"!" 66 | error=1 67 | return 68 | fi 69 | 70 | if [[ $(cat $2) ]]; then 71 | sed -i "1i $1" $2 72 | else 73 | echo "$1" > $2 74 | fi 75 | 76 | error= 77 | return 78 | } 79 | 80 | # Queues $1 onto $2 (file) 81 | # $1 MUST be enclosed in quotes! 82 | queue() { 83 | if [[ $# -lt 2 ]]; then 84 | echo "ERROR: Not enough args for queue!" 85 | error=1 86 | return 87 | fi 88 | 89 | if [[ ! -f $2 ]]; then 90 | echo "ERROR: Could not queue onto non-file \"$2\"!" 91 | error=1 92 | return 93 | fi 94 | 95 | echo "$1" >> $todofile 96 | 97 | error= 98 | return 99 | } 100 | 101 | # Echoes first $2 lines of $1 102 | # "all" is an acceptable # of lines 103 | # Default is 5 104 | # 105 | # If you want to use line numbers, make $1 = -n and shift everything over 106 | top() { 107 | if [[ $1 == "-n" ]]; then 108 | catargs="-n" 109 | shift 110 | fi 111 | 112 | if [[ ! -f $1 ]]; then 113 | echo "ERROR: No file \"$1\" to top from!" 114 | error=1 115 | return 116 | fi 117 | 118 | if [[ $2 ]]; then 119 | numlines=$2 120 | else 121 | numlines=5 122 | fi 123 | 124 | if [[ $2 == "all" ]]; then 125 | cat $catargs $1 126 | else 127 | cat $catargs $1 | head -n $numlines 128 | 129 | # if more than $numlines lines ... 130 | if [[ $(wc -l $1 | cut -d " " -f 1) -gt $numlines ]]; then 131 | echo " ..." 132 | fi 133 | fi 134 | 135 | error= 136 | return 137 | } 138 | 139 | case "$1" in 140 | e) 141 | vim $todofile 142 | ;; 143 | w) 144 | cat > $todofile 145 | ;; 146 | x) 147 | while [[ ! $error ]]; do 148 | pop $todofile > /dev/null 149 | if [[ ! $error ]]; then 150 | push "$popped" $historyfile 151 | else 152 | break 153 | fi 154 | done 155 | ;; 156 | p) 157 | if [[ $2 && ! $2 =~ $numexp ]]; then 158 | echo "ERROR: Arg not a number!" 159 | exit 1 160 | fi 161 | 162 | for i in $(seq 1 $2); do 163 | pop $todofile > /dev/null 164 | if [[ ! $error ]]; then 165 | push "$popped" $historyfile 166 | else 167 | echo "End of todo reached, popped $(($i-1)) total." 168 | break 169 | fi 170 | done 171 | ;; 172 | pq) 173 | if [[ $2 && ! $2 =~ $numexp ]]; then 174 | echo "ERROR: Arg not a number!" 175 | exit 1 176 | fi 177 | 178 | for i in $(seq 1 $2); do 179 | pop $todofile > /dev/null 180 | if [[ ! $error ]]; then 181 | queue "$popped" $todofile 182 | else 183 | echo "End of todo reached, re-queued $(($i-1)) total." 184 | break 185 | fi 186 | done 187 | ;; 188 | px) 189 | if [[ $2 && ! $2 =~ $numexp ]]; then 190 | echo "ERROR: Arg not a number!" 191 | exit 1 192 | fi 193 | 194 | for i in $(seq 1 $2); do 195 | pop $todofile > /dev/null 196 | if [[ $error ]]; then 197 | echo "End of todo reached, deleted $(($i-1)) total." 198 | break 199 | fi 200 | done 201 | ;; 202 | p+([0-9])) 203 | if [[ $2 && ! $2 =~ $numexp ]]; then 204 | echo "ERROR: Arg not a number!" 205 | exit 1 206 | fi 207 | 208 | pnum=$(echo "$1" | cut -c2-) 209 | if [[ $pnum -gt $todolen ]]; then 210 | echo "ERROR: Index out of bounds!" 211 | echo " Tried to pop line $pnum/$todolen." 212 | exit 1 213 | fi 214 | 215 | # Get things out of the way 216 | $0 p $(($pnum-1)) 217 | 218 | # Pop range 219 | for i in $(seq 1 $2); do 220 | pop $todofile > /dev/null 221 | if [[ ! $error ]]; then 222 | to_repush="$popped $to_repush" 223 | else 224 | echo "End of todo reached, popped $(($i-1)) total." 225 | break 226 | fi 227 | done 228 | 229 | # Put things back 230 | $0 up $(($pnum-1)) 231 | 232 | # Push to history 233 | for task in "$to_repush"; do 234 | push "$task" $historyfile 235 | done 236 | ;; 237 | up) 238 | if [[ $2 && ! $2 =~ $numexp ]]; then 239 | echo "ERROR: Arg not a number!" 240 | exit 1 241 | fi 242 | 243 | for i in $(seq 1 $2); do 244 | pop $historyfile > /dev/null 245 | if [[ ! $error ]]; then 246 | push "$popped" $todofile 247 | else 248 | echo "End of todo reached, unpopped $(($i-1)) total." 249 | break 250 | fi 251 | done 252 | ;; 253 | u) 254 | shift 255 | if [[ $# -lt 1 ]]; then 256 | echo "ERROR: No tasks provided!" 257 | exit 1 258 | fi 259 | 260 | for task in "$@"; do 261 | push "$task" $todofile 262 | done 263 | ;; 264 | u+([0-9])) 265 | pnum=$(echo "$1" | cut -c2-) 266 | if [[ $pnum -gt $todolen ]]; then 267 | echo "ERROR: Index out of bounds!" 268 | echo " Tried to push to line $pnum/$todolen." 269 | exit 1 270 | fi 271 | 272 | # Get things out of the way 273 | $0 p $(($pnum-1)) 274 | 275 | # Push the other args 276 | shift 277 | $0 u "$@" 278 | 279 | # Put things back 280 | $0 up $(($pnum-1)) 281 | ;; 282 | q) 283 | shift 284 | if [[ $# -lt 1 ]]; then 285 | echo "ERROR: No tasks provided!" 286 | exit 1 287 | fi 288 | 289 | for task in "$@"; do 290 | queue "$task" $todofile 291 | done 292 | ;; 293 | l) 294 | top -n $todofile $2 295 | ;; 296 | la) 297 | top -n $todofile all 298 | ;; 299 | h) 300 | top -n $historyfile $2 301 | ;; 302 | ha) 303 | top -n $historyfile all 304 | ;; 305 | hx) 306 | read -n 1 -p "Really clear history? [y/n]: " input 307 | echo 308 | if [[ $input =~ [yY] ]]; then 309 | echo "Clearing history..." 310 | rm $historyfile 311 | touch $historyfile 312 | fi 313 | ;; 314 | "") 315 | echo "$str_usage" 316 | echo " e - edit (with vim)" 317 | echo " w - write (with cat)" 318 | echo " p (#) - pop # times (default 1)" 319 | echo " p% (#) - pop the %th line # times (default 1)" 320 | echo " pq (#) - pop and re-queue # times (default 1)" 321 | echo " px (#) - pop # times, no history (default 1)" 322 | echo " up (#) - unpop # times (default 1)" 323 | echo " u [task] (task) (...) - push" 324 | echo " u% [task] (task) (...) - push at %th line" 325 | echo " q [task] (task) (...) - queue" 326 | echo " l (# | all) - list first # lines of todo (default 5)" 327 | echo " la - shortcut for 'l all'" 328 | echo " h (# | all) - list first # lines of history (default 5)" 329 | echo " ha - shortcut for 'h all'" 330 | echo " x - clear todo" 331 | echo " hx - clear history" 332 | ;; 333 | *) 334 | echo "ERROR: Bad argument!" 335 | echo "$str_usage" 336 | ;; 337 | esac 338 | -------------------------------------------------------------------------------- /todo-head: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # todo-head 4 | # Author: Ethan Chan 5 | # Date: 2/6/14 6 | # 7 | # A script to echo the first line of my todo list, if any tasks exist. 8 | # Otherwise, a smiley is echoed. 9 | 10 | if [[ $(cat ~/todo.txt) ]]; then head -n1 ~/todo.txt; else echo "☺"; fi 11 | 12 | # ☺ 13 | -------------------------------------------------------------------------------- /ucsd-course-snipe: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Checks if a course is available for waitlist in UCSD. 3 | # The webpage has probably changed by now, so this probably won't work. 4 | # 5 | # Author: metakirby5 6 | 7 | import time 8 | from sys import stdout 9 | from datetime import datetime 10 | from getpass import getpass 11 | from pushbullet import Pushbullet 12 | from selenium import webdriver 13 | 14 | 15 | def print_noendl(text): 16 | stdout.write(text) 17 | stdout.flush() 18 | 19 | 20 | button_id = input('Waitlist button ID: ') 21 | pb_key = input('PB API Key: ') 22 | pb = Pushbullet(pb_key) 23 | 24 | 25 | def print_and_push(text): 26 | print(text) 27 | pb.push_note('course_snipe.py', text) 28 | 29 | 30 | print('- UCSD Credentials -') 31 | username = input('Username: ') 32 | password = getpass() 33 | 34 | options = webdriver.ChromeOptions() 35 | options.add_argument('headless') 36 | driver = webdriver.Chrome(chrome_options=options) 37 | driver.get('https://act.ucsd.edu/webreg2/start') 38 | 39 | e = driver.find_element_by_id('ssousername') 40 | print(driver.title) 41 | e.send_keys(username) 42 | e = driver.find_element_by_id('ssopassword') 43 | e.send_keys(password) 44 | e = driver.find_element_by_class_name('sso-button') 45 | e.click() 46 | 47 | e = driver.find_element_by_id('startpage-button-go') 48 | print(driver.title) 49 | e.click() 50 | 51 | while True: 52 | # Change this ID to the Waitlist button ID. 53 | try: 54 | driver.refresh() 55 | e = driver.find_element_by_id(button_id) 56 | except Exception as e: 57 | print_and_push('EXCEPTION: %s' % e) 58 | break 59 | 60 | if not e.get_attribute('disabled'): 61 | print_and_push('ENROLL, NOW!!!') 62 | break 63 | 64 | print_noendl('(%s) Refreshing' % datetime.now()) 65 | for _ in range(5): 66 | print_noendl('.') 67 | time.sleep(1) 68 | print() 69 | -------------------------------------------------------------------------------- /urldecode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # https://gist.github.com/cdown/1163649 3 | 4 | url_encoded="${*//+/ }" 5 | printf '%b' "${url_encoded//%/\\x}" 6 | -------------------------------------------------------------------------------- /urlencode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # https://gist.github.com/cdown/1163649 3 | 4 | old_lc_collate=$LC_COLLATE 5 | LC_COLLATE=C 6 | 7 | arg="$*" 8 | length="${#arg}" 9 | for (( i = 0; i < length; i++ )); do 10 | c="${arg:i:1}" 11 | case $c in 12 | [a-zA-Z0-9.~_-]) printf "$c" ;; 13 | *) printf '%%%02X' "'$c" ;; 14 | esac 15 | done 16 | 17 | LC_COLLATE=$old_lc_collate 18 | 19 | -------------------------------------------------------------------------------- /use-xresources: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # http://superuser.com/a/921802 3 | 4 | tr -d ' \t' | sed -n ' 5 | s/.*\.font:/\x1b]710;/p 6 | s/.*\.boldFont:/\x1b]711;/p 7 | s/.*\.italicFont:/\x1b]712;/p 8 | s/.*\.boldItalicFont:/\x1b]713;/p 9 | s/.*\.background:/\x1b]11;/p 10 | s/.*\.foreground:/\x1b]10;/p 11 | s/.*\.borderColor:/\x1b]708;/p 12 | s/.*\.color\([0-9][^:]*\):/\x1b]4;\1;/p 13 | ' | tr \\n \\a 14 | -------------------------------------------------------------------------------- /vidhalve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Halves video dimensions for uploading to GitLab. 3 | # 4 | # Dependencies: ffmpeg 5 | # 6 | # Author: metakirby5 7 | 8 | checkdep() { 9 | type "$1" &>/dev/null || echo " $1" 10 | } 11 | 12 | missing="$(checkdep ffmpeg)" 13 | if [ "$missing" ]; then 14 | echo "The following dependencies are missing:$missing" 15 | exit 1 16 | fi 17 | 18 | usage() { 19 | echo "Usage: $(basename "$0") [filename] (new height)" 20 | exit 1 21 | } 22 | 23 | [ "$#" -lt 1 ] && usage 24 | 25 | out="$(mktemp).${1##*.}" 26 | ffmpeg -i "$1" -max_muxing_queue_size 4000 \ 27 | -vf "scale=trunc(oh*a/2)*2:trunc(${2:-ih/2}/2)*2" "$out" && 28 | mv "$out" "$1" || 29 | rm "$out" 30 | -------------------------------------------------------------------------------- /waaai: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shortens a URL via waa.ai. 3 | # Requires jq. 4 | # 5 | # Author: metakirby5 6 | 7 | usage() { 8 | echo "USAGE: $(basename "$0") (-c CUSTOM_URL) (-p) [URL]" 9 | exit 1 10 | } 11 | 12 | # http://stackoverflow.com/a/14203146 13 | OPTIND=1 14 | custom="" 15 | private=false 16 | 17 | while getopts "c:p" opt; do 18 | case "$opt" in 19 | c) 20 | custom=$OPTARG 21 | ;; 22 | p) 23 | private=true 24 | ;; 25 | esac 26 | done 27 | 28 | shift $((OPTIND-1)) 29 | 30 | # Sanity checks 31 | [ "$#" -ne 1 ] && usage 32 | 33 | url="http://api.waa.ai/shorten?url=$1" 34 | if [ ! -z "$custom" ]; then 35 | url="$url&custom=$custom" 36 | fi 37 | if [ ! "$private" = false ]; then 38 | url="$url&private=true" 39 | fi 40 | 41 | curl -sf "$url" | jq -r '.data.url' 42 | -------------------------------------------------------------------------------- /wchat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # wchat 4 | # Author: Ethan Chan 5 | # Date: 5/4/14 6 | # 7 | # A script to emulate a multi-person chatroom using write. 8 | 9 | usage() { 10 | echo "Usage: $(basename "$0") [your name] [user1 (pts/XXX)] (user2 (pts/XXX)) (...)" 11 | echo 12 | } 13 | 14 | echo 15 | 16 | if [[ $# -eq 0 ]]; then 17 | usage 18 | echo " Sets up multi-way write with timestamp and handle." 19 | echo " See available users using:" 20 | echo " $ finger" 21 | echo 22 | exit 0 23 | fi 24 | 25 | if [[ $# -lt 2 ]]; then 26 | echo "ERROR: Missing recipients!" 27 | error=1 28 | fi 29 | 30 | handle=$1 31 | shift 32 | 33 | # Process additional args 34 | while [[ $# -gt 0 ]]; do 35 | 36 | # Process tty 37 | if [[ $1 =~ ^pts/ ]]; then 38 | rmtail=${people%%)} 39 | person=${rmtail##* } 40 | 41 | # Is there even a person to give the tty? 42 | if [[ $person ]]; then 43 | 44 | # Is that person online? 45 | if [[ $(finger | grep ^$person | grep $1) ]]; then 46 | people="$rmtail $1)" 47 | else 48 | # What kind of mistake did the user make? 49 | if [[ $person =~ ^pts/ ]]; then 50 | rmhead=${people##*write } 51 | realperson=${rmhead%%[ )]*} 52 | echo "ERROR: multiple tty per user not supported!" 53 | echo " Context: $realperson $person $1" 54 | else 55 | echo "ERROR: tty $1 not found for user $person!" 56 | fi 57 | error=1 58 | fi 59 | else 60 | echo "ERROR: No user to assign tty $1 to!" 61 | error=1 62 | fi 63 | 64 | # Process user 65 | else 66 | if [[ $(finger | grep ^$1) ]]; then 67 | people="$people >(write $1)" # For tee-ing 68 | HRPeople="$HRPeople $1" # Human-readable version 69 | else 70 | echo "ERROR: User $1 not found!" 71 | error=1 72 | fi 73 | fi 74 | shift 75 | done 76 | 77 | if [[ $error ]]; then 78 | echo 79 | echo "Error(s) encountered, aborting..." 80 | echo 81 | usage 82 | exit $error 83 | fi 84 | 85 | mesg y # Turn on messages 86 | echo "====================Now chatting!====================" 87 | echo "Chatting with:$HRPeople" 88 | 89 | # Eval because process substitution is stupid. Need to use fflsuh with awk 90 | # so the messages come through instantly, rather than at EOF. 91 | eval "cat | awk '{ \ 92 | print ((NR == 1) ?\"\nSender: $USER\nRecipients:$HRPeople\n\n\" : \"\n\"), \ 93 | strftime(\"[%H:%M:%S]\"), \"$handle: \" \$0;\ 94 | fflush();\ 95 | }' | tee$people > /dev/null" 96 | -------------------------------------------------------------------------------- /woodo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shows a dancing sudowoodo. 3 | # 4 | # Author: metakirby5 5 | 6 | frameHeight=15 7 | ((botline = $(tput lines) - 1)) 8 | ((topline = botline - frameHeight)) 9 | nframes=2 10 | 11 | sdw() { 12 | case "$1" in 13 | "0") 14 | echo " _ __ " 15 | echo " / '\\ (~._ ./ ) " 16 | echo " \\__/ __'-_\\__/ ./ " 17 | echo " _ \\ \\/ \\ \\ |_ __ " 18 | echo " ( ) \\__/ -^ \\ / \\ " 19 | echo " \\_/ \" \\ | o o | .. / __ " 20 | echo " \\\\. -' ==== / || / \\ " 21 | echo " \\ . . |---__.\\__/ " 22 | echo " / : / | | " 23 | echo " / : / \\_/ " 24 | echo " --/ :: ( " 25 | echo " ( | ( (____ " 26 | echo " .-- .. ----**.____) " 27 | echo " \\___/ " 28 | echo 29 | ;; 30 | "1") 31 | echo " __ _ " 32 | echo " ( \\. _.~) /' \\ " 33 | echo " \\. \\__/_-'__ \\__/ " 34 | echo " __ _| / / \\/ / _ " 35 | echo " / \\ / ^- \\__/ ( ) " 36 | echo " __ \\ .. | o o | / \" \\_/ " 37 | echo " / \\ || \\ ==== '- .// " 38 | echo " \\__/.__---| . . / " 39 | echo " | | \\ : \\ " 40 | echo " \\_/ \\ : \\ " 41 | echo " ) :: \\-- " 42 | echo " ____) ) | ) " 43 | echo " (____.**---- .. --. " 44 | echo " \\___/ " 45 | echo 46 | esac 47 | } 48 | 49 | if [ $EUID -ne 0 ]; then 50 | echo "This is a weird tree." 51 | else 52 | i=0 53 | sdw $i 54 | while true; do 55 | tput cup $topline 0 56 | sdw $i 57 | tput cup $botline 0 58 | (( i = (i + 1) % nframes )) 59 | sleep 0.5 60 | done 61 | fi 62 | 63 | -------------------------------------------------------------------------------- /wzk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs whizkers with environment variable support, asks for a theme using 3 | # dmenu, and reloads the desktop. 4 | # 5 | # Author: metakirby5 6 | 7 | yes 2>/dev/null | restow-dots >/dev/null 8 | 9 | if [ "$?" -ne 0 ]; then 10 | echo 'restow-dots FAILED' 11 | exit 1 12 | fi 13 | 14 | if [ "$#" -eq 0 ]; then 15 | selected=$(whizkers -l |\ 16 | dmenu -i -f -fn "Calibri:pixelsize=28" -sb "#3f91c0" -h 50 -t \ 17 | -p 'Whizkers') 18 | [ -z "$selected" ] && exit 0 19 | whizkers -e $selected >/dev/null 20 | else 21 | whizkers -e "$@" >/dev/null 22 | fi 23 | 24 | [ "$?" -ne 0 ] && exit 1 25 | 26 | reload-desktop 27 | [ "$#" -ne 0 ] && sleep 1 && fetch 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /xfr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # transfer.sh client. 3 | 4 | if [ "$#" -eq 0 ]; then 5 | echo "No arguments specified. Usage: 6 | $(basename "$0") [file] 7 | cat [file] | transfer [url]" 8 | exit 1 9 | fi 10 | 11 | tmpfile="$(mktemp -t transferXXX)" 12 | 13 | if tty -s; then 14 | basefile="$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')" 15 | curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile 16 | else 17 | curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile 18 | fi 19 | 20 | cat $tmpfile 21 | rm -f $tmpfile 22 | -------------------------------------------------------------------------------- /xpipes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Blog: http://blog.yjl.im/2013/07/pipesxsh-animated-pipessh-terminal.html 4 | # Gist: https://gist.github.com/livibetter/5974905 5 | # Screenshot: https://lh3.googleusercontent.com/-UaCta_DtgrQ/Ud6dqIgcfmI/AAAAAAAAE_8/VXPac0OpULU/s800/pipesX.sh.gif 6 | # Screenshot: https://lh6.googleusercontent.com/-yBety-A8J_c/Ud6dk10sjBI/AAAAAAAAE_0/S98aRRV8t0s/s800/pipesX.sh%25202013-07-11--19%253A51%253A05.png 7 | # Screencast: http://youtu.be/dITTlFPYVPA 8 | 9 | W=$(tput cols) H=$(tput lines) 10 | # maximal random value + 1 11 | M=32768 12 | 13 | SETS=('╱╲' '/\') 14 | COLORS=(31 32 33 34 35 36 37) 15 | 16 | # default values 17 | N=1 18 | T=0 19 | I=0.05 20 | P=25 21 | R=$((W * H / 4)) 22 | 23 | HELP="Usage: $(basename $0) [OPTIONS] 24 | Animated pipes.sh terminal screensaver at an angle. 25 | 26 | Options: 27 | 28 | -n [1-] number of pipes. (Default: $N) 29 | -t [0-$((${#SETS[@]} - 1))] type of pipes. (Default: $T) 30 | -i [float] piping interval or maze generation interval. (Default: $I) 31 | -P [0-100] probability of a turning pipe or of \\ in maze generation. (Default: $P) 32 | -r [LIMIT] reset after x characters, 0 if no limit. (Default: $R) 33 | -R random starting point. 34 | -C no color. 35 | -X maze generation. 36 | -h this help message. 37 | " 38 | 39 | while getopts "n:t:i:P:r:RCXh" arg; do 40 | case $arg in 41 | n) 42 | ((N = OPTARG > 0 ? OPTARG : N)) 43 | ;; 44 | t) 45 | ((T = (OPTARG >= 0 && OPTARG < ${#SETS[@]}) ? OPTARG : T)) 46 | ;; 47 | i) 48 | I=$OPTARG 49 | ;; 50 | P) 51 | ((P = (OPTARG >= 0 && OPTARG <= 100) ? OPTARG : P)) 52 | ;; 53 | r) 54 | ((R = OPTARG >= 0 ? OPTARG : R)) 55 | ;; 56 | R) 57 | RNDSTART=1 58 | ;; 59 | C) 60 | NOCOLOR=1 61 | ;; 62 | X) 63 | MAZE=1 64 | ;; 65 | h) 66 | echo -e "$HELP" 67 | exit 0 68 | ;; 69 | esac 70 | done 71 | 72 | do_exit() { 73 | # Show cursor and echo stdin 74 | echo -ne "[?25h" 75 | stty echo 76 | clear 77 | exit 0 78 | } 79 | trap do_exit INT TERM 80 | 81 | # No echo stdin and hide the cursor 82 | stty -echo 83 | echo -ne "[?25l" 84 | 85 | # maze geneartion 86 | while [[ $MAZE ]] && clear; do 87 | [[ $NOCOLOR ]] || echo -ne "[1;${COLORS[${#COLORS[@]} * RANDOM / M]}m" 88 | for ((i = 0; i < W * H; i++ )); do 89 | echo -ne ${SETS[T]:100 * RANDOM / M < P:1} 90 | done 91 | sleep $I 92 | done 93 | 94 | # initialze values 95 | for ((n = 0; n < N; n++)); do 96 | ((X[n] = RNDSTART ? (W + 2) * RANDOM / M : W / 2)) 97 | ((Y[n] = RNDSTART ? (H + 2) * RANDOM / M : H / 2)) 98 | D[n]=$((4 * RANDOM / M)) 99 | C[n]=${COLORS[${#COLORS[@]} * RANDOM / M]} 100 | done 101 | 102 | clear 103 | while :; do 104 | for ((n = 0; n < N; n++, CC = 0)); do 105 | x=${X[n]} y=${Y[n]} 106 | d=${D[n]} c=${C[n]} 107 | 108 | # calculate new direction `d` 109 | # 1 0 110 | # \/ 4 directions 0 to 3 111 | # /\ 112 | # 2 3 113 | # valid directions: d: dd', d' is the new direction 114 | # d 115 | # 0: / 00 \ 01 03 116 | # / / /\ 117 | # 1: / 10 \ 11 12 118 | # \ \ /\ 119 | # 2: \/ 21 / 22 / 23 120 | # / \ 121 | # 3: \/ 30 \ 32 \ 33 122 | # / \ 123 | ((d = (100 * RANDOM / M) < P ? ((d + 1) + 2 * (RANDOM % 2)) % 4 : d)) 124 | ((e = (d + 1) % 4)) 125 | 126 | # calculate new position 127 | # d' x' y' 128 | # 0: x+1 y-1 129 | # 1: x-1 y-1 130 | # 2: x-1 y+1 131 | # 3: x+1 y+1 132 | ((xn = e < 2 ? x + 1 : x - 1)) 133 | ((yn = d < 2 ? y - 1 : y + 1)) 134 | 135 | # adjust position and change color? 136 | ((d < 2 && y == 0)) && ((yn--, CC=1)) 137 | ((e > 1 && x == 0)) && ((xn--, CC=1)) 138 | ((d > 1 && y == H)) && ((yn++, CC=1)) 139 | ((e < 2 && x == W)) && ((xn++, CC=1)) 140 | ((CC)) && c=${COLORS[${#COLORS[@]} * RANDOM / M]} 141 | 142 | # warp pipe 143 | ((xn = (xn + W + 1) % (W + 1))) 144 | ((yn = (yn + H + 1) % (H + 1))) 145 | 146 | # calculate position in terminal 147 | # d' xt yt 148 | # 0: x' y'+1 149 | # 1: x'+1 y'+1 150 | # 2: x'+1 y' 151 | # 3: x' y' 152 | ((xt = e < 2 ? xn : xn + 1)) 153 | ((yt = d < 2 ? yn + 1 : yn)) 154 | 155 | echo -ne "[${yt};${xt}H" 156 | [[ $NOCOLOR ]] || echo -ne "[1;${c}m" 157 | echo -n "${SETS[T]:d%2:1}" 158 | 159 | X[n]=$xn Y[n]=$yn 160 | D[n]=$d C[n]=$c 161 | done 162 | sleep $I 163 | ((R)) && ((r += N, r >= R)) && r=0 && clear 164 | done 165 | 166 | do_exit 167 | --------------------------------------------------------------------------------