Add script functionality

This commit is contained in:
2025-10-28 20:14:32 +01:00
parent b1a6654d1c
commit 48ab557769
5 changed files with 127 additions and 0 deletions

View File

@@ -64,3 +64,28 @@ quit `lazygit` by pressing `q`.
To open a chat window to confer with your ai-bot in chatmode, you can easily
open a chatwindow to the left of your main window. To do so, press
`Ctrl+<prefix> a`. To close the window, press `Ctrl+d`.
## Building
Sometime you want to bulild your project. In this configuration a key-binding is
added to the F9 key. Pressing `Ctrl+<prefix> F9` will run a make-script that
tests (in order) for the following build-systems:
- [WAF](https://waf.io)
- [Cargo](https://doc.rust-lang.org/cargo/commands/cargo-build.html)
- [CMake](https://cmake.org/)
- [Automake](https://www.gnu.org/software/automake/)
The process will open a popup window, in which the build is performed. After the
build stops, the window will stay open until a key is pressed.
## Launch different editor layouts
The configuration comes with a script named `hxi`, which is installed into the
` ~/.local/bin` folder. When the script is started, it launches a new tmux
session with a randomised name. In this session, an editor is opened, with the
given parameters. Then the script looks for a file named `.tmux.layout`, which
needs to be an executeable script file. It then sources the file. and finally
attaches to the session, that was created. The sourced `.tmux.layout` file can
be used to create an individual layout for the project folder you're in,
creating new windows and panes, as needed.

25
scripts/hxi Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/zsh
# Runs the IDE
SESSIONID="IDE-${RANDOM}"
TMUX=$(where tmux)
# Set editor to helix, if unset
if [ -z ${EDITOR+x} ]; then
EDITOR=$(where hx)
fi
# Open a new session with a random name
$TMUX new-session -d -s $SESSINID $EDITOR
$TMUX rename-window -t ${SESSIONID}:0 "TMUX IDE"
# check, if a layout file is present, and run it.
if [ -f ./.tmux.layout ]; then
source ./.tmux.layout
fi
# Finally, select the editor window in the current session,
# and attach to the session
$TMUX select-window -t ${SESSIONID}:0
$TMUX select-pane -t 0
$TMUX attach-session -t ${SESSIONID}

3
scripts/install.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
mkdir -p ~/.local/bin
cp ~/.config/tmux/scripts/hxi ~/.local/bin

71
scripts/makescript.sh Executable file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/zsh
# configure make tools
WAF=$(where waf)
CARGO=$(where cargo)
CMAKE=$(where cmake)
MAKE=$(where make)
WAITMSG="Press any key to continue..."
function find-up() {
curpath=$(pwd)
while [[ "$curpath" != "" && ! -e "$curpath/$1" ]]; do
curpath=${curpath%/*}
done
echo $curpath
}
function wait-for-keypress() {
echo $WAITMSG
read -k
}
# look for the make file for waf
MAKEPATH=$(find-up "wscript")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'wscript' file. Building WAF project."
cd $MAKEPATH
$WAF configure build
wait-for-keypress
return 0
fi
# look for a cargo file for rust.
MAKEPATH=$(find-up "Cargo.toml")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'Cargo.toml' file. Building rust project."
cd $MAKEPATH
$CARGO build
wait-for-keypress
return 0
fi
# look for a make file for CMAKE
MAKEPATH=$(find-up "CMakeList.txt")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'CMakeList.txt' file. Building CMAKE project."
cd $MAKEPATH
$CMAKE -DCMAKE_BUILD_TYPE=Debug -S . -B ./build
$CMAKE --build ./build
wait-for-keypress
return 0
fi
# look for a classical make file
MAKEPATH=$(find-up "Makefile")
if [[ "$MAKEPATH" != "" ]]
then
cd $MAKEPATH
./configure
$MAKE
wait-for-keypress
return 0
fi
echo "No matching makefiles found"
wait-for-keypress
return 1

View File

@@ -26,6 +26,9 @@ bind-key g display-popup -d "#{pane_current_path}" -x C -y C -w 80% -h 80% -E 'l
# open an ai chat window to the left of the main screen
bind-key a split-window -bh -p 20 -c "#{pane_current_path}" 'aichat-ng'
# Call the proper make script for the current project.
bind-key F9 display-popup -d "#{pane_current_path}" -x C -y C -w 80% -h 80% -E '~/.config/tmux/scripts/makescript.sh'
# Configure the plugin manager
# List of plugins
set -g @plugin 'tmux-plugins/tpm'