# Type alias-find command for help on that alias alias-find() { grep "$1" *.sh } alias-new() { if [ -z "$1" ]; then echo "Create new alias called?" else pushd ~/.aliases.d nano "${1//.sh}".sh if [ -f ~/.data/.sane_checker.sum ]; then echo -e "Enter sudo password for sane_checker...\n" sudo chattr -i ~/.data/.sane_checker.sum sudo chmod 644 ~/.data/.sane_checker.sum rm ~/.data/.sane_checker.sum fi popd fi } alias alias-update='alias-new' alias-help() { echo -e "Alias Help:\n" echo -e "my-aliases - will use fzf selection box to pick an alias to edit.\n" echo -e "alias-find - will search for a given command and tell which alias file contains it.\n" echo -e "aliases - will cd into aliases folder.\n" echo -e "alias-new - Followed by a filename will make a new alais file.\n" echo -e "cmd - will less out alias command file.\n" echo -e "cmds - will list all alias command files.\n" echo -e "cmds-print - will print all alias commands.\n" echo -e "calias - will edit alias command env file.\n" echo -e "alias-reload - will reload bashrc...\n" echo -e "cheat - Followed by Cheat file to view. If empty, all cheat files are displayed.\n" echo -e "cheats - will cd into cheats folder.\n" } cheats=~/cheats/ alias cheats="cd ${cheats}" alias list-cheats='ls -1 ${cheats}*.txt | sed -e "s,${cheats},,g"' cheat() { if [ -f ~/cheats/$1.txt ]; then less -X ~/cheats/$1.txt else if [ -f ~/cheats/$1 ]; then less -X ~/cheats/$1 else list-cheats fi fi } alias alias-reload='unalias -a && . $HOME/.bashrc' alias alias-guide='dialog --title "Alias Profiles Guide" --textbox ~/cheats/guide 0 0; clear' my-aliases() { local sys_aliases=$(find ~/.aliases.d/ -type f -name "*.sh") local selected_alias=$(printf "%s\n" "${sys_aliases[@]}" | fzf --prompt "Select Alias file: ") if [ -z "$selected_alias" ]; then echo "No Alias selected." return 1 fi nano "$selected_alias" } cmds-print() { lpstat -d | grep "no system default destination" if [ $? -eq 0 ]; then if [ -z $1 ]; then echo "Please enter pritner dest:" lpstat -t else lpoptions -d $1 fi else echo "..." > /tmp/pcommands.txt for f in ~/.aliases.d/*.sh; do if [ "$f" == "kubectl-cheat-sheet.sh" ]; then # skip large file continue fi echo "Reading Aliases for ${f}" >> /tmp/pcommands.txt cat "${f}" >> /tmp/pcommands.txt done lpr /tmp/pcommands.txt fi }