Change writeShellScriptBin to writeShellApplication

This commit is contained in:
Oliver Davies 2024-06-15 13:26:38 +01:00
parent 5347c04b3e
commit 9fcce5ad14
2 changed files with 43 additions and 37 deletions

View file

@ -6,13 +6,16 @@
}: }:
let let
inherit (pkgs) writeShellScriptBin; inherit (pkgs) writeShellApplication;
script-autostart = writeShellScriptBin "awesome-autostart" '' script-autostart = writeShellApplication {
set -o errexit name = "awesome-autostart";
text = ''
set -o errexit
${pkgs.nitrogen}/bin/nitrogen --set-zoom-fill --random "''${HOME}/Pictures/Wallpaper" ${pkgs.nitrogen}/bin/nitrogen --set-zoom-fill --random "''${HOME}/Pictures/Wallpaper"
''; '';
};
in in
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -3,48 +3,51 @@ let
php = pkgs.php82; php = pkgs.php82;
phpPackages = pkgs.php82Packages; phpPackages = pkgs.php82Packages;
inherit (pkgs) writeShellScriptBin; inherit (pkgs) writeShellApplication;
script-t = writeShellScriptBin "t" '' script-t = writeShellApplication {
# Credit to ThePrimeagen. name = "t";
text = ''
# Credit to ThePrimeagen.
set -o nounset set -o nounset
set -o pipefail set -o pipefail
if [[ $# -eq 1 ]]; then if [[ $# -eq 1 ]]; then
selected=$1 selected=$1
else else
# Get the session name from fuzzy-finding list of directories and generating a # Get the session name from fuzzy-finding list of directories and generating a
# tmux-safe version. # tmux-safe version.
items=$(find ~/Code/* ~/Code ~ ~/Documents /tmp \ items=$(find ~/Code/* ~/Code ~ ~/Documents /tmp \
-maxdepth 1 -mindepth 1 -type d \ -maxdepth 1 -mindepth 1 -type d \
! -name "*-old" \ ! -name "*-old" \
! -name "*.old" ! -name "*.old"
) )
selected=$(echo "''${items}" | fzf) selected=$(echo "''${items}" | fzf)
fi fi
if [[ -z "''${selected}" ]]; then if [[ -z "''${selected}" ]]; then
exit 0 exit 0
fi fi
session_name=$(basename "''${selected}" | sed 's/\./_/g') session_name=$(basename "''${selected}" | sed 's/\./_/g')
session_path="''${selected}" session_path="''${selected}"
# Git worktrees. # Git worktrees.
if [[ -e "''${selected}/main" ]]; then if [[ -e "''${selected}/main" ]]; then
session_path="''${selected}/main" session_path="''${selected}/main"
fi fi
if tmux has-session -t "''${session_name}" 2> /dev/null; then if tmux has-session -t "''${session_name}" 2> /dev/null; then
tmux attach -t "''${session_name}" tmux attach -t "''${session_name}"
fi fi
tmux new-session -d -s "''${session_name}" -c "''${session_path}" tmux new-session -d -s "''${session_name}" -c "''${session_path}"
tmux switch-client -t "''${session_name}" || tmux attach -t "''${session_name}" tmux switch-client -t "''${session_name}" || tmux attach -t "''${session_name}"
''; '';
};
in in
with pkgs; with pkgs;
[ [