-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tmux-lazygit-popup) add the basic working script
- Loading branch information
0 parents
commit 64d322e
Showing
8 changed files
with
677 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
} |