Skip to content

Instantly share code, notes, and snippets.

View leogama's full-sized avatar

Leonardo Gama leogama

View GitHub Profile
@leogama
leogama / which.sh
Created September 13, 2017 00:28
A decent and portable 'which' command for bash
function which {
local CMD=$1;
if alias $1 &>/dev/null; then
CMD=$(alias $1 | sed "s/^alias $1='\([^' ]*\).*$/\1/");
if [[ "$CMD" != $1 ]]; then
type $1;
which "$CMD"; # recursive call for nested aliases
return;
fi;
fi;
@leogama
leogama / man.sh
Created September 13, 2017 00:33
A smartish 'man' command for bash
function man {
local CMD=${@: -1}
# Strangely, 'whatis' and even 'man -f' may fail to find the command.
if whatis $CMD &>/dev/null || [[ $(info -w $CMD) == '*manpages*' ]]; then
command man "$@"
elif info -w &>/dev/null; then
info "$@"
else
for HELP in --help -h -help --usage; do
if $CMD $HELP &>/dev/null; then
@leogama
leogama / appify.sh
Last active January 20, 2018 00:52 — forked from oubiwann/appify.sh
appify — create the simplest possible Mac app from a shell script (adds an application icon)
#!/usr/bin/env bash
VERSION=4.0.1
SCRIPT=`basename "$0"`
APPNAME="My App"
APPICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns"
OSX_VERSION=`sw_vers -productVersion`
PWD=`pwd`
function usage {
@leogama
leogama / pulseaudio-equalizer-setup.sh
Created September 14, 2021 00:27
Script to setup PulseAudio equalizer module + qpaeq GUI as a desktop application
#!/bin/sh -ux
# This is a small script to setup the PulseAudio equalizer as a desktop
# application that runs just when the 'qpaeq' GUI is open.
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or distribute
# this software, either in source code form or as a compiled binary, for any
# purpose, commercial or non-commercial, and by any means.
@leogama
leogama / unix_permissions.ipynb
Last active November 14, 2023 14:34
User and file permissions in Unix systems
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.