feat: open notes and fix tmux

This commit is contained in:
Florian Schmitt 2024-12-09 10:21:17 +03:00
parent 48e8218774
commit 89cf7f3a75
3 changed files with 22 additions and 7 deletions

View file

@ -1,8 +1,6 @@
# Inject the right home-manager config for the machine.
{
config,
pkgs,
lib,
...
}:
let
@ -239,7 +237,9 @@ in
shellAliases = {
#tmux = "tmux -f ~/.config/tmux/tmux.conf attach || tmux -f ~/.config/tmux/tmux.conf new";
bunx = "bun --bun x";
c = "/home/mrflos/Code/nixos-config/scripts/tmux-sessionizer";
g = "lazygit";
n = "/home/mrflos/Code/nixos-config/scripts/open-notes";
s = "/home/mrflos/Code/nixos-config/scripts/ssh-connect";
t = "/home/mrflos/Code/nixos-config/scripts/tmux-sessionizer";
kdenix = "nix run github:pjones/plasma-manager --extra-experimental-features nix-command --extra-experimental-features flakes > /home/mrflos/Developpements/nixos-config/modules/home-plasma.nix";

15
scripts/open-notes Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
pushd ~/Nextcloud/Notes/ > /dev/null
if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(rg . --files --glob "*.md" | sort -r -f | fzf)
fi
if [[ -z $selected ]]; then
exit 0
fi
nvim "$selected"
popd > /dev/null

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
pushd ~/Code
pushd ~/Code > /dev/null
if [[ $# -eq 1 ]]; then
selected=$1
else
@ -15,13 +15,13 @@ selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
tmux new-session -s $selected_name -c $selected -d 'nvim .'
tmux a
exit 0
fi
if ! tmux has-session -t=$selected_name 2> /dev/null; then
tmux new-session -ds $selected_name -c $selected
tmux new-session -ds $selected_name -c $selected -d 'nvim .'
fi
tmux switch-client -t $selected_name
popd
popd > /dev/null