Skip to content

Instantly share code, notes, and snippets.

@rupeshtr78
Last active May 26, 2024 19:27

Revisions

  1. rupeshtr78 revised this gist Mar 29, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    -- fzf clink history search
    -- update cmder\vendor\clink >= clink -- version = 1.1.44
    -- install fzf choco install fzf
    -- add the fzf_history.lua to cmder\config folder
    -- add below key binding to _inputrc use "clink info" to find inputrc path
    -- M-x: "luafunc:fzf_history" #Alt x
    -- Might have to adjust your regex in line 38 39 based on your settings
  2. rupeshtr78 revised this gist Mar 26, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    -- update cmder\vendor\clink >= clink -- version = 1.1.44
    -- install fzf choco install fzf
    -- add below key binding to _inputrc use "clink info" to find inputrc path
    -- M-x: "luafunc:fzf_history"
    -- M-x: "luafunc:fzf_history" #Alt x
    -- Might have to adjust your regex in line 38 39 based on your settings
    -- reference https://chrisant996.github.io/clink/clink.html

  3. rupeshtr78 revised this gist Mar 25, 2021. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ settings.add("fzf.height", "40%", "Height to use for the --height flag")
    local function get_fzf()
    local height = settings.get("fzf.height")
    local c = "C:\\cmder\\vendor\\clink\\clink_x64.exe"
    local session_history = c.." --session".." clink.getsession()".. " history"
    local session_history = c.." --session".." clink.getsession()".. " history".." --bare"
    local fzf_command= session_history.." | ".."fzf"

    if height and height ~= "" then
    @@ -36,13 +36,12 @@ function fzf_history(rl_buffer)
    handle:close()
    if fzf_complete_intercept then
    for hist in string.gmatch(result, "(.+)$") do
    local finalhist = string.match(hist,"[^|%s+%d+].+")
    rl_buffer:insert(finalhist)
    rl_buffer:insert(hist)
    end
    end


    fzf_complete_intercept = false

    rl_buffer:refreshline()
    end
    end
  4. rupeshtr78 revised this gist Mar 25, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    -- install fzf choco install fzf
    -- add below key binding to _inputrc use "clink info" to find inputrc path
    -- M-x: "luafunc:fzf_history"
    -- Might have to adjust your regex in line 38 39 based on your settings
    -- reference https://chrisant996.github.io/clink/clink.html

    settings.add("fzf.height", "40%", "Height to use for the --height flag")
  5. rupeshtr78 revised this gist Mar 25, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    -- fzf clink history search
    -- update cmder\vendor\clink to clink -- version = 1.1.44
    -- update cmder\vendor\clink >= clink -- version = 1.1.44
    -- install fzf choco install fzf
    -- add below key binding to _inputrc use "clink info" to find inputrc path
    -- M-x: "luafunc:fzf_history"
  6. rupeshtr78 created this gist Mar 25, 2021.
    47 changes: 47 additions & 0 deletions fzf_history.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    -- fzf clink history search
    -- update cmder\vendor\clink to clink -- version = 1.1.44
    -- install fzf choco install fzf
    -- add below key binding to _inputrc use "clink info" to find inputrc path
    -- M-x: "luafunc:fzf_history"
    -- reference https://chrisant996.github.io/clink/clink.html

    settings.add("fzf.height", "40%", "Height to use for the --height flag")
    -- settings.add("fzf.exe_location", "", "Location of fzf.exe if not on the PATH")

    -- Build a command line to pipe history and launch fzf
    local function get_fzf()
    local height = settings.get("fzf.height")
    local c = "C:\\cmder\\vendor\\clink\\clink_x64.exe"
    local session_history = c.." --session".." clink.getsession()".. " history"
    local fzf_command= session_history.." | ".."fzf"

    if height and height ~= "" then
    fzf_command = fzf_command..' --height '..height..' --layout=reverse'
    end
    return fzf_command
    end

    local fzf_complete_intercept = false

    function fzf_history(rl_buffer)
    print("Searching History")
    fzf_complete_intercept = true
    if not fzf_complete_intercept then
    return
    end

    local handle = io.popen(get_fzf())
    local result = handle:read("*a")
    handle:close()
    if fzf_complete_intercept then
    for hist in string.gmatch(result, "(.+)$") do
    local finalhist = string.match(hist,"[^|%s+%d+].+")
    rl_buffer:insert(finalhist)
    end
    end


    fzf_complete_intercept = false

    rl_buffer:refreshline()
    end