Skip to content

Commit

Permalink
feat(tmux-lazygit-popup) add the basic working script
Browse files Browse the repository at this point in the history
  • Loading branch information
kampanosg committed Jul 3, 2024
0 parents commit 64d322e
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 0 deletions.
Empty file added .gitignore
Empty file.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: compile
compile:
@echo "Compiling..."
amber tmux-lazygit-popup.ab tmux-lazygit-popup.sh
@echo "Done!"
Empty file added README.md
Empty file.
280 changes: 280 additions & 0 deletions tmux-client-49282.log

Large diffs are not rendered by default.

280 changes: 280 additions & 0 deletions tmux-client-49802.log

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions tmux-lazygit-popup.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { exit } from "std"
import { parse_args } from "./utils.ab"

main(args) {
silent $lazygit -v$ failed {
echo "cannot execute lazygit command. make sure it is installed"
exit(1)
}

silent $tmux -V$ failed {
echo "cannot execute tmux command. make sure it is installed"
exit(1)
}

let params = parse_args(args)

$tmux display-popup -E -w {params[0]} -h {params[1]} -b {params[2]} -d {params[3]} {params[4]}$ failed {
echo "command failed"
}
}

63 changes: 63 additions & 0 deletions tmux-lazygit-popup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)

function exit__23_v0 {
local code=$1
exit "${code}"
__AS=$?
}
__0_DEFAULT_WIDTH="90%"
__1_DEFAULT_HEIGHT="90%"
__2_DEFAULT_BORDER="rounded"
__AMBER_ARRAY_0=("rounded" "single" "double" "heavy" "simple" "padded" "none");
__3_VALID_BORDERS=("${__AMBER_ARRAY_0[@]}")
function parse_args__26_v0 {
local args=("${!1}")
local width="${args[0]}"
local height="${args[1]}"
local border="${args[2]}"
if [ $([ "_${width}" != "_" ]; echo $?) != 0 ]; then
width="${__0_DEFAULT_WIDTH}"
fi
if [ $([ "_${height}" != "_" ]; echo $?) != 0 ]; then
height="${__1_DEFAULT_HEIGHT}"
fi
if [ $([ "_${border}" != "_" ]; echo $?) != 0 ]; then
border="${__2_DEFAULT_BORDER}"
fi
local cmd="lazygit"
__AMBER_VAL_0=$(tmux display-message -p '#{pane_current_path}');
__AS=$?;
if [ $__AS != 0 ]; then
echo "failed to find pwd"
fi;
local current_path="${__AMBER_VAL_0}"
__AMBER_ARRAY_1=("${width}" "${height}" "${border}" "${current_path}" "${cmd}");
__AF_parse_args26_v0=("${__AMBER_ARRAY_1[@]}");
return 0
}
args=("$@")
lazygit -v > /dev/null 2>&1
__AS=$?;
if [ $__AS != 0 ]; then
echo "cannot execute lazygit command. make sure it is installed"
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__7=$__AF_exit23_v0;
echo $__AF_exit23_v0__7 > /dev/null 2>&1
fi
tmux -V > /dev/null 2>&1
__AS=$?;
if [ $__AS != 0 ]; then
echo "cannot execute tmux command. make sure it is installed"
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__12=$__AF_exit23_v0;
echo $__AF_exit23_v0__12 > /dev/null 2>&1
fi
parse_args__26_v0 args[@];
__AF_parse_args26_v0__15=("${__AF_parse_args26_v0[@]}");
params=("${__AF_parse_args26_v0__15[@]}")
tmux display-popup -E -w ${params[0]} -h ${params[1]} -b ${params[2]} -d ${params[3]} ${params[4]}
__AS=$?;
if [ $__AS != 0 ]; then
echo "command failed"
fi
28 changes: 28 additions & 0 deletions utils.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let DEFAULT_WIDTH = "90%"
let DEFAULT_HEIGHT = "90%"
let DEFAULT_BORDER = "rounded"

pub fun parse_args(args) {
let width = args[0]
let height = args[1]
let border = args[2]

if width == "" {
width = DEFAULT_WIDTH
}

if height == "" {
height = DEFAULT_HEIGHT
}

if border == "" {
border = DEFAULT_BORDER
}

let cmd = "lazygit"
let current_path = $tmux display-message -p '#\{pane_current_path}'$ failed {
echo "failed to find pwd"
}

return [width, height, border, current_path, cmd]
}

0 comments on commit 64d322e

Please sign in to comment.