Skip to content

Instantly share code, notes, and snippets.

Danilo Gomez DaniloGomez

Block or report user

Report or block DaniloGomez

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DaniloGomez
DaniloGomez / mute.sh
Created Oct 19, 2018
Executes a command and suppress its output
View mute.sh
# mute
function mute()
{
${@:1} &> /dev/null
}
# mute completion -*- shell-script -*-
_mute()
@DaniloGomez
DaniloGomez / colors.sh
Created Jun 13, 2018
Terminal colors for common outputs and bash prompts with a colored prompt example
View colors.sh
# styles
declare -A styles=(
["normal"]="0"
["bold"]="1"
["dark"]="2"
["under"]="4"
["invert"]="7"
["background"]="8"
["negate"]="9"
)
@DaniloGomez
DaniloGomez / wifi-hotspot
Created Jun 13, 2018
create a WiFi hotspot with `create_ap` bridging the wired network interface
View wifi-hotspot
#!/bin/sh
sudo create_ap `ifconfig -a | awk '/^w.*Ethernet/ { print $1; exit }` `ifconfig -a | awk '/^w.*Ethernet/ { print $1; exit }` $*
@DaniloGomez
DaniloGomez / net-interfaces.sh
Last active Feb 18, 2019
Commands to list network interfaces and specifically wired and wireless interfaces
View net-interfaces.sh
#!/bin/sh
function net-interfaces(){
echo `ip -c=never addr | gawk 'match($0, /[[:digit:]]+: ([[:alnum:]]+):/, m) { print m[1] }'`
}
function wireless() {
echo `ip -c=never addr | gawk 'match($0, /[[:digit:]]+: (w[[:alnum:]]+):/, m) { print m[1] }'`
}
@DaniloGomez
DaniloGomez / bak.sh
Created Jun 13, 2018
Commands to backup and unbackup files rotating its names
View bak.sh
#!/usr/bin/bash
function bak() {
name=${1%/}
prefix=${name%.bak}
if [[ $prefix == $name ]]; then
backup $name
else
unbackup $name
fi
@DaniloGomez
DaniloGomez / battery
Created Jun 13, 2018
Animated progress bar of laptop battery in command line
View battery
#!/bin/sh
info=`acpi`
level=`echo $info | grep -Eo '[0-9]{,3}%' | tr -d '%'`
msg=`echo $info | sed 's/.*: //g'`
if [ $# = 0 ]
then columns=$((`tput cols` - 2))
else columns=$(( $1 - 2 ))
fi
@DaniloGomez
DaniloGomez / crlf2lf
Created Jun 13, 2018
Converts CRLF to LF in a file or recursively in all files of a directory
View crlf2lf
#!/usr/bin/env python
import argparse, os, sys
(
NO_ERR,
READ_ERR,
WRITE_ERR,
BACKUP_ERR,
) = range(4)
@DaniloGomez
DaniloGomez / matrix.sh
Last active Apr 18, 2019
Executes `openvpn` with some known `.ovpn` files and prepares a route for your local network while `openvpn` is running
View matrix.sh
#!/bin/bash
################################################################################
# Matrix
# ======
#
# `Matrix` executes `openvpn` with some known `.ovpn` files located in a given
# directory and sends a notification via `notify-osd` when vpn connection drops
#
################################################################################
You can’t perform that action at this time.