2024-03-18 20:33:28 +00:00
|
|
|
{ inputs, pkgs, ... }:
|
2024-03-30 20:00:37 +00:00
|
|
|
let
|
|
|
|
php = pkgs.php82;
|
|
|
|
phpPackages = pkgs.php82Packages;
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 12:26:38 +00:00
|
|
|
inherit (pkgs) writeShellApplication;
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 12:26:38 +00:00
|
|
|
script-t = writeShellApplication {
|
|
|
|
name = "t";
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
openssl
|
|
|
|
tmux
|
|
|
|
];
|
|
|
|
|
|
|
|
text = ''
|
|
|
|
# Credit to ThePrimeagen and Jess Archer.
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 12:26:38 +00:00
|
|
|
if [[ $# -eq 1 ]]; then
|
2024-06-15 14:33:57 +00:00
|
|
|
SELECTED_PATH=$1
|
2024-06-15 12:26:38 +00:00
|
|
|
else
|
|
|
|
# Get the session name from fuzzy-finding list of directories and generating a
|
|
|
|
# tmux-safe version.
|
|
|
|
items=$(find ~/Code/* ~/Code ~ ~/Documents /tmp \
|
|
|
|
-maxdepth 1 -mindepth 1 -type d \
|
|
|
|
! -name "*-old" \
|
|
|
|
! -name "*.old"
|
|
|
|
)
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
SELECTED_PATH=$(echo "''${items}" | fzf)
|
2024-06-15 12:26:38 +00:00
|
|
|
fi
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
SESSION_NAME=$(basename "''${SELECTED_PATH}" | sed 's/\./_/g')
|
|
|
|
|
|
|
|
# Attach to an existing session, if one exists.
|
|
|
|
if tmux has-session -t "''${SESSION_NAME}" 2> /dev/null; then
|
|
|
|
tmux attach -t "''${SESSION_NAME}" || tmux switch-client -t "''${SESSION_NAME}"
|
|
|
|
exit
|
2024-06-15 12:26:38 +00:00
|
|
|
fi
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
# TODO: support .ignored/.tmux
|
|
|
|
if [[ -x "''${SELECTED_PATH}/.tmux" ]]; then
|
|
|
|
DIGEST="$(openssl sha512 "''${SELECTED_PATH}/.tmux")"
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
# Prompt the first time we see a given .tmux file before running it.
|
|
|
|
if ! grep -q "''${DIGEST}" ~/..tmux.digests 2> /dev/null; then
|
|
|
|
cat "''${SELECTED_PATH}/.tmux"
|
|
|
|
|
|
|
|
read -r -n 1 -p "Trust (and run) this .tmux file? (t = trust, otherwise = skip) "
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
if [[ $REPLY =~ ^[Tt]$ ]]; then
|
|
|
|
echo "''${DIGEST}" >> ~/..tmux.digests
|
|
|
|
|
|
|
|
# Create a new session and run the .tmux script.
|
|
|
|
tmux new-session -d -c "''${SELECTED_PATH}" -s "''${SESSION_NAME}"
|
|
|
|
(cd "''${SELECTED_PATH}" && "''${SELECTED_PATH}/.tmux" "''${SESSION_NAME}")
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Create a new session and run the .tmux script.
|
|
|
|
tmux new-session -d -c "''${SELECTED_PATH}" -s "''${SESSION_NAME}"
|
|
|
|
(cd "''${SELECTED_PATH}" && "''${SELECTED_PATH}/.tmux" "''${SESSION_NAME}")
|
|
|
|
fi
|
2024-06-15 12:26:38 +00:00
|
|
|
fi
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
# If there is no session, create one.
|
|
|
|
if ! tmux has-session -t "''${SESSION_NAME}" 2> /dev/null; then
|
|
|
|
tmux new-session -d -c "''${SELECTED_PATH}" -s "''${SESSION_NAME}"
|
|
|
|
fi
|
2024-06-15 11:17:07 +00:00
|
|
|
|
2024-06-15 14:33:57 +00:00
|
|
|
tmux switch-client -t "''${SESSION_NAME}" || tmux attach-session -t "''${SESSION_NAME}"
|
2024-06-15 12:26:38 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-06-10 08:31:28 +00:00
|
|
|
in
|
|
|
|
with pkgs;
|
|
|
|
[
|
2024-06-15 11:17:07 +00:00
|
|
|
script-t
|
|
|
|
|
2024-05-22 08:00:00 +00:00
|
|
|
inputs.build-configs.packages.${pkgs.system}.default
|
|
|
|
|
2024-03-30 22:22:39 +00:00
|
|
|
awscli2
|
2024-02-27 18:33:03 +00:00
|
|
|
bitwarden-cli
|
2023-03-22 22:56:56 +00:00
|
|
|
bottom
|
2024-03-01 21:30:54 +00:00
|
|
|
cachix
|
2023-03-22 22:56:56 +00:00
|
|
|
ctop
|
|
|
|
delta
|
2023-06-28 19:49:08 +00:00
|
|
|
dog
|
2023-03-22 22:56:56 +00:00
|
|
|
doppler
|
2024-03-22 07:31:30 +00:00
|
|
|
entr
|
2023-06-28 19:49:08 +00:00
|
|
|
fd
|
2023-03-22 22:56:56 +00:00
|
|
|
file
|
|
|
|
gcc
|
|
|
|
gh
|
|
|
|
git
|
|
|
|
git-crypt
|
2023-06-22 06:55:59 +00:00
|
|
|
gnupg
|
2023-09-22 06:45:29 +00:00
|
|
|
go
|
2023-03-22 22:56:56 +00:00
|
|
|
htop
|
2023-06-28 19:49:08 +00:00
|
|
|
inotify-tools
|
2023-03-22 22:56:56 +00:00
|
|
|
jq
|
|
|
|
lua
|
|
|
|
mysql
|
2024-03-30 20:00:37 +00:00
|
|
|
php
|
|
|
|
phpPackages.composer
|
2023-03-22 22:56:56 +00:00
|
|
|
pv
|
2024-01-14 09:11:03 +00:00
|
|
|
rustywind
|
2023-03-22 22:56:56 +00:00
|
|
|
tldr
|
|
|
|
tree
|
2023-06-28 19:49:08 +00:00
|
|
|
tree-sitter
|
2023-03-22 22:56:56 +00:00
|
|
|
unzip
|
|
|
|
virtualenv
|
|
|
|
wget
|
|
|
|
xcp
|
2023-06-28 19:49:08 +00:00
|
|
|
xh
|
2023-03-22 22:56:56 +00:00
|
|
|
yarn
|
|
|
|
]
|