dotfiles/.bashrc

59 lines
1.3 KiB
Bash

# SPDX-License-Identifier: Unlicense
# Skip script if not running interactively
if [[ $- != *i* ]] ; then
return
fi
# Set permissions for file/directory owner only by default
umask 0077
echo -ne '\e[16;125]'
export EDITOR='nvim'
export HISTCONTROL=ignorespace
export HISTFILESIZE=5000
export HISTSIZE=5000
export PATH="${PATH}:${HOME}/.local/bin"
# Use interactive option to prevent accidental data loss
alias cp='cp -pi'
alias mv='mv -i'
alias rm='rm -i'
# Short commands
alias ll='ls -l'
# Get rid of commands that have verbose output by default
alias ffmpeg='ffmpeg -hide_banner'
## Function commands ##
# Retrieves a specific line number of a specified text file.
#
# Syntax: $0 <FILENAME> <LINE NUMBER>
function lnof() {
if [[ $1 =~ ^-(-help|h)$ ]]; then
echo "syntax: $0 <FILENAME> <LINE NUMBER>" >&2
return
fi
if [[ -z "$1" || -z "$2" ]]; then
echo "error: missing required options" >&2
fi
head -n $2 $1 | tail -1
}
# Creates, then displays a temporary QR code with given data passed through
# standard input.
#
# Syntax: $0
function qrnow() {
if [[ $1 =~ ^-(-help|h)$ ]]; then
echo "$0: displays a QR code for given data"
echo "pipe data to this command to create a temporary QR code, then show it"
return
fi
qrencode -t png -o - | ffplay -hide_banner -i - >/dev/null
}