mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nix: expose shared home manager configuration via homeModules
This commit is contained in:
parent
5155bd69e8
commit
5b95c43559
47 changed files with 45 additions and 29 deletions
85
nix/homeModules/fish/aliasesAbbrs.nix
Normal file
85
nix/homeModules/fish/aliasesAbbrs.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
pkgs,
|
||||
hostname,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
programs.fish = {
|
||||
shellAbbrs = lib.mkMerge [
|
||||
{
|
||||
## Docker
|
||||
dc = "docker compose";
|
||||
|
||||
## Git
|
||||
gaa = "git add (git rev-parse --show-toplevel)";
|
||||
"ga." = "git add .";
|
||||
grg = "git remote get-url";
|
||||
gra = "git remote add";
|
||||
gc = "git commit";
|
||||
gca = "git commit --amend";
|
||||
gs = "git stash --all";
|
||||
gp = "git pull";
|
||||
gP = "git push";
|
||||
gb = "git blame -C -C -C";
|
||||
clone = "clone_to_repos";
|
||||
|
||||
## Editor
|
||||
ts = "tmux_sessionizer";
|
||||
ta = "tmux_attach";
|
||||
v = "nvim";
|
||||
|
||||
":q" = "exit";
|
||||
|
||||
## Preferences
|
||||
np = "cd ~/.dotfiles && $EDITOR flake.nix && prevd";
|
||||
nd = "nix develop -L -c fish";
|
||||
vp = "cd ~/.dotfiles/.config/nvim && $EDITOR init.lua && prevd";
|
||||
xp = "cd ~/.dotfiles/.config/xmonad && $EDITOR xmonad.hs && prevd";
|
||||
}
|
||||
|
||||
# TODO: move this out
|
||||
(lib.mkIf pkgs.stdenv.isLinux {
|
||||
ss = "sudo systemctl";
|
||||
se = "SUDO_EDITOR=(which nvim) sudoedit";
|
||||
ns = "sudo nixos-rebuild switch -L --flake ~/.dotfiles#${hostname}";
|
||||
hs = "home-manager switch -L --flake ~/.dotfiles#${hostname}";
|
||||
})
|
||||
|
||||
(lib.mkIf pkgs.stdenv.isDarwin {
|
||||
ns = "darwin-rebuild switch -L --flake ~/.dotfiles#${hostname} --option sandbox false";
|
||||
ndd = "nix develop -L --option sandbox false -c true"; # run the develop once without sandbox when needed
|
||||
})
|
||||
];
|
||||
|
||||
shellAliases = lib.mkMerge [
|
||||
{
|
||||
rm = "rm -i"; # idiot protection
|
||||
tree = "tree -Cph";
|
||||
restow = "cd ~/.dotfiles/ && stow -D . && stow -S . && prevd";
|
||||
nix-shell = "nix-shell --run fish";
|
||||
",," = "nix shell -c";
|
||||
}
|
||||
|
||||
(lib.mkIf pkgs.stdenv.isLinux {
|
||||
chmod = "chmod --preserve-root";
|
||||
chown = "chown --preserve-root";
|
||||
})
|
||||
|
||||
(lib.mkIf pkgs.stdenv.isDarwin {
|
||||
hide_desktop = ''
|
||||
defaults write com.apple.finder CreateDesktop false; killall Finder
|
||||
'';
|
||||
show_desktop = ''
|
||||
defaults write com.apple.finder CreateDesktop true; killall Finder
|
||||
'';
|
||||
reset_launchpad = ''
|
||||
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
|
||||
'';
|
||||
add_spacer_tile = ''
|
||||
defaults write com.apple.dock persistent-apps -array-add '{tile-type="small-spacer-tile";}'; killall Dock
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
11
nix/homeModules/fish/conf.d/bind.fish
Normal file
11
nix/homeModules/fish/conf.d/bind.fish
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
for mode in default insert
|
||||
bind --mode $mode \cg tmux_home
|
||||
bind --mode $mode \cf tmux_sessionizer
|
||||
end
|
||||
|
||||
# vi cursor style
|
||||
fish_vi_key_bindings
|
||||
set fish_cursor_default block
|
||||
set fish_cursor_insert line
|
||||
set fish_cursor_replace_one underscore
|
||||
set fish_cursor_visual block
|
||||
100
nix/homeModules/fish/conf.d/colorscheme.fish
Normal file
100
nix/homeModules/fish/conf.d/colorscheme.fish
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# Learn more: https://fishshell.com/docs/current/interactive.html
|
||||
|
||||
begin
|
||||
# scope this in a bolck to not leak variables everywhere
|
||||
|
||||
set -l black 000000
|
||||
set -l grey a0a1a7
|
||||
set -l cyan 0184bc
|
||||
set -l blue 4078f2
|
||||
set -l purple a626a4
|
||||
set -l green 50a14f
|
||||
set -l orange e45649
|
||||
set -l red ca1243
|
||||
set -l brown 986801
|
||||
set -l gold c18401
|
||||
set -l accent 645199
|
||||
set -l visual d0d0d0
|
||||
|
||||
###########
|
||||
# General #
|
||||
###########
|
||||
# default color
|
||||
set fish_color_normal $black
|
||||
# commands like echo
|
||||
set fish_color_command $blue
|
||||
# keywords like if - this falls back on the command color if unset
|
||||
set fish_color_keyword $purple
|
||||
# quoted text like "abc"
|
||||
set fish_color_quote $green
|
||||
# IO redirections like >/dev/null
|
||||
set fish_color_redirection $gold
|
||||
# process separators like ; and &
|
||||
set fish_color_end $black --bold
|
||||
# syntax errors
|
||||
set fish_color_error $black
|
||||
# ordinary command parameters
|
||||
set fish_color_param $red
|
||||
# parameters that are filenames (if the file exists)
|
||||
set fish_color_valid_path --italics
|
||||
# options starting with “-”, up to the first “--” parameter
|
||||
set fish_color_option $cyan
|
||||
# comments like ‘# important’
|
||||
set fish_color_comment $grey
|
||||
# selected text in vi visual mode
|
||||
set fish_color_selection --background=$visual
|
||||
# parameter expansion operators like * and ~
|
||||
set fish_color_operator $orange
|
||||
# character escapes like \n and \x70
|
||||
set fish_color_escape $purple
|
||||
# autosuggestions (the proposed rest of a command)
|
||||
set fish_color_autosuggestion $grey
|
||||
# The current working directory in the default prompt
|
||||
set fish_color_cwd $black
|
||||
# The current working directory in the default prompt for the root user
|
||||
set fish_color_cwd_root $red
|
||||
# The username in the default prompt
|
||||
set fish_color_user $grey
|
||||
# The hostname in the default prompt
|
||||
set fish_color_host $black
|
||||
# the hostname in the default prompt for remote sessions (like ssh)
|
||||
set fish_color_host_remote $red
|
||||
# the last command’s nonzero exit code in the default prompt
|
||||
set fish_color_status $red
|
||||
# the ‘^C’ indicator on a canceled command
|
||||
set fish_color_cancel $accent --reverse
|
||||
# history search matches and selected pager items (background only)
|
||||
set fish_color_search_match --background $visual
|
||||
|
||||
#########
|
||||
# Pager #
|
||||
#########
|
||||
# the progress bar at the bottom left corner
|
||||
set fish_pager_color_progress --reverse $cyan
|
||||
# the background color of a line
|
||||
set fish_pager_color_background $black
|
||||
# the prefix string, i.e. the string that is to be completed
|
||||
set fish_pager_color_prefix $black
|
||||
# the completion itself, i.e. the proposed rest of the string
|
||||
set fish_pager_color_completion $grey
|
||||
# the completion description
|
||||
set fish_pager_color_description $grey
|
||||
# background of the selected completion
|
||||
set fish_pager_color_selected_background $black
|
||||
# prefix of the selected completion
|
||||
set fish_pager_color_selected_prefix
|
||||
# suffix of the selected completion
|
||||
set fish_pager_color_selected_completion $red
|
||||
# description of the selected completion
|
||||
set fish_pager_color_selected_description $gold
|
||||
|
||||
# ## Alternating colors
|
||||
# # background of every second unselected completion
|
||||
# set fish_pager_color_secondary_background --background=$tinted_bg
|
||||
# # prefix of every second unselected completion
|
||||
# set fish_pager_color_secondary_prefix
|
||||
# # suffix of every second unselected completion
|
||||
# set fish_pager_color_secondary_completion
|
||||
# # description of every second unselected completion
|
||||
# set fish_pager_color_secondary_description
|
||||
end
|
||||
6
nix/homeModules/fish/conf.d/interactiveShellInit.fish
Normal file
6
nix/homeModules/fish/conf.d/interactiveShellInit.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# fzf preview theme (use delta instead of bat)
|
||||
set -x fzf_preview_file_cmd 'delta'
|
||||
# fd uses LS_COLORS
|
||||
set -x LS_COLORS (vivid -m 24-bit generate one-light)
|
||||
# fzf-fish search hidden files
|
||||
set -x fzf_fd_opts --hidden --exclude=.git
|
||||
14
nix/homeModules/fish/conf.d/locale.fish
Normal file
14
nix/homeModules/fish/conf.d/locale.fish
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# zh_TW
|
||||
# set -x LANG zh_TW.UTF-8
|
||||
# set -x LANGUAGE zh_TW
|
||||
# set -x LC_ALL zh_TW.UTF-8
|
||||
|
||||
# fr_FR
|
||||
# set -x LANG fr_FR.UTF-8
|
||||
# set -x LANGUAGE fr_FR
|
||||
# set -x LC_ALL fr_FR.UTF-8
|
||||
|
||||
# en_US
|
||||
set -x LANG en_US.UTF-8
|
||||
set -x LANGUAGE en_US
|
||||
set -x LC_ALL en_US.UTF-8
|
||||
4
nix/homeModules/fish/conf.d/shellInit.fish
Normal file
4
nix/homeModules/fish/conf.d/shellInit.fish
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# repo paths
|
||||
set REPOS_PATH ~/repos
|
||||
set UNIV_REPOS_PATH ~/univ-repos
|
||||
set PLAYGROUND_PATH ~/playground
|
||||
106
nix/homeModules/fish/default.nix
Normal file
106
nix/homeModules/fish/default.nix
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [ ./aliasesAbbrs.nix ];
|
||||
|
||||
programs.fish =
|
||||
let
|
||||
readConfig = n: builtins.readFile ./conf.d/${n}.fish;
|
||||
readConfigs = ns: builtins.concatStringsSep "\n" (map readConfig ns);
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
||||
shellInit = ''
|
||||
${readConfig "shellInit"}
|
||||
|
||||
# Just in case $PATH is broken, add them in an idempotent fashion
|
||||
fish_add_path --prepend --move /nix/var/nix/profiles/default/bin
|
||||
fish_add_path --prepend --move ${config.home.homeDirectory}/.local/.local/bin
|
||||
fish_add_path --prepend --move ${config.home.homeDirectory}/.dotfiles/.local/bin
|
||||
fish_add_path --prepend --move ${config.home.homeDirectory}/.nix-profile/bin
|
||||
fish_add_path --prepend --move /run/current-system/sw/bin
|
||||
fish_add_path --prepend --move /etc/profiles/per-user/${config.home.username}/bin # prioritize user path
|
||||
|
||||
# Make sure wrapper comes first
|
||||
# https://discourse.nixos.org/t/sudo-run-current-system-sw-bin-sudo-must-be-owned-by-uid-0-and-have-the-setuid-bit-set-and-cannot-chdir-var-cron-bailing-out-var-cron-permission-denied/20463/2
|
||||
fish_add_path --prepend --move /run/wrappers/bin
|
||||
|
||||
${lib.strings.optionalString pkgs.stdenv.isDarwin ''
|
||||
# Add brew, but as fallback
|
||||
# Don't move it at all
|
||||
fish_add_path --path --append /opt/homebrew/bin; :
|
||||
''}
|
||||
'';
|
||||
|
||||
interactiveShellInit = readConfigs [
|
||||
"interactiveShellInit"
|
||||
"bind"
|
||||
"colorscheme"
|
||||
"locale"
|
||||
];
|
||||
|
||||
functions =
|
||||
let
|
||||
makeFishFunctions =
|
||||
ns:
|
||||
lib.trivial.pipe ns [
|
||||
(map (n: {
|
||||
name = n;
|
||||
value = builtins.readFile ./functions/${n}.fish;
|
||||
}))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
in
|
||||
makeFishFunctions [
|
||||
","
|
||||
"clone_to_repos"
|
||||
"file_extension"
|
||||
"file_mantissa"
|
||||
"fish_command_not_found"
|
||||
"fish_greeting"
|
||||
"fish_remove_path"
|
||||
"largest-objects-in-repo"
|
||||
"snakecase"
|
||||
"timestamp"
|
||||
"tmux_attach"
|
||||
"tmux_home"
|
||||
"tmux_last"
|
||||
"tmux_sessionizer"
|
||||
"update_dotfiles"
|
||||
];
|
||||
plugins = [
|
||||
{
|
||||
name = "fzf-fish";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "PatrickF1";
|
||||
repo = "fzf.fish";
|
||||
rev = "v10.3";
|
||||
hash = "sha256-T8KYLA/r/gOKvAivKRoeqIwE2pINlxFQtZJHpOy9GMM=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "colored-man-pages";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "PatrickF1";
|
||||
repo = "colored_man_pages.fish";
|
||||
rev = "f885c2507128b70d6c41b043070a8f399988bc7a";
|
||||
sha256 = "sha256-ii9gdBPlC1/P1N9xJzqomrkyDqIdTg+iCg0mwNVq2EU=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "sponge";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "meaningful-ooo";
|
||||
repo = "sponge";
|
||||
sha256 = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w=";
|
||||
rev = "1.1.0";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
8
nix/homeModules/fish/functions/,.fish
Normal file
8
nix/homeModules/fish/functions/,.fish
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
set ps
|
||||
for p in $argv
|
||||
set -a ps "nixpkgs#$p"
|
||||
end
|
||||
|
||||
set cmd "nix shell $ps"
|
||||
echo "Executing `$cmd`..."
|
||||
eval $cmd
|
||||
9
nix/homeModules/fish/functions/clone_to_repos.fish
Normal file
9
nix/homeModules/fish/functions/clone_to_repos.fish
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
if count $argv > /dev/null
|
||||
set name_repo (echo $argv | sed -E 's/.*[:\/]([[:alnum:]._-]+)\/([[:alnum:]._-]+).git$/\1 \2/')
|
||||
set name (echo $name_repo | cut -d ' ' -f1)
|
||||
set repo (echo $name_repo | cut -d ' ' -f2)
|
||||
mkdir -p $REPOS_PATH/$name
|
||||
git clone $argv $REPOS_PATH/$name/$repo
|
||||
else
|
||||
echo "Please provide a git url"
|
||||
end
|
||||
6
nix/homeModules/fish/functions/file_extension.fish
Normal file
6
nix/homeModules/fish/functions/file_extension.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if count $argv >/dev/null
|
||||
echo (basename $argv) | sed 's/.*\(\.[^.]*$\)/\1/'
|
||||
else
|
||||
echo "Please supply a path"
|
||||
return 1
|
||||
end
|
||||
6
nix/homeModules/fish/functions/file_mantissa.fish
Normal file
6
nix/homeModules/fish/functions/file_mantissa.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if count $argv >/dev/null
|
||||
echo (basename $argv) | sed 's/\.[^.]*$//'
|
||||
else
|
||||
echo "Please supply a path"
|
||||
return 1
|
||||
end
|
||||
14
nix/homeModules/fish/functions/fish_command_not_found.fish
Normal file
14
nix/homeModules/fish/functions/fish_command_not_found.fish
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
set hour (date +"%H")
|
||||
set user (whoami)
|
||||
|
||||
set words \
|
||||
"Are you drunk ??" \
|
||||
"Il est seulement $hour heures" \
|
||||
"Reveille-toi, $user" \
|
||||
"Magique de vim !" \
|
||||
"Magique de nix !" \
|
||||
"As-tu ecris ton journal aujourd'hui ?"
|
||||
|
||||
set choice $words[(random 1 (count $words))]
|
||||
|
||||
echo -e $choice | figlet -c
|
||||
12
nix/homeModules/fish/functions/fish_greeting.fish
Normal file
12
nix/homeModules/fish/functions/fish_greeting.fish
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
set_color --italics
|
||||
switch $FISH_GREETING
|
||||
case "toh"
|
||||
cat ~/.quotes/toh/* | shuf -n 1
|
||||
case "fleabag"
|
||||
cat ~/.quotes/fleabag/* | shuf -n 1
|
||||
case "date"
|
||||
date
|
||||
case "citation"
|
||||
~/.local/bin/citation.py
|
||||
case "*"
|
||||
end
|
||||
6
nix/homeModules/fish/functions/fish_remove_path.fish
Normal file
6
nix/homeModules/fish/functions/fish_remove_path.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if set index (contains -i $argv[1] $fish_user_path)
|
||||
set --erase --universal fish_user_paths[$index]
|
||||
echo "Updated fish_user_path: $fish_user_path"
|
||||
else
|
||||
echo "$argv[1] not found in fish_user_path: $fish_user_path"
|
||||
end
|
||||
28
nix/homeModules/fish/functions/largest-objects-in-repo.fish
Normal file
28
nix/homeModules/fish/functions/largest-objects-in-repo.fish
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Shows you the largest objects in your repo's pack file. Written for osx.
|
||||
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
|
||||
# @author Antony Stubbs
|
||||
# translated to fish with ChatGPT, reviewed by Léana :P
|
||||
|
||||
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
|
||||
set -x IFS "\n"
|
||||
|
||||
# list all objects including their size, sort by size, take top 10
|
||||
set objects (git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head)
|
||||
|
||||
echo "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file."
|
||||
|
||||
set output "size,pack,SHA,location"
|
||||
for obj in $objects
|
||||
# extract the size in bytes
|
||||
set size (math (echo $obj | cut -f 5 -d ' ') / 1024)
|
||||
# extract the compressed size in bytes
|
||||
set compressedSize (math (echo $obj | cut -f 6 -d ' ') / 1024)
|
||||
# extract the SHA
|
||||
set sha (echo $obj | cut -f 1 -d ' ')
|
||||
# find the objects location in the repository tree
|
||||
set other (git rev-list --all --objects | grep $sha)
|
||||
#lineBreak=`echo -e "\n"`
|
||||
set output "$output\n$size,$compressedSize,$other"
|
||||
end
|
||||
|
||||
echo -e $output | column -t -s ', '
|
||||
1
nix/homeModules/fish/functions/snakecase.fish
Normal file
1
nix/homeModules/fish/functions/snakecase.fish
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo $argv | sed -E 's/[^A-Za-z0-9_\n]+/_/g' | sed -E 's/__+/_/g' | tr '[:upper:]' '[:lower:]'
|
||||
1
nix/homeModules/fish/functions/timestamp.fish
Normal file
1
nix/homeModules/fish/functions/timestamp.fish
Normal file
|
|
@ -0,0 +1 @@
|
|||
date +%s
|
||||
21
nix/homeModules/fish/functions/tmux_attach.fish
Normal file
21
nix/homeModules/fish/functions/tmux_attach.fish
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# abandon if tmux not running
|
||||
set tmux_running (pgrep tmux)
|
||||
if [ -z "$tmux_running" ]
|
||||
return 0
|
||||
end
|
||||
|
||||
set selected (tmux list-sessions -F "#{session_name}" | fzf)
|
||||
if [ -z $selected ]
|
||||
return 0
|
||||
end
|
||||
|
||||
# echo "---attach---" >> /tmp/TMUX_DEBUG
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
echo (tmux display-message -p '#S') > /tmp/TMUX_LAST
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
|
||||
if [ -z $TMUX ]
|
||||
tmux attach-session -t $selected
|
||||
else
|
||||
tmux switch-client -t $selected
|
||||
end
|
||||
18
nix/homeModules/fish/functions/tmux_home.fish
Normal file
18
nix/homeModules/fish/functions/tmux_home.fish
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# echo "---home---" >> /tmp/TMUX_DEBUG
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
echo (tmux display-message -p '#S') > /tmp/TMUX_LAST
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
|
||||
# create session if doesn't exist
|
||||
if ! tmux has-session -t="home" 2> /dev/null
|
||||
tmux \
|
||||
new-session -ds "home" \; \
|
||||
new-window -t "home" \; \
|
||||
select-window -t "home":1
|
||||
end
|
||||
|
||||
if [ -z $TMUX ]
|
||||
tmux attach-session -t "home"
|
||||
else
|
||||
tmux switch-client -t "home"
|
||||
end
|
||||
19
nix/homeModules/fish/functions/tmux_last.fish
Normal file
19
nix/homeModules/fish/functions/tmux_last.fish
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# create session if doesn't exist
|
||||
set session_name (cat /tmp/TMUX_LAST)
|
||||
if ! tmux has-session -t=$session_name 2> /dev/null
|
||||
tmux \
|
||||
new-session -ds $session_name \; \
|
||||
new-window -t $session_name \; \
|
||||
select-window -t $session_name:1
|
||||
end
|
||||
|
||||
# echo "---last---" >> /tmp/TMUX_DEBUG
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
echo (tmux display-message -p '#S') > /tmp/TMUX_LAST
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
|
||||
if [ -z $TMUX ]
|
||||
tmux attach-session -t $session_name
|
||||
else
|
||||
tmux switch-client -t $session_name
|
||||
end
|
||||
48
nix/homeModules/fish/functions/tmux_sessionizer.fish
Normal file
48
nix/homeModules/fish/functions/tmux_sessionizer.fish
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Inspired by the one and only primeagen
|
||||
set selected \
|
||||
(begin
|
||||
# use fd even though it's an extra dependency because find is too slow
|
||||
fd . $REPOS_PATH $UNIV_REPOS_PATH --exact-depth 2 --type d;
|
||||
fd . $PLAYGROUND_PATH --exact-depth 1 --type d;
|
||||
echo "play"
|
||||
end 2> /dev/null | sed -e "s|^$HOME|~|" | fzf)
|
||||
|
||||
set selected (echo $selected | sed -e "s|^~|$HOME|")
|
||||
|
||||
if [ -z $selected ]
|
||||
commandline --function repaint
|
||||
return 0
|
||||
end
|
||||
|
||||
switch $selected
|
||||
case "play"
|
||||
read -P "Give it a name: " name
|
||||
if test -z $name
|
||||
return 0
|
||||
else
|
||||
set name (snakecase $name)
|
||||
set selected ~/playground/$name/
|
||||
mkdir -p $selected
|
||||
end
|
||||
end
|
||||
|
||||
set session_name (echo $selected | tr . _)
|
||||
# echo "---sess---" >> /tmp/TMUX_DEBUG
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
echo (tmux display-message -p '#S') > /tmp/TMUX_LAST
|
||||
# echo (cat /tmp/TMUX_LAST) >> /tmp/TMUX_DEBUG
|
||||
|
||||
# create session if doesn't exist
|
||||
if ! tmux has -t=$session_name 2> /dev/null
|
||||
tmux \
|
||||
new-session -ds $session_name -c $selected \; \
|
||||
send-keys -t $session_name $EDITOR ENTER \; \
|
||||
new-window -t $session_name -c $selected \; \
|
||||
select-window -t $session_name:1 \;
|
||||
end
|
||||
|
||||
if [ -z $TMUX ]
|
||||
tmux attach-session -t $session_name
|
||||
else
|
||||
tmux switch-client -t $session_name
|
||||
end
|
||||
6
nix/homeModules/fish/functions/update_dotfiles.fish
Normal file
6
nix/homeModules/fish/functions/update_dotfiles.fish
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
cd ~/.dotfiles/
|
||||
git reset --hard
|
||||
git pull --set-upstream origin main
|
||||
git submodule update --init
|
||||
prevd
|
||||
restow
|
||||
Loading…
Add table
Add a link
Reference in a new issue