aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--src/c_defs.go63
-rw-r--r--src/c_exec.go21
-rw-r--r--src/c_fuzz.go38
-rw-r--r--src/c_hardflip.go6
-rw-r--r--src/c_utils.go3
-rw-r--r--src/e_keys.go1
-rw-r--r--src/i_help.go4
-rw-r--r--src/i_host.go2
-rw-r--r--src/i_info.go2
-rw-r--r--src/i_insert.go2
11 files changed, 79 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index 88597ab..a347df2 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ DEST := /usr
.DEFAULT_GOAL := ${TARGET}
run: ${SRC}
- go run ${SRC_DIR}
+ go run ${SRC_DIR} -s
${TARGET}: ${SRC}
go build -o ${TARGET} ${SRC_DIR}
diff --git a/src/c_defs.go b/src/c_defs.go
index 82ddd5c..fc6c4c2 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -56,7 +56,7 @@ const (
STYLE_FILE_NAME = "colors.yml"
CONF_DIR_NAME = "hf"
DATA_DIR_NAME = "hf"
- VERSION = "v1.0.2"
+ VERSION = "v1.0.3"
VERSION_NAME = "wheelbite"
)
@@ -185,44 +185,31 @@ const (
INSERT_EDIT
)
-var INSERT_HINTS = [INS_MAX]string{
- "Select the protocol used to connect to your host",
- "IP or domain name of your host",
- "Port used for SSH (default: 22)",
- "User used to log in (default: root)",
- "Password for your user",
- "SSH private key used to log in instead of a password",
- "Optional shell command line that will be run on your host",
- "IP or domain name of your jump host",
- "Port used for your jump SSH host (default: 22)",
- // NOTE: fuck this anyway
- }
-
var HELP_NORMAL_KEYS = [][2]string{
- {"<down> | j", "Go to next item"},
- {"<up> | k", "Go to previous item"},
- {"<pgdown> | <c-d>", "Jump down"},
- {"<pgup> | <c-u>", "Jump up"},
- {"} | ]", "Go to next directory"},
- {"{ | [", "Go to previous directory"},
- {"g", "Go to first item"},
- {"G", "Go to last item"},
- {"D", "Delete selected item"},
- {"h", "Close current directory"},
- {"H", "Close all directories"},
- {"l | <space>", "Toggle directory"},
- {"<right> | l | <enter>", "Connect to selected host / toggle directory"},
- {"a | i", "Create a new host"},
- {"y", "Copy selected host"},
- {"d", "Cut selected host"},
- {"p", "Paste host in clipboard"},
- {"<f7> | m", "Create a new directory"},
- {"e", "Edit selected host"},
- {"c | C | A", "Rename selected item"},
- {"<c-r>", "Reload data and configuration"},
- {"/ | <c-f>", "Fuzzy search"},
- {"?", "Display this help menu"},
- {"<c-c> | q", "Quit"},
+ {"<down> | j", "go to next item"},
+ {"<up> | k", "go to previous item"},
+ {"<pgdown> | <c-d>", "jump down"},
+ {"<pgup> | <c-u>", "jump up"},
+ {"} | ]", "go to next directory"},
+ {"{ | [", "go to previous directory"},
+ {"g", "go to first item"},
+ {"G", "go to last item"},
+ {"D", "delete selected item"},
+ {"h", "close current directory"},
+ {"H", "close all directories"},
+ {"l | <space>", "toggle directory"},
+ {"<right> | l | <enter>", "connect to selected host / toggle directory"},
+ {"a | i", "create a new host"},
+ {"y", "copy selected host"},
+ {"d", "cut selected host"},
+ {"p", "paste host in clipboard"},
+ {"<f7> | m", "create a new directory"},
+ {"e", "edit selected host"},
+ {"c | C | A", "rename selected item"},
+ {"<c-r>", "reload data and configuration"},
+ {"/ | f | <c-f>", "fuzzy search"},
+ {"?", "display this help menu"},
+ {"<c-c> | q", "quit"},
}
var (
diff --git a/src/c_exec.go b/src/c_exec.go
index e00fe36..f6d84ed 100644
--- a/src/c_exec.go
+++ b/src/c_exec.go
@@ -211,12 +211,14 @@ func c_format_cmd(host *HostNode, opts HardOpts,
return nil, nil
}
if len(gpg) > 0 && gpg != "plain" && len(host.Pass) > 0 {
- i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " GnuPG ")
- text := "decryption using gpg..."
- left, right := i_left_right(len(text), *ui)
- i_draw_text(ui.s, left, ui.dim[H] - 3, right, ui.dim[H] - 3,
- ui.style[DEF_STYLE], text)
- ui.s.Show()
+ if ui.s != nil {
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " GnuPG ")
+ text := "decryption using gpg..."
+ left, right := i_left_right(len(text), *ui)
+ i_draw_text(ui.s, left, ui.dim[H] - 3, right, ui.dim[H] - 3,
+ ui.style[DEF_STYLE], text)
+ ui.s.Show()
+ }
var err error
pass, err = c_decrypt_str(host.Pass)
if err != nil {
@@ -292,12 +294,13 @@ func c_exec(host *HostNode, opts HardOpts, ui *HardUI) {
if host.Protocol == PROTOCOL_CMD {
silent = host.Silent
}
- if silent == false {
+ if silent == false && ui.s != nil {
if err := ui.s.Suspend(); err != nil {
c_error_mode("screen", err, ui)
return
}
- } else {
+ } else if ui.s != nil {
+
i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Exec ")
text := "running command..."
left, right := i_left_right(len(text), *ui)
@@ -312,7 +315,7 @@ func c_exec(host *HostNode, opts HardOpts, ui *HardUI) {
if opts.Loop == false {
ui.s.Fini()
os.Exit(0)
- } else if silent == false {
+ } else if silent == false && ui.s != nil {
c_resume_or_die(ui)
}
}
diff --git a/src/c_fuzz.go b/src/c_fuzz.go
index fb230e1..313b684 100644
--- a/src/c_fuzz.go
+++ b/src/c_fuzz.go
@@ -91,20 +91,26 @@ func c_fuzz_find_item(str_out string, litems *ItemsList) (*ItemsNode) {
return nil
}
-func c_fuzz(data *HardData, ui *HardUI) {
- if err := ui.s.Suspend(); err != nil {
- c_error_mode("screen", err, ui)
- return
+func c_fuzz(data *HardData, ui *HardUI) (bool) {
+ if ui.s != nil {
+ if err := ui.s.Suspend(); err != nil {
+ c_error_mode("screen", err, ui)
+ return false
+ }
}
search := exec.Command("fzf")
stdin, stdout := c_fuzz_init_pipes(ui, search)
if stdin == nil || stdout == nil {
- return
+ return false
}
if err := search.Start(); err != nil {
- c_error_mode("fzf", err, ui)
- c_resume_or_die(ui)
- return
+ if ui.s != nil {
+ c_error_mode("fzf", err, ui)
+ c_resume_or_die(ui)
+ return false
+ } else {
+ c_die("fzf", err)
+ }
}
go func() {
defer stdin.Close()
@@ -117,17 +123,25 @@ func c_fuzz(data *HardData, ui *HardUI) {
}()
output, err := io.ReadAll(stdout)
if err != nil {
- ui.s.Fini()
+ if ui.s != nil {
+ ui.s.Fini()
+ }
c_die("search stdout", err)
}
str_out := strings.TrimSuffix(string(output), "\n")
- c_resume_or_die(ui)
+ if ui.s != nil {
+ c_resume_or_die(ui)
+ }
if len(str_out) > 0 {
item := c_fuzz_find_item(str_out, data.litems)
if item == nil {
- c_error_mode("item not found", nil, ui)
- return
+ if ui.s != nil {
+ c_error_mode("item not found", nil, ui)
+ }
+ return false
}
data.litems.curr = item
+ return true
}
+ return false
}
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 948a7f9..bc072ed 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -80,5 +80,11 @@ func main() {
}
data_dir := c_get_data_dir(nil)
data := c_init_hard(data_dir, n_arg, s_arg)
+ if s_arg == true {
+ if c_fuzz(data, &data.ui) == true {
+ c_exec(data.litems.curr.Host, data.opts, &data.ui)
+ }
+ return
+ }
i_ui(data)
}
diff --git a/src/c_utils.go b/src/c_utils.go
index 76ac248..2333ffd 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -149,6 +149,9 @@ func c_die(str string, err error) {
}
func c_error_mode(msg string, err error, ui *HardUI) {
+ if ui == nil {
+ return
+ }
ui.mode = ERROR_MODE
err_str := ""
if err != nil {
diff --git a/src/e_keys.go b/src/e_keys.go
index 1e598b5..67cb8ce 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -252,6 +252,7 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
ui.buff.insert(data.litems.curr.Dirs.Name)
}
} else if (event.Rune() == '/' ||
+ event.Rune() == 'f' ||
event.Key() == tcell.KeyCtrlF) &&
data.litems.curr != nil {
c_fuzz(data, ui)
diff --git a/src/i_help.go b/src/i_help.go
index 7f549a0..de0a085 100644
--- a/src/i_help.go
+++ b/src/i_help.go
@@ -67,7 +67,7 @@ func i_draw_help(ui *HardUI) {
i_draw_box(ui.s,
win.L, win.T, win.R, win.B,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE],
- " Keys ", true)
+ " keys ", true)
line := 0
line -= ui.help_scroll
if line < 0 {
@@ -94,7 +94,7 @@ func i_help_normal(ui HardUI, win Quad, line *int) bool {
return false
}
i := delim - 1 - len(v[0])
- if i < 0 { i = 0 }
+ i = max(i, 0)
i_draw_text(ui.s, win.L + 1 + i, win.T + 1 + *line, win.L + delim,
win.T + 1 + *line, ui.style[BOT_STYLE], v[0])
i_draw_text(ui.s, win.L + delim + 1, win.T + 1 + *line, win.R,
diff --git a/src/i_host.go b/src/i_host.go
index 6c28f51..b06486d 100644
--- a/src/i_host.go
+++ b/src/i_host.go
@@ -110,7 +110,7 @@ func i_draw_host_panel(ui HardUI, icons bool,
litems *ItemsList, data *HardData) {
i_draw_box(ui.s, 0, 0,
ui.dim[W] / 3, ui.dim[H] - 2,
- ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Hosts ", false)
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " hosts ", false)
line := 1
if litems == nil || litems.head == nil {
return
diff --git a/src/i_info.go b/src/i_info.go
index 4802feb..c27afe6 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -469,7 +469,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
i_draw_box(ui.s, (ui.dim[W] / 3), 0,
ui.dim[W] - 1, ui.dim[H] - 2,
- ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Infos ", false)
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " infos ", false)
ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[BOX_STYLE])
ui.s.SetContent(ui.dim[W] / 3, ui.dim[H] - 2,
tcell.RuneBTee, nil, ui.style[BOX_STYLE])
diff --git a/src/i_insert.go b/src/i_insert.go
index a147cb3..84c6468 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -471,7 +471,7 @@ func i_draw_insert_panel(ui *HardUI, in *HostNode, home_dir string) {
i_draw_box(ui.s,
win.L, win.T, win.R, win.B,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE],
- " Insert - " + in.Name + " ", true)
+ " insert - " + in.Name + " ", true)
line := i_insert_follow_cursor(ui.insert_scroll, 2)
if line <= 0 {
ui.s.SetContent(ui.dim[W] / 2, win.T, '▲', nil, ui.style[BOX_STYLE])