Add .e command and completionsrc

This commit is contained in:
Tobias Reisinger 2022-08-01 15:59:07 +02:00
parent 5c1bfe5b3c
commit 0dbe93759a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 46 additions and 5 deletions

View file

@ -87,6 +87,7 @@ shopt -s checkwinsize
source "$HOME/.config/environment"
source "$HOME/.config/completionsrc"
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
[ -x "$(command -v thefuck)" ] && eval $(thefuck --alias)

29
.bin/.e Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
declare -A mapper=(
["bash"]="$HOME/.bashrc"
["bspwm"]="$HOME/.config/bspwm/bspwmrc"
["qb"]="$HOME/.config/qutebrowser/config.py"
["sxhkd"]="$HOME/.config/sxhkd/sxhkdrc"
["vim"]="$HOME/.config/vim/vimrc"
["zsh"]="$HOME/.config/zsh/.zshrc"
)
if [[ -z "$1" ]]
then
echo "No argument given. Use --list (-l) to show all options."
exit
fi
if [[ "$1" == "-l" ]] || [[ "$1" == "--list" ]]
then
echo "${!mapper[@]}"
exit
fi
target="${mapper["$1"]}"
if [[ -n "$target" ]]
then
$EDITOR "$target"
else
echo "Dotfile not found. Use --list (-l) to show all options."
fi

View file

@ -1,10 +1,5 @@
#!/bin/sh
alias .evim='$EDITOR $HOME/.config/vim/vimrc'
alias .ebspwm='$EDITOR $HOME/.config/bspwm/bspwmrc'
alias .eqb='$EDITOR $HOME/.config/qutebrowser/config.py'
alias .esxhkd='$EDITOR $HOME/.config/sxhkd/sxhkdrc'
alias .ezsh='$EDITOR $HOME/.config/zsh/.zshrc'
alias .f='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
alias aliases='$EDITOR ~/.config/aliasrc && . ~/.config/aliasrc'

15
.config/completionsrc Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
_dote_completions()
{
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=()
while IFS='' read -r line
do
COMPREPLY+=("$line")
done < <(compgen -W "$(.e -l)" "${COMP_WORDS[1]}")
}
complete -F _dote_completions ".e"

View file

@ -95,6 +95,7 @@ source $ZSH/oh-my-zsh.sh
# User configuration
source "$HOME/.config/environment"
source "$HOME/.config/completionsrc"
[ -f "$HOME/.config/aliasrc" ] && source $HOME/.config/aliasrc
[ -x "$(command -v thefuck)" ] && eval $(thefuck --alias)