Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / fdisk-color.bash
Last active December 17, 2024 18:36
Custom version of the "fdisk" command, with color.
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=Dl2n_fcDjkE
### Add this to your .bashrc
# custom fdisk
# - add color when called with -l or -x
# - prepend sudo
function fdisk () {
@sebastiancarlos
sebastiancarlos / free-color.bash
Last active September 8, 2023 20:37
Custom version of the "free" command, with color.
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=Dl2n_fcDjkE
### Add this to your .bashrc
# custom free
# - add common options
# - add color
# - add footer
@sebastiancarlos
sebastiancarlos / less-horizontal.bash
Last active September 6, 2023 09:06
The less command... now with horizontal scrolling too!
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=lSOVozD7Iio
### Add this to your .bashrc
export LESS="--RAW-CONTROL-CHARS --quit-if-one-screen --clear-screen --tilde"
# version of less that scrolls
alias less="less --chop-long-lines --status-column --rscroll='>'"
@sebastiancarlos
sebastiancarlos / colorgpg.bash
Last active January 7, 2024 12:48
Color output for GnuPG
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=cDlWF48xaGQ
# Add this to your .bashrc
# custom gpg
# - add color output
# - replace $HOME with ~
# - Add footer with explanation of terms
@sebastiancarlos
sebastiancarlos / sourceme.bash
Last active August 25, 2023 17:19
Template for a sourceable but non-executable shell script. Useful for initialising an interactive shell environment.
#!/usr/bin/env bash
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=cOYVjk26504
red="\e[31m"
green="\e[32m"
reset="\e[0m"
@sebastiancarlos
sebastiancarlos / open_links_with_keyboard.bash
Last active August 25, 2023 02:55
Opening links in your Bash terminal with the keyboard
@sebastiancarlos
sebastiancarlos / custom-type.bash
Last active August 23, 2023 11:48
Custom version of the Bash 'type' command, navigating symlinks and aliases.
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/shorts/mYfEIZFlIwo
# Put this in your .bashrc or something like that
# pretty_print_directory
# - replace $HOME with ~
# - make everything before the last '/' green, and everything after white and
# bold
@sebastiancarlos
sebastiancarlos / show_notifications.bash
Last active July 23, 2024 08:43
Show notifications in your terminal
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/shorts/WVyqVkGYb4k
# Add this somewhere in ~/.bashrc
# write_message
# - write a message on the lower right corner of the terminal
function write_message () {
if [[ "$#" -eq 0 ]]; then
@sebastiancarlos
sebastiancarlos / edit_without_executing.bash
Last active August 5, 2024 14:50
Replacement for the "C-x e" bash binding, but without executing the command immediately. (Good for validating before running, and for performing history expansion).
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=yYsmcfWIblg
# Add this somewhere in ~/.bashrc
# __edit_without_executing
# - Replacement for the "C-x e" Bash binding, but without executing the
# command immediately. (Good for validating before running, and for performing
# history expansion).
@sebastiancarlos
sebastiancarlos / tari.bash
Last active August 23, 2023 11:51
tari - tar "in-place" - Remove duplicates when operating on tar archives
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=IyzNz1uPEGg
# deleteAllButMostRecentInTar
# source: https://stackoverflow.com/a/71666950/21567639
function deleteAllButMostRecentInTar()
{
local archive=$1
local filesToDelete=$(mktemp)