Skip to content

Instantly share code, notes, and snippets.

@danielfmo
Last active March 30, 2026 08:35
Show Gist options
  • Select an option

  • Save danielfmo/51f66f422b99811b3552fd85d14e3740 to your computer and use it in GitHub Desktop.

Select an option

Save danielfmo/51f66f422b99811b3552fd85d14e3740 to your computer and use it in GitHub Desktop.
Windows Development Environment
alias ls='ls -aFh --color=always --group-directories-first'
alias ll='ls -Fls'
alias getidf='. $HOME/esp/esp-idf/export.sh'
################ GIT aliases #####################
alias ga='git add'
alias gb="git branch"
alias gc="git commit"
alias gf="git fetch --all --prune"
alias gg="gf && gp"
alias gl="git logline"
alias gm="git merge --no-ff --no-commit"
alias gp="git pull"
alias gs="git status"
alias gco="git checkout"
alias gnb="git checkout -b"
alias gpull="git pull --rebase --prune"
################ GIT prompt #####################
# GIT bash integration
if [[ -e /usr/lib/git-core/git-sh-prompt ]]; then
source /usr/lib/git-core/git-sh-prompt
export GIT_PS1_SHOWCOLORHINTS=true # Not working with __prompt_command() :(
export GIT_PS1_SHOWDIRTYSTATE=true # staged '+', unstaged '*'
export GIT_PS1_SHOWUNTRACKEDFILES=true # '%' untracked files
export GIT_PS1_SHOWUPSTREAM="auto" # '<' behind, '>' ahead, '<>' diverged, '=' no difference
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PROMPT_COMMAND=$(sed -r 's|^(.+)(\\\$\s*)$|__git_ps1 "\1" "\2"|' <<<$PS1)
# export PROMPT_COMMAND=__prompt_command
fi
function __prompt_command() {
local ERRORCODE="$?"
PS1="${debian_chroot:+($debian_chroot)}"
# Errorcode (conditional)
if [ ${ERRORCODE} != 0 ]; then
PS1+="\e[90m $(echo -e '\u2570\u2500\u2770')\e[1;31m$ERRORCODE\e[90m$(echo -e '\u2771')\e[0m\n"
fi
# Main line
local c="$(echo -e '\u256d\u2500')"
if [[ "$(dirs -p | wc -l)" != "1" ]]; then
local c="$(echo -e '\u2934') "
fi
PS1+="\e[90m$c\e[0m"
if [[ ! -z "${VIRTUAL_ENV}" ]]; then
PS1+="\e[90m$(echo -e '\u2770')\e[32m$(basename $VIRTUAL_ENV)\e[90m$(echo -e '\u2771')\e[0m"
fi
PS1+=" \e[0;34m\w\e[m"
PS1+="\e[0;32m\$(__git_ps1)\e[m"
# Command Line
PS1+="\n\e[90m$(echo -e '\u2570\u2500\u2bc8') \e[0m"
}
#!/bin/bash
iatest=$(expr index "$-" i)
#######################################################
# SOURCED ALIAS'S AND SCRIPTS
#######################################################
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Enable bash programmable completion features in interactive shells
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
#######################################################
# EXPORTS
#######################################################
# Disable the bell
if [[ $iatest > 0 ]]; then bind "set bell-style visible"; fi
# Expand the history size
export HISTFILESIZE=10000
export HISTSIZE=500
# Don't put duplicate lines in the history and do not add lines that start with a space
export HISTCONTROL=erasedups:ignoredups:ignorespace
# Check the window size after each command and, if necessary, update the values of LINES and COLUMNS
shopt -s checkwinsize
# Causes bash to append to history instead of overwriting it so if you start a new terminal, you have old session history
shopt -s histappend
PROMPT_COMMAND='history -a'
# Allow ctrl-S for history navigation (with ctrl-R)
stty -ixon
# Ignore case on auto-completion
# Note: bind used instead of sticking these in .inputrc
if [[ $iatest > 0 ]]; then bind "set completion-ignore-case on"; fi
# Show auto-completion list automatically, without double tab
if [[ $iatest > 0 ]]; then bind "set show-all-if-ambiguous On"; fi
# Set the default editor
export EDITOR=vim
export VISUAL=vim
# To have colors for ls and all grep commands such as grep, egrep and zgrep
export CLICOLOR=1
export LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.xml=00;31:'
# Color for manpages in less makes manpages a little easier to read
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
#######################################################
# GENERAL ALIAS'S
#######################################################
# To temporarily bypass an alias, we preceed the command with a \
# EG: the ls command is aliased, but to use the normal ls command you would type \ls
# Alias's to modified commands
alias mkdir='mkdir -p'
alias ps='ps auxf'
alias vi='vim'
alias rm='rm -f'
# cd into the old directory
alias bd='cd "$OLDPWD"'
# Alias's for multiple directory listing commands
alias ls='ls -aFh --group-directories-first --color=auto' # add colors and file type extensions
alias ll='ls -Fls' # long listing format
alias labc='ls -lap' # alphabetical sort
alias lf="ls -l | egrep -v '^d'" # files only
alias ldir="ls -l | egrep '^d'" # directories only
alias grep="grep --color=auto"
# Search running processes
alias psg="ps aux | grep "
# Count all files (recursively) in the current folder
alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null"
# Load other aliases from external file
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
#######################################################
# Set the command prompt
#######################################################
function __setprompt
{
local LAST_COMMAND=$? # Must come first!
# Define colors
local LIGHTGRAY="\033[0;37m"
local WHITE="\033[1;37m"
local BLACK="\033[0;30m"
local DARKGRAY="\033[1;30m"
local RED="\033[0;31m"
local LIGHTRED="\033[1;31m"
local GREEN="\033[0;32m"
local LIGHTGREEN="\033[1;32m"
local BROWN="\033[0;33m"
local YELLOW="\033[1;33m"
local BLUE="\033[0;34m"
local LIGHTBLUE="\033[1;34m"
local MAGENTA="\033[0;35m"
local LIGHTMAGENTA="\033[1;35m"
local CYAN="\033[0;36m"
local LIGHTCYAN="\033[1;36m"
local NOCOLOR="\033[0m"
# Show error exit code if there is one
if [[ $LAST_COMMAND != 0 ]]; then
PS1="\[${DARKGRAY}\](\[${LIGHTRED}\]ERROR\[${DARKGRAY}\])-(\[${RED}\]Exit Code \[${LIGHTRED}\]${LAST_COMMAND}\[${DARKGRAY}\])-(\[${RED}\]"
if [[ $LAST_COMMAND == 1 ]]; then
PS1+="General error"
elif [ $LAST_COMMAND == 2 ]; then
PS1+="Missing keyword, command, or permission problem"
elif [ $LAST_COMMAND == 126 ]; then
PS1+="Permission problem or command is not an executable"
elif [ $LAST_COMMAND == 127 ]; then
PS1+="Command not found"
elif [ $LAST_COMMAND == 128 ]; then
PS1+="Invalid argument to exit"
elif [ $LAST_COMMAND == 129 ]; then
PS1+="Fatal error signal 1"
elif [ $LAST_COMMAND == 130 ]; then
PS1+="Script terminated by Control-C"
elif [ $LAST_COMMAND == 131 ]; then
PS1+="Fatal error signal 3"
elif [ $LAST_COMMAND == 132 ]; then
PS1+="Fatal error signal 4"
elif [ $LAST_COMMAND == 133 ]; then
PS1+="Fatal error signal 5"
elif [ $LAST_COMMAND == 134 ]; then
PS1+="Fatal error signal 6"
elif [ $LAST_COMMAND == 135 ]; then
PS1+="Fatal error signal 7"
elif [ $LAST_COMMAND == 136 ]; then
PS1+="Fatal error signal 8"
elif [ $LAST_COMMAND == 137 ]; then
PS1+="Fatal error signal 9"
elif [ $LAST_COMMAND -gt 255 ]; then
PS1+="Exit status out of range"
else
PS1+="Unknown error code"
fi
PS1+="\[${DARKGRAY}\])\[${NOCOLOR}\]\n"
else
PS1=""
fi
# User and server
local SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
local SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
if [ $SSH2_IP ] || [ $SSH_IP ] ; then
PS1+="\[${DARKGRAY}\]\u@\h"
else
PS1+="\[${DARKGRAY}\]\u"
fi
# Current directory
PS1+="\[${DARKGRAY}\]:\[${BROWN}\]\w\[${DARKGRAY}\]:"
# Skip to the next line
PS1+="\n"
if [[ $EUID -ne 0 ]]; then
PS1+="\[${GREEN}\]>\[${NOCOLOR}\] " # Normal user
else
PS1+="\[${RED}\]>\[${NOCOLOR}\] " # Root user
fi
# PS2 is used to continue a command using the \ character
PS2="\[${DARKGRAY}\]>\[${NOCOLOR}\] "
# PS3 is used to enter a number choice in a script
PS3='Please enter a number from above list: '
# PS4 is used for tracing a script in debug mode
PS4='\[${DARKGRAY}\]+\[${NOCOLOR}\] '
}
PROMPT_COMMAND='__setprompt'
Language: Cpp
BasedOnStyle: Google
AlignConsecutiveAssignments: true
AlignTrailingComments: true
AlignOperands: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
ColumnLimit: 120
IndentWidth: 4
SortIncludes: false
AccessModifierOffset: -3
[alias]
logline = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
loggraph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
BoldAsFont=-1
FontHeight=11
ThemeFile=flat-ui
Columns=160
Rows=48
Term=xterm-256color
BellType=0
###########################################
################### GIT ###################
###########################################
####### Set VIM as default editor #######
Set core.editor in your Git config: git config --global core.editor "vim"
## OR
Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim
####### Cleanup Git #######
git fetch --all
git reset --hard origin/master
## OR
git reset --hard HEAD
git clean -xffd
git pull
####### Reset Git Fork #######
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
####### Create new branch from current master #######
git checkout -b branch_anme
####### Squash Git Commits #######
git rebase -i origin/master~2 master
(replace last "pick" with "squash")
git push origin +master
git push --force
####### Sync from upstream #######
git fetch upstream
git checkout master
git merge upstream/master
###########################################
########## LibreELEC / CoreELEC ###########
###########################################
####### Build Envinonemnt #######
sudo apt-get install gcc make git autoconf texinfo pv pxz pigz pastebinit patchutils bison gettext libtool
sudo dpkg-reconfigure dash
####### Libreelec Create patch #######
./scripts/unpack moonlight
cd build.LibreELEC-Odroid_C2.arm-9.0-devel
cp -R ./moonlight-4d94439 moonlight-4d94439-original
-> modif moonlight-4d94439 contents
diff -Naur moonlight-4d94439-original moonlight-4d94439 > ../packages/addons/script/moonlight/patches/moonlight-0001-start_script_fix_for_C2.patch
./scripts/clean moonlight
####### Build Libreelec #######
PROJECT=Amlogic DEVICE=Odroid_C2 ARCH=arm
PROJECT=Amlogic DEVICE=Odroid_C2 ARCH=arm ./tools/download-tool
PROJECT=Amlogic DEVICE=Odroid_C2 ARCH=arm make -j5 image
PROJECT=Amlogic DEVICE=Odroid_C2 ARCH=arm CUSTOM_VERSION=dov-8.90.3 make -j5 image
####### CCache #######
If you add export CCACHE_DIR=$HOME/.ccache to your .bashrc
###########################################
################ VirtualBox ###############
###########################################
####### VirtualBox Shrink VDI #######
sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k
sudo rm -rf /bigemptyfile
cd C:\Program Files\Oracle\VirtualBox
VBoxManage.exe modifyhd "C:\Users\Daniel\VirtualBox VMs\Ubuntu\Ubuntu.vdi" --compact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment