Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
unset PASSWORD
unset CHARCOUNT
echo -n "Enter password: "
stty -echo
CHARCOUNT=0
@dougpagani
dougpagani / typify-file.sh
Created January 19, 2019 20:58
Ask what "tf" is up with this cmd, which is often a symlinked-file (think brew Cellars). Also good for getting to a python-cli wrapper's lib dir.
typify-file ()
{
opwd="$PWD";
type -a "$1";
cmdpath=$(type -P "$1");
if ( test -e "$cmdpath" ); then
count=0;
while ( test -L "$cmdpath" ); do
(( count++ ));
linkrelative=$(readlink -n "$cmdpath");
@dougpagani
dougpagani / posix-commandline-processing.sh
Last active January 19, 2019 21:03
Quick Cheatsheets when debugging bash command line construction
# https://bashrules.blogspot.com/2006/04/bash-order-of-expansions.html
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html
alias bashexpandorder='echo '\''
1. {} brace
2. ~ tilde
3. $VAR parameter & variable
4. $() command-substitution
5. $(()) arithmetic expansion
6. (IFS) word-splitting
7. * ? [ filename expansion (-f will disable)
@dougpagani
dougpagani / timo-make.sh
Created November 27, 2018 15:15
Facilitated Teamocil.yml file creation
#!/usr/bin/env bash
# FILE: timo-make.sh
# readline for facilitating
set -euo pipefail
############################################################
#{{{ Helpers
tmuxdims ()
{
local WINDEX=${1:-$(tmux display-message -p '#I')};
tmux list-windows | \grep -i "^${WINDEX}" | cut -f 3- -d'[' | sed 's/layout //' | sed 's/ @.*//' | sed 's/.$//'
@dougpagani
dougpagani / grab_gh_password.py
Created August 27, 2018 04:34
Get macOS password from the 'security' command in python
import subprocess
import re
# Grab password from macOS keychain
def grab_gh_password():
invocation = ['security', 'find-internet-password', '-gs', 'github.com']
block = subprocess.Popen(invocation, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
lastline = block.stderr.read().strip().decode("utf-8")
parsed_password = re.sub('password: "(.*)"', '\\1', lastline)
return parsed_password
@dougpagani
dougpagani / .muttrc
Created June 8, 2018 16:02 — forked from shreeshga/.muttrc
mutt rc file
# A basic .muttrc for use with Gmail
# Change the following six lines to match your Gmail account details
set imap_user = "[email protected]"
set copy=yes
set smtp_url = "smtps://[email protected]@smtp.gmail.com:465/"
set from = "[email protected]"
set realname = "shreesh ayachit"
# Change the following line to a different editor you prefer.