Skip to content

Instantly share code, notes, and snippets.

View erykpiast's full-sized avatar
🚀
Making the Web faster

Eryk Napierała erykpiast

🚀
Making the Web faster
  • Poznań, Poland
View GitHub Profile
@erykpiast
erykpiast / .zshrc
Last active March 4, 2020 11:43
Show aliases available for the last command
# I'm a lame, sorry
FIRST_RUN="true";
function show_aliases_available_for_the_last_command {
if [[ "$FIRST_RUN" == "true" ]]; then
FIRST_RUN="false";
return;
fi
local LAST_COMMAND=$(history | tail -1 | cut -d' ' -f2- | xargs);
local FOUND_ALIASES=$(alias | egrep "^[a-z]+='$LAST_COMMAND .*'$");
@erykpiast
erykpiast / git_clean_local_branches.sh
Created August 4, 2016 14:32
git_clean_local_branches
#!/bin/bash
function git_clean_local_branches {
TO_REMOVE=`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}'`;
TO_REMOVE_LINES=`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | wc -l`
if [ "$TO_REMOVE_LINES" -ne 0 ]; then
echo "Removing branches..."
printf "\n$TO_REMOVE\n\n";
echo "Proceed?";
@erykpiast
erykpiast / .bash_aliases
Created June 27, 2016 13:02
git local prune origin
function git_clean_local_branches {
TO_REMOVE=`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}'`;
TO_REMOVE_LINES=`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | wc -l`
if [ "$TO_REMOVE_LINES" -ne 0 ]; then
echo "Removing branches..."
printf "\n$TO_REMOVE\n\n";
echo "Proceed?";
select result in Yes No; do
if [[ "$result" == "Yes" ]]; then
@erykpiast
erykpiast / git_clean_untracked_safely.sh
Created December 15, 2015 11:55
Clean untracked files in git more safely
function git_clean_untracked_safely {
TO_REMOVE=`git clean -f -d -n`;
TO_REMOVE_LINES=`git clean -f -d -n | wc -l`;
if [ "$TO_REMOVE_LINES" -ne "0" ]; then
echo "Cleaning";
printf "\n$TO_REMOVE\n\n";
echo "Proceed?";
select result in Yes No; do
if [[ "$result" == "Yes" ]]; then
echo "Cleaning in progress..."