manager/files/lf/lfrc
Dan Anglin 2402833b1a
feat: a new home manager
This commit updates the scope of this project to manage the files and
directories within my home directory. The Makefile and helper bash
scripts are now replaced with mage targets so that the home directory is
now managed with Mage. The state of the home directory is managed using
a JSON configuration for each machine host. The manager is a set of mage
targets to manage various aspects of the home directory. At the moment
the manager can:

- ensure specified directories are present within the home directory.
- ensure application configuration files are up-to-date and have the
  correct symlinks within the user's home configuration directory.
- manages the user's bash profile (a.k.a bashrc) file.

Other notable changes:

- The X11 xinitrc is removed because it is not currently used and won't
  be used for the forseeable future as we slowly move to Wayland.
- All bashrc configurations are now defined in one file and is now fully
  managed by the manager.
- The dunst configuration is currently removed but will make a comeback.
- The ansible configuration is removed as it is no longer used.
- The logrotate configuration is updated and now generated from a
  template.
- Added configuration for the foot terminal.
- Added configuration for the River window manager.
2024-09-12 16:35:06 +01:00

89 lines
1.7 KiB
Text

set shell bash
set shellopts '-eu'
set info size:time
map o open
map x extract
map t trash
map <delete> delete
map r rename
push mw
map q push 'w:quit<enter>
map Q push :quit<enter>
cmd open ${{
case $(file --mime-type $f -b) in
text/*) $EDITOR $fx;;
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
esac
}}
# extract files from the selected archive file using
# the method based on it's file type.
cmd extract ${{
set -f
case $f in
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
*.tar.gz|*.tgz) tar xzvf $f;;
*.tar.xz|*.txz) tar xJvf $f;;
*.zip) unzip $f;;
*.rar) unrar x $f;;
*.7z) 7z x $f;;
esac
}}
# trash moves a file to the trash folder.
cmd trash $trash-put $fx
# empty-trash empties the trash folder.
cmd empty-trash %{{
set -f
printf "Are you sure you want to empty the trash? [yes/no] "
read ans
[ $ans = "yes" ] && trash-empty
}}
# list-trash list all files and directories in the trash folder.
cmd list-trash $trash-list | less
# delete permanently deletes a file.
cmd delete %{{
set -f
printf "Are you sure you want to delete $fx? [yes/no] "
read ans
[ $ans = "yes" ] && rm -rf $fx
}}
# vim opens a file in vim.
# If the selected file is a directory
# the command opens vim in that directory
# with an empty buffer.
cmd vim ${{
if [ -d $fx ]; then
cd $fx && vim
else
vim $fx
fi
}}
# mkdir creates a new directory
cmd mkdir %{{
printf "Directory name: "
read ans
mkdir $ans
}}
# mkfile creates a new file
cmd mkfile %{{
printf "File name: "
read ans
touch $ans
}}
# rename renames a file or folder
cmd rename %{{
printf "Enter the new name: "
read ans
mv $fx $ans
}}