Last active
December 26, 2023 08:49
-
-
Save stokito/cb5154ad346051a7c08a0d5c9b51a792 to your computer and use it in GitHub Desktop.
.bashrc and .profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some more ls aliases | |
alias ll='ls -alF' | |
alias la='ls -A' | |
alias l='ls -CF' | |
alias dirs="ls -al | grep '^d'" | |
# Add an "alert" alias for long running commands. Use like so: | |
# sleep 10; alert | |
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' | |
function cd() { | |
new_directory="$*"; | |
if [ $# -eq 0 ]; then | |
new_directory=${HOME}; | |
fi; | |
builtin cd "${new_directory}" && ls | |
} | |
# Red STDERR | |
# rse <command string> | |
function rse() | |
{ | |
# We need to wrap each phrase of the command in quotes to preserve arguments that contain whitespace | |
# Execute the command, swap STDOUT and STDERR, colour STDOUT, swap back | |
((eval $(for phrase in "$@"; do echo -n "'$phrase' "; done)) 3>&1 1>&2 2>&3 | sed -e "s/^\(.*\)$/$(echo -en \\033)[31;1m\1$(echo -en \\033)[0m/") 3>&1 1>&2 2>&3 | |
} | |
# https://stackoverflow.com/questions/6841143/how-to-set-font-color-for-stdout-and-stderr/21320645#21320645 | |
exec 9>&2 | |
exec 8> >( | |
while IFS='' read -r line || [ -n "$line" ]; do | |
echo -e "\033[31m${line}\033[0m" | |
done | |
) | |
function undirect(){ exec 2>&9; } | |
function redirect(){ exec 2>&8; } | |
trap "redirect;" DEBUG | |
PROMPT_COMMAND='undirect;' | |
function webm2gif() { | |
ffmpeg -y -i "$1" -vf palettegen _tmp_palette.png | |
ffmpeg -y -i "$1" -i _tmp_palette.png -filter_complex paletteuse -r 10 "${1%.webm}.gif" | |
rm _tmp_palette.png | |
} | |
export TMPDIR="/home/stokito/tmp" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment