updated antidote in prep for usage on laptop

This commit is contained in:
eeleater 2024-08-15 23:25:11 +02:00
parent 4dce77ed89
commit ef46d0e0a0
11 changed files with 29 additions and 281 deletions

View file

@ -1,11 +0,0 @@
if (( ${+commands[distrobox]} )); then
source /usr/share/bash-completion/completions/distrobox
source /usr/share/bash-completion/completions/distrobox-create
source /usr/share/bash-completion/completions/distrobox-enter
source /usr/share/bash-completion/completions/distrobox-ephemeral
source /usr/share/bash-completion/completions/distrobox-generate-entry
source /usr/share/bash-completion/completions/distrobox-list
source /usr/share/bash-completion/completions/distrobox-rm
source /usr/share/bash-completion/completions/distrobox-stop
source /usr/share/bash-completion/completions/distrobox-upgrade
fi

View file

@ -1,4 +0,0 @@
mkdir -p "$XDG_CACHE_HOME"/zsh &>/dev/null
autoload -Uz compinit
compinit -d "$XDG_CACHE_HOME"/zsh/compdump

View file

@ -1,33 +0,0 @@
# find out which distribution we are running on
FILE="/etc/*-release"
if [[ -f $FILE ]]; then
_distro=$(awk '/^ID=/' /etc/*-release | awk -F'=' '{ print tolower($2) }')
fi
# set an icon based on the distro
case $_distro in
*kali*) ICON="ﴣ";;
*arch*|*endeavouros*) ICON="";;
*debian*) ICON="";;
*raspbian*) ICON="";;
*ubuntu*) ICON="";;
*elementary*) ICON="";;
*fedora*) ICON="";;
*coreos*) ICON="";;
*gentoo*) ICON="";;
*mageia*) ICON="";;
*centos*) ICON="";;
*opensuse*|*tumbleweed*) ICON="";;
*sabayon*) ICON="";;
*slackware*) ICON="";;
*linuxmint*) ICON="";;
*alpine*) ICON="";;
*aosc*) ICON="";;
*nixos*) ICON="";;
*devuan*) ICON="";;
*manjaro*) ICON="";;
*rhel*) ICON="";;
*) ICON="";;
esac
export DISTROICON="$ICON"

View file

@ -1,8 +1,5 @@
# evalstuff
_evalcache fzf --zsh
_evalcache zoxide init --cmd cd zsh
_evalcache atuin init zsh
_evalcache navi widget zsh
_evalcache direnv hook zsh
#_evalcache ntfy shell-integration
#eval "$(keychain --dir "$XDG_CACHE_HOME"/keychain --eval --quiet id_rsa)"

View file

@ -1,195 +0,0 @@
export ALIASES_FILE="$XDG_CONFIG_HOME"/aliasesrc
function mal {
# Use fzf to allow the user to select an alias from the aliases file
function _execute_alias {
local alias_to_execute=$(cut -d' ' -f2- "$ALIASES_FILE" | fzf)
# Check if the user cancelled the selection
test -z $alias_to_execute && return 1
echo "Executing alias: $alias_to_execute"
# Execute the selected alias
eval ${alias_to_execute%%=*}
return 0
}
# Delete an existing alias by selecting it from a list
function _interactive_delete {
local alias_to_delete=$(cut -d' ' -f2- "$ALIASES_FILE" | fzf)
# Check if the user cancelled the selection
test -z $alias_to_delete && return 1
echo "Deleted alias: $alias_to_delete"
# Delete the selected alias from the aliases file
sed -i "/^alias ${alias_to_delete%%=*}=/d" "$ALIASES_FILE"
unalias ${alias_to_delete%%=*}
}
# Delete an existing alias using specified name
function _parameter_delete {
local alias_to_delete=$1
local line_with_alias=$(grep "$1=" "$ALIASES_FILE")
# Check if the alias exists in the aliases file
if test -z "$line_with_alias"; then
echo "No alias with the name $1 found."
return 2
fi
echo "Deleted alias: $alias_to_delete"
# Delete the selected alias from the aliases file
sed -i "/^alias ${alias_to_delete%%=*}=/d" "$ALIASES_FILE"
unalias ${alias_to_delete%%=*}
}
# Rename an existing alias by selecting it from a list
function _interactive_rename {
local alias_to_rename=$(cut -d' ' -f2- "$ALIASES_FILE" | fzf)
# Check if the user cancelled the selection
test -z $alias_to_rename && return 1
echo "Input new name:"
read new_name
echo "Renaming alias from $alias_to_rename to $new_name"
sed -i "s/^alias ${alias_to_rename%%=*}=/alias ${new_name}=/g" "$ALIASES_FILE"
unalias ${alias_to_rename%%=*}
}
# Rename an existing alias using specified old and new names
function _parameter_rename {
local old_alias_name=$1
local new_alias_name=$2
local line_with_alias=$(grep "^alias ${old_alias_name}=" "$ALIASES_FILE")
if test -z "$line_with_alias"; then
echo "No alias with the name $old_alias_name found."
return 1
fi
echo "Renaming alias from $old_alias_name to $new_alias_name"
sed -i "s/^alias ${old_alias_name}=/alias ${new_alias_name}=/g" "$ALIASES_FILE"
unalias ${old_alias_name}
}
# Change the command associated with an existing alias by selecting it from a list
function _interactive_command_change {
local alias_to_change=$(cut -d' ' -f2- "$ALIASES_FILE" | fzf)
# Check if the user cancelled the selection
test -z $alias_to_change && return 1
echo "Input new command:"
read new_command
echo "Changing command for alias ${alias_to_change%%=*} to \"$new_command\""
sed -i "/^alias ${alias_to_change%%=*}=/{s/=.*/=\"$new_command\"/}" "$ALIASES_FILE"
}
# Change the command associated with an existing alias using specified name and command
function _parameter_command_change {
local alias_to_change=$1
local new_command="${@:2}"
local line_with_alias=$(grep "$alias_to_change=" "$ALIASES_FILE")
if test -z "$line_with_alias"; then
echo "No alias with the name $alias_to_change found."
return 1
fi
echo "Changing command for alias $alias_to_change to \"$new_command\""
sed -i "/^alias ${alias_to_change}=/{s/=.*/=\"$new_command\"/}" "$ALIASES_FILE"
}
# Add a new alias
function _add_command {
local line_with_alias=$(grep "$1=" "$ALIASES_FILE")
if test ! -z "$line_with_alias"; then
echo "Alias found: $line_with_alias; change alias by using the -c flag."
return 1
fi
local lh="alias $1"
local rh=\"${@:2}\"
local alias_str="$lh=$rh"
echo $alias_str >>"$ALIASES_FILE"
echo "added '$alias_str' to .aliases"
}
# List all aliases from the aliases file
function _list_aliases {
cut -d' ' -f2- "$ALIASES_FILE" | command cat
}
# ==============================================================================================================================================================
action="$1"
param1="$2"
param2="$3"
# Check if the user has provided a help option or no arguments
helpParams=('-h' '--help' '-help')
if (($helpParams[(Ie)$action])) || test $# -eq 0; then
# Display usage information
echo "Usage: mal [OPTION]... [ALIAS_NAME] [ALIAS_COMMAND]..."
echo ""
echo "Create, delete, change, or execute aliases interactively."
echo ""
echo "Options:"
echo " -h, --help display this help and exit"
echo " -l list all defined aliases"
echo " -e execute an alias interactively"
echo " -d delete an alias interactively"
echo " -dn NAME delete an alias by name"
echo " -r rename an alias interactively"
echo " -rn OLD NEW rename an existing alias"
echo " -c change the command associated with an existing alias interactively"
echo " -cc NAME COMMAND change the command associated with an existing alias by name"
return 0
fi
case "$action" in
"-e")
# Execute an alias interactively
_execute_alias
;;
"-l")
# List all aliases
_list_aliases
;;
"-d")
# Delete an alias interactively
_interactive_delete
;;
"-dn")
# Delete an alias using a parameter
_parameter_delete "$param1"
;;
"-r")
# rename an alias interactively
_interactive_rename
;;
"-rn")
# rename an alias using parameters
_parameter_rename "$param1" "$param2"
;;
"-c")
# change a command interactively
_interactive_command_change
;;
"-cc")
# change a command using parameters
_parameter_command_change "$param1" "$param2"
;;
*)
# add a new command
_add_command "$action" "$param1"
;;
esac
# Reload aliases
source "$ALIASES_FILE"
}

View file

@ -1,5 +0,0 @@
setopt NO_CLOBBER
setopt INTERACTIVE_COMMENTS
setopt HASH_EXECUTABLES_ONLY
setopt NUMERIC_GLOB_SORT
unsetopt FLOW_CONTROL