[feat] Update flake.lock and add start-tmux script
This commit is contained in:
30
config/nix/flake.lock
generated
30
config/nix/flake.lock
generated
@@ -44,11 +44,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1704982712,
|
||||
"narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=",
|
||||
"lastModified": 1706830856,
|
||||
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "07f6395285469419cf9d078f59b5b49993198c00",
|
||||
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -125,11 +125,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1707683400,
|
||||
"narHash": "sha256-Zc+J3UO1Xpx+NL8UB6woPHyttEy9cXXtm+0uWwzuYDc=",
|
||||
"lastModified": 1707919853,
|
||||
"narHash": "sha256-qxmBGDzutuJ/tsX4gp+Mr7fjxOZBbeT9ixhS5o4iFOw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "21b078306a2ab68748abf72650db313d646cf2ca",
|
||||
"rev": "043ba285c6dc20f36441d48525402bcb9743c498",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -148,11 +148,11 @@
|
||||
},
|
||||
"locked": {
|
||||
"dir": "contrib",
|
||||
"lastModified": 1706140641,
|
||||
"narHash": "sha256-H1qHhkf7sF7yrG2rb9Ks1Y4EtLY3cXGp16KCGveJWY4=",
|
||||
"lastModified": 1707868264,
|
||||
"narHash": "sha256-Ewc5fxKb09XQeO6LeKmko0x7MxKmVCGUYwKq7w8sZD0=",
|
||||
"owner": "neovim",
|
||||
"repo": "neovim",
|
||||
"rev": "4e59422e1d4950a3042bad41a7b81c8db4f8b648",
|
||||
"rev": "a376d979bda103fa9998d05c3cc4ba56d3c3cece",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -171,11 +171,11 @@
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1706141075,
|
||||
"narHash": "sha256-o66/XFTXmcJSpEcO508V5r765HtgT8qtr+H4LRIB9BY=",
|
||||
"lastModified": 1707935913,
|
||||
"narHash": "sha256-uAkWeyJUNyZS9/u9huCoAJXyTiHw1F+5a91IDujPppk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "neovim-nightly-overlay",
|
||||
"rev": "1da2e054a16309d7d7f7669438c8b9a5ef1b4642",
|
||||
"rev": "b57bf64254630de4920177333f06b341653b1f28",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -186,11 +186,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1706006310,
|
||||
"narHash": "sha256-nDPz0fj0IFcDhSTlXBU2aixcnGs2Jm4Zcuoj0QtmiXQ=",
|
||||
"lastModified": 1707877513,
|
||||
"narHash": "sha256-sp0w2apswd3wv0sAEF7StOGHkns3XUQaO5erhWFZWXk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b43bb235efeab5324c5e486882ef46749188eee2",
|
||||
"rev": "89653a03e0915e4a872788d10680e7eec92f8600",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# https://mipmip.github.io/home-manager-option-search/
|
||||
{
|
||||
}: let
|
||||
start-tmux = (import ./scripts/start-tmux.nix) pkgs;
|
||||
in
|
||||
# https://mipmip.github.io/home-manager-option-search/
|
||||
{
|
||||
imports = [
|
||||
# Include the results of the hardware scan.
|
||||
./tmux.nix
|
||||
@@ -22,6 +24,7 @@
|
||||
g = "git";
|
||||
cd = "z";
|
||||
ls = "exa";
|
||||
t = "${start-tmux}";
|
||||
};
|
||||
interactiveShellInit = ''
|
||||
set fish_greeting
|
||||
@@ -154,10 +157,8 @@
|
||||
];
|
||||
|
||||
file = {
|
||||
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
|
||||
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
|
||||
# # symlink to the Nix store copy.
|
||||
# ".screenrc".source = dotfiles/screenrc;
|
||||
".config/tmux/sessions".source = ../tmux/sessions;
|
||||
".config/nvim".source = ../nvim;
|
||||
|
||||
# # You can also set the file content immediately.
|
||||
# ".gradle/gradle.properties".text = ''
|
||||
@@ -175,4 +176,4 @@
|
||||
"${config.home.homeDirectory}/.nix-profile/bin"
|
||||
];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
48
config/nix/scripts/start-tmux.nix
Normal file
48
config/nix/scripts/start-tmux.nix
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
pkgs.writeShellScript "start-tmux" ''
|
||||
live_sessions=$(${pkgs.tmux}/bin/tmux list-sessions 2>/dev/null)
|
||||
all_sessions=$(${pkgs.findutils}/bin/find -L ~/.config/tmux/sessions -type f -executable -printf '%f\n'| sort)
|
||||
TMUX_SESSIONS="$HOME/.config/tmux/sessions"
|
||||
# for some reason ~/.config/tmux/session doesn't work if made with quotes
|
||||
# TMUX_SESSIONS=$XDG_CONFIG_HOME/tmux/sessions
|
||||
if ! [ -z "$TMUX" ];then
|
||||
echo "Nested tmux sessions are a bad idea?"
|
||||
echo "If you want to really do this unset TMUX environment variable"
|
||||
exit 1
|
||||
fi
|
||||
IFS=$'\n'
|
||||
for live_session in $live_sessions;do
|
||||
live_session_name=$(echo $live_session | ${pkgs.coreutils}/bin/cut -d: -f1)
|
||||
if [ -z "''\${all_sessions##*$live_session_name*}" ];then # see https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash
|
||||
all_sessions="$(echo "$all_sessions" | sed "s/$live_session_name/$live_session/g")"
|
||||
else
|
||||
all_sessions=$(echo -e "$all_sessions\n$live_session")
|
||||
# Okay I know this is ugly it is 5:13 my brain is not working
|
||||
fi
|
||||
session=$(echo "''\$all_sessions" | fzf)
|
||||
session_name=$(echo $session | cut -d: -f1)
|
||||
if [ -z "$session" ];then
|
||||
exit 0
|
||||
fi
|
||||
if ! [ -z "''\${session##*created*}" ];then
|
||||
if [ -x "$TMUX_SESSIONS/$session_name" ];then
|
||||
source $TMUX_SESSIONS/$session_name
|
||||
else
|
||||
echo $TMUX_SESSIONS/$session_name not found or is not executable
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ -z "''\${session##*attached*}" ];then
|
||||
read -r -p "The session is already attached somewhere else. Attach it here too ? (y/N): " choice
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ];then
|
||||
tmux attach-session -t$session_name
|
||||
fi
|
||||
else
|
||||
tmux attach-session -t$session_name
|
||||
fi
|
||||
done
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user