manager/config/bash/bashrc.d/functions

39 lines
939 B
Bash

## Description: All aliases are defined here.
## vim: ft=sh :
# mkcd creates a new directory (including the parent directories if they don't exist)
# and makes it the current directory.
mkcd() {
mkdir -p $1
cd $1
}
# go_up() navigates up a specified number of parent directories.
# Inspired from DT's up() function:
# https://gitlab.com/dwt1/dotfiles/-/blob/80632c5cad56ac96955e0ca1d582a4b59741bace/.bashrc#L109
go_up() {
local d=""
local steps="$1"
if [ -z "$steps" ] || [ "$steps" -lt 1 ]; then
steps=1
fi
for ((i=1; i<=steps; i++)); do
d="../$d"
done
if ! cd "$d"; then
echo "Unable to go up $steps directories."
fi
}
# run_package_updates() ensures all apt packages are updated
# and runs autoremove to remove any unused packages.
run_package_updates() {
sudo apt update
apt list --upgradable
sleep 5
sudo apt dist-upgrade
sudo apt autoremove
}