Skip to content

Instantly share code, notes, and snippets.

View edvb's full-sized avatar

Ed van Bruggen edvb

View GitHub Profile
@edvb
edvb / $
Last active July 16, 2017 01:10
blindly copy commands from the internet
#!/usr/bin/env bash
# $: blindly copy commands from the internet
"$@"
@edvb
edvb / calc
Last active July 27, 2017 03:04
preform fast calculations on the go
#!/usr/bin/env bash
# calc: preform fast calculations on the go
#
# Tired of having to open a new terminal, run `bc`, type the calculation, only
# to exit right after seeing the answer? Suffer no longer! Now just type
# `calc 2+2` and instantly see the answer!
echo "$@" | bc -l
@edvb
edvb / g
Last active July 28, 2017 21:50
tiny git wrapper
#!/usr/bin/env bash
# g: tiny git wrapper
if [[ $# -eq 0 ]]; then
git status
else
git "$@"
fi
@edvb
edvb / tg
Created March 18, 2018 00:47
quickly tag files
#!/usr/bin/env bash
# tg: quickly tag files
#
# Rename files based on the given tag. For example `tg old file.txt` changes
# `file.txt` to `file-old.txt`. If the file already contains the suppied tag,
# it is removed.
if [[ $# != 2 ]]; then
printf "usage: tg TAG FILE \n"
@edvb
edvb / ED
Last active January 5, 2021 23:30
Commands revolving around $EDITOR
#!/usr/bin/env bash
# ED: change between $EDITORs
#
# Toggles your $EDITOR between your different editors.
# To install add `source path/to/ED.sh` to your shell's rc file.
ED() {
local new
if [[ "$1" != "" ]]; then
@edvb
edvb / echk
Created March 18, 2018 00:59
functions to display shell error code
#!/usr/bin/env bash
# echk: functions to display shell error code
echk_color() {
# set color depending on if the last command succeed or not
if [[ $? -eq 0 ]]; then
echo -ne "\033[0;32m"
return 0
else
@edvb
edvb / pub
Created April 13, 2018 06:24
prepare post to be published
#!/usr/bin/env bash
# pub: prepare post to be published
#
# Moves given draft into the posts directory and prefixes the filename with the
# date so that it is ready to be published.
if [[ $# == 0 || $# > 2 || ! -f "$1" ]]; then
echo "usage: pub FILE [POSTDIR]"
exit 1
@edvb
edvb / aln2grishin.py
Last active April 16, 2022 22:27
Convert alignment files for Rosetta simulations
#!/usr/bin/env python
"""
Convert clustal alignment files to grishin format for use in Rosetta
protein homology simulatoins
Author: Ed van Bruggen <edvb@uw.edu>
"""
import argparse
from argparse import RawTextHelpFormatter
@edvb
edvb / body
Created January 27, 2019 06:46
print the body of a file
#!/usr/bin/env bash
# body: print the body of a file
#
# if only two arguments are given print the file given by the first at the line
# number from the second. If a third argument is given print until that line.
if [[ $# == 2 ]]; then
sed -n $2p $1
elif [[ $# == 3 ]]; then
@edvb
edvb / sett
Created January 27, 2019 07:03
set title of a terminal
#!/usr/bin/env bash
# sett: set title of a terminal
#
# Change the title of any terminal window. If no argument is given it sets the
# title to the working directory, otherwise the supplied TITLE is used.
title=$1
if [[ -z $title ]]; then
title="$(basename "$PWD")"