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
# Note that this uses the 'func() ( ;)' form, not 'func() { ;}' | |
# in order to contain any changes to dotglob or nullglob | |
# This means that this function will also return directories | |
# whose names begin with a dot. | |
listdirs() ( | |
shopt -s dotglob nullglob | |
set -- */ | |
printf -- '%s\n' "${@%/}" | |
) |
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
#!/bin/bash | |
# A merge of ideas from the following sources | |
# https://askubuntu.com/q/476641 | |
# https://github.com/dylanaraps/neofetch/blob/master/neofetch | |
# https://raw.githubusercontent.com/mintty/utils/master/terminal | |
# If TERM_PROGRAM is set, give it a name that we recognise | |
# Otherwise, poll the terminal and interpret what it feeds back | |
# Otherwise, try to glean the information from the PPID |
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
#!/bin/bash | |
# Scripted version of this reddit post: | |
# https://www.reddit.com/r/linuxmint/comments/dawx7s/how_i_fixed_my_ubuntu_base_to_get_the_best/ | |
# Beerware Licence and standard no warranty, no liability disclaimers | |
# TO-DO: Perhaps insert a reboot after the kernel installation | |
# Define any extra packages that we want | |
extra_packages=( | |
amd64-microcode |
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
#!/bin/bash | |
# lightswitch - Switch themes between light and dark mode | |
# This is intended for Linux hosts using the Cinnamon desktop e.g. Mint. | |
export prog_name="${0##*/}" | |
export app_filename="/usr/share/applications/${prog_name}.desktop" | |
# Set our times to switch between light and dark themes (24hr time) | |
lights_on="${lights_on:-0900}" | |
lights_off="${lights_off:-2000}" |
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
echo() { | |
case "${1}" in | |
(-e) | |
case "${2}" in | |
(-n|--end) shift 2; printf -- '%b' "${*}" ;; | |
(*) shift; printf -- '%b\n' "${*}" ;; | |
esac | |
;; | |
(-E) | |
case "${2}" in |
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
logname() { | |
case "${1}" in | |
(--home) | |
getent passwd "$(command logname)" | awk -F ':' '{print $6}' | |
;; | |
(*) | |
command logname "${@}" | |
;; | |
esac | |
} |
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
if (( BASH_VERSINFO >= 4 )); then | |
tolower() { | |
# If parameter is a file, or stdin is used, action that first | |
if [[ -r "${1}" ]]||[[ ! -t 0 ]]; then | |
# We structure our while read loop to handle no newline at EOF | |
eof= | |
while [[ -z "${eof}" ]]; do | |
read -r || eof=true | |
printf -- '%s\n' "${REPLY,,}" | |
done < "${1:-/dev/stdin}" |
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
# shellcheck shell=bash | |
################################################################################ | |
# setprompt and related/required functions | |
################################################################################ | |
# Wrap 'cd' to automatically update GIT_BRANCH when necessary | |
cd() { | |
command cd "${@}" || return 1 | |
if is_gitdir; then | |
PS1_GIT_MODE=True |
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
# Detect if our version of 'tput' is so old that it uses termcap syntax | |
# If this is the case, overlay it so that newer terminfo style syntax works | |
# Inspired by 'bashlib' and 'liquidprompt' | |
# For performance we only implement if 'tput ce' (a harmless test) works | |
if tput ce 2>/dev/null; then | |
tput() { | |
ctput-null() { command tput "${@}" 2>/dev/null; } | |
ctput() { command tput "${@}"; } | |
case "${1}" in | |
(blink) ctput-null blink || ctput mb;; |
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
# Password strength check function. Can be fed a password most ways. | |
# TO-DO: add a verbose output switch | |
pwcheck () { | |
# Read password in, if it's blank, prompt the user | |
if [[ "${*}" = "" ]]; then | |
read -resp $'Please enter the password/phrase you would like checked:\n' PwdIn | |
else | |
# Otherwise, whatever is fed in is the password to check | |
PwdIn="${*}" | |
fi |