~hacktivista/config

f296472ec0aab369cc7e5991f7f2eeecfb3157e7 — Felix Freeman 2 years ago 657e40a
Add `allow_profile` and custom `cd` functions.

This allows to execute custom shell scripting when entering a directory.

Also drop trailing whitespace on sway defaults file.
2 files changed, 20 insertions(+), 1 deletions(-)

M root/etc/skel/.bashrc
M root/etc/sway/config.d/defaults
M root/etc/skel/.bashrc => root/etc/skel/.bashrc +19 -0
@@ 13,3 13,22 @@ chtitle () {
PROMPT_COMMAND=chtitle
PS1="[\u@\h \W]\$ "

profile_dirs="$HOME/.config/profile_dirs"

# Allow a path to load .profile on cd
allow_profile () {
    (realpath $1 2>/dev/null || pwd) >> "$profile_dirs"
    # sort and remove dupes
    sort -u "$profile_dirs" -o "$profile_dirs"
}

# Load local .profile files on each cd (if allowed)
cd () {
    command cd $@
    test -f .profile && grep -q "^$(pwd)\$" "$profile_dirs" 2>/dev/null && . .profile
}

# Spawn new shell on current directory
shpawn () {
    swaymsg exec "\$term --working-directory '$(pwd)'"
}

M root/etc/sway/config.d/defaults => root/etc/sway/config.d/defaults +1 -1
@@ 6,7 6,7 @@
include ~/.config/sway/vars

# Terminal emulator
set $term alacritty 
set $term alacritty

# Application launcher
set $menu bemenu-run | xargs swaymsg exec --