# Pastebin R1CZcj7o use_nix() { eval "$(lorri direnv)" ruby -e '`pgrep -xf "lorri watch"`.split.map{|pid| File.read(%(/proc/#{pid.strip}/environ)).scan(/PWD=([^\0]+)/) }.flatten.map{|dir| File.realpath(dir) rescue nil }.include?(Dir.pwd) || exit(1)' if [[ $? == 1 ]]; then lorri watch 2>/dev/null 1>/dev/null & pid=$! echo "started lorri watch with pid $pid" disown $pid fi }