GithubHelp home page GithubHelp logo

walk's Introduction

๐Ÿฅพ walk


walk demo

Walk โ€” a terminal navigator.

Why another terminal navigator? I wanted something simple and minimalistic. Something to help me with faster navigation in the filesystem; a cd and ls replacement. So I build walk. It allows for quick navigation with fuzzy searching, cd integration is quite simple. And you can open vim right from the walk. That's it.

Install

brew install walk
pkg_add walk
go install github.com/antonmedv/walk@latest

Or download prebuild binaries.

Put the next function into the .bashrc or a similar config:

Bash/Zsh Fish PowerShell
function lk {
  cd "$(walk "$@")"
}
function lk
  set loc (walk $argv); and cd $loc;
end
function lk() {
  cd $(walk $args)
}

Now use lk command to start walking.

Usage

Key binding Description
Arrows, hjkl Move cursor
Enter Enter directory
Backspace Exit directory
Space Toggle preview
Esc, q Exit with cd
Ctrl+c Exit without cd
/ Fuzzy search
dd Delete file or dir
y yank current dir

The EDITOR or WALK_EDITOR environment variable used for opening files from the walk.

export EDITOR=vim

Preview mode

Press Space to toggle preview mode.

Walk Preview Mode

Delete file or directory

Press dd to delete file or directory. Press u to undo.

Walk Deletes a File

Display icons

Install Nerd Fonts and add --icons flag.

Walk Icons Support

Image preview

No additional setup is required.

Walk Image Preview

Become a sponsor

Every line of code in my repositories ๐Ÿ“– signifies my unwavering commitment to open source ๐Ÿ’ก. Your support ๐Ÿค ensures these projects keep thriving, innovating, and benefiting all ๐Ÿ’ผ. If my work has ever resonated ๐ŸŽต or helped you, kindly consider showing love โค๏ธ by sponsoring. ๐Ÿš€ Sponsor Me Today! ๐Ÿš€

License

MIT

walk's People

Contributors

antongolub avatar antonmedv avatar ardnew avatar chuhlomin avatar cyc4188 avatar dlvhdr avatar ducretje avatar fzdwx avatar gingerbeardman avatar gonzalo- avatar guy-av avatar juneezee avatar kachick avatar kz6fittycent avatar meowgorithm avatar omar-polo avatar parlajatwit avatar thereptar avatar tuzu128 avatar vvcaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

walk's Issues

Command line option "--icons" crashes in PowerShell

PS C:\> llama --version

  llama v1.4.0

PS C:\> llama --icons
panic: open C:\--icons: The system cannot find the file specified.

goroutine 1 [running]:
main.(*model).list(0xc000158000)
        /home/runner/work/llama/llama/main.go:631 +0x2d6
main.main()
        /home/runner/work/llama/llama/main.go:97 +0x19b
PS C:\>

I'm using llama_windows_amd64.exe

Slow with large readable files

When previewing files and navigating on a readable but large file there is a very strong time lag. Maybe loading only a few hundred lines would make this better?

error when using bash function

I get the error -bash: complete: cd: no completion specification when I include the bash function in my ~/.bashrc

function lla {
  cd "$(llama "$@")"
}

Curiously, when I paste it into the shell, no error occurs.

macOS 12.6.1 (Monterey)
bash: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)

Preview mode trims off file content in view

Best explained by this screenshot. It is the standard license file in a directory called ~/Projects/llama

Observed on master, only in preview mode. To replicate just do llama . and then

Terminal: GNOME Terminal
Go version: 1.20.1

llama

Add vim-style navigation

Allow using h,j,k,l instead of arrows

Suggestion: if user has .vimrc or init.vim, then use use vim style navigation

Command line option: "--icons" crashes

$ llama --version
   llama  v1.4.0

$ llama --icons

panic: open /home/guest/apps/llama/--icons: no such file or directory

goroutine 1 [running]:
main.(*model).list(0xc000146000)
	/home/runner/work/llama/llama/main.go:631 +0x2d6
main.main()
	/home/runner/work/llama/llama/main.go:97 +0x19b

Is it hard-coded path?

I'm using Ubuntu, prebuilt binary of LLama.

Return selected files to bash

I have an idea. Instead returning a new path for cd $(llama). Llama can return a bash script for execution!

eval $(llama)

This way llama can implement file selection and return something like this:

cd new-path;
export files="some-files";

And users can do something with the results:

ll
[..select some files, let say with a spacebar...]
rm -r $files

"dd" for delete not working?

The "dd" to delete goes to the next file/directory starting with the letter d. Is there an escape sequence that you need to invoke first to enable this function?

brew install fail

brew install walk
Warning: No available formula with the name "walk". Did you mean walkmod?

Add PgUp/PgDn, Home and End key bindings

Hi,

it would be nice to have some more key bindings to navigate the listing:

  • Home: Jump to beginning of listing
  • End: Jump to end of listing
  • PageUp: jump to top of current row
  • PageDown: jump to bottom of current row

Thank you very much!

New name for llama

I think it will be wise to rename llama to something else.

Here a few names:

  1. golscd
  2. walk
  3. navigo

Any ideas?

Refresh in combination with o

llama might need a refresh after launching applications like the o text editor.

Steps to reproduce:

  • Use alacritty.
  • Install o: go install github.com/xyproto/o@latest
  • Set EDITOR:export EDITOR=o
  • Launch llama and open a text file.
  • Quit o with ctrl-q.
  • Move arrows up and down.
  • Observe that some of the text in llama is gone.

Thanks for creating llama, it was quick to install and fun to use. ๐Ÿ‘

Add syntax highlighting

I created this patch to use bat for sytnax highlighting, but the output isn't quite right:

diff --git a/main.go b/main.go
index 0f6ba98..522ed48 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
        "fmt"
        "io"
        "io/fs"
+       "bytes"
        "math"
        "os"
        "os/exec"
@@ -689,22 +690,32 @@ func (m *model) preview() {
                return
        }
 
-       file, err := os.Open(filePath)
-       defer file.Close()
-       if err != nil {
-               m.previewContent = err.Error()
-               return
-       }
-       content, _ := io.ReadAll(file)
+       cmd := exec.Command("bat", "-pP", filePath)
+       Spawn(cmd)
+
+       var buf bytes.Buffer
+       io.MultiWriter(cmd.Stdout, &buf)
 
        switch {
-       case utf8.Valid(content):
-               m.previewContent = Replace(string(content), "\t", "    ", -1)
+       case utf8.Valid(buf.Bytes()):
+               m.previewContent = Replace(buf.String(), "\t", "    ", -1)
        default:
                m.previewContent = warning.Render("No preview available")
        }
 }
 
+func Spawn(cmd *exec.Cmd) {
+    cmd.Stdout = os.Stdout
+    cmd.Stderr = os.Stderr
+
+    err := cmd.Start()
+    if err != nil {
+        err.Error()
+    }
+
+    defer cmd.Wait()
+}
+
 func (m *model) performPendingDeletions() {
        for _, toDelete := range m.toBeDeleted {
                _ = os.RemoveAll(toDelete.path)

Show/hide hidden files

Hi,

would it be possible to add eg. the key binding " . " to toggle the visibility of 'hidden' files and directories (ie. filename start with '.')?

Thank you!

Support vim key bindings

Add a configurable option to replace directional arrow keys with hjkl;

set LLAMA_VIM_KEYBINDINGS=true

Add support for `--version`

Hi @antonmedv ,

I'm checking out llama and was wondering if there's a way to check the current version of the program installed.

llama --version currently returns:

panic: open <HOME>--version: no such file or directory

Ordering of files/folders

Looking in the code there's a comment suggesting the files/folders come pre-ordered from the OS but the ordering seems strange.

It seems to be alphabetical, but with all capital letters being ranked higher than lower case letters..

Powershell in windows:
image

Bash in ubuntu (WSL2):
image

At least it's consistent but it might be nice to optionally allow internal sorting, making it case insensitive.

Just to add to this, I'd also prefer to see folders above files, but that's a nice-to-have

"failed to get console mode for stdout" in windows powershell

image

I get this error message on windows powershell.

What i did:

  • Downloaded the Exe file
  • Renamed it to llama.exe
  • Put it in PATH
  • Added your PS snipped (ll command) to my profile
  • called ll in ps
  • Moved to a directory
  • Esc

Expected behavior: Setting Location to my selected location
Actual Behavior: Error above

Any idea where this is from?

bashrc rename `ll` -> `walk`

I just now saw that this project used to be called llama, and the function ll ... stuff in the readme makes slightly more sense now. But it might be a good idea to change it. For some reason it is extremely common to have an alias in bashrc something like this:
alias ll='ls -l' , i think it originates from debians default bashrc . And it is not 100% clear that you are supposed to start walk by typing ll after it has been set up.

Why not name the function walk ? In bash functions have priority over commands (and i think aliases have priority over functions) if they have the same name. And it is possible to override this by using the command command. So this works as expected:

function walk { cd "$(command walk "$@")" ;}

but it will throw a warning when linting with shellcheck ( ^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.)

so even better would be:

function walk { cd "$(command walk "$@")" || return ;}

In my own bashrc i ended up with this:

command -v walk >/dev/null \
  && function walk { command cd "$(command walk "$@")"  || return ;}

command -v walk will print the path to the command (or name if it is a function) or silently fail if it isn't available.
This is good because if i have this bashrc on a system that doesn't have the walk command, or if i uninstall walk, the function
walk() will not be defined either. I also ended up using command cd because i actually have a function called cd that also does ls && pwd and it was annoying to have ls output after selecting a directory with walk.

I never liked terminal filemanagers before, but this walk thing is really neat and integrates a lot more fluently into regular interactive shell usage, keep up the good work!

Import .vimrc

Setting;

export LLAMA_EDITOR=vim

uses an embedded vim that doesn't load my vimrc.

Feature request: yank

In my experience with walk, it would be useful have a hotkey to copy the selected path to a clipboard, for example, for use in other cli tools.
I suggest using the y key, which is common for this kind of functionality.

Preview mode

Will be cool to have the ability to quickly preview a file (with a press of a spacebar, as on macOS) in a side panel.

panic: read /dev/stdin: resource temporarily unavailable

Hey there.

On OSX 11.4 (Intel), I get the following error after navigating to a file, editing it with Neovim, and exiting Neovim:

panic: read /dev/stdin: resource temporarily unavailable

goroutine 1 [running]:
main.main()
	/Users/anton/dev/llama/main.go:66 +0x277

No highlighting when run in screen and $TERM=screen

When run under a screen session, there is no highlighting, so the currently selected item is unknown. Appears that screen sets the "TERM" environment variable to "screen" which appears to cause the issue.

llama running under bash, not in a screen session; TERM is xterm-256color:
llama_in_bash

llama running under bash, while in a screen session; TERM is screen. Overriding TERM variable with xterm-256color resolves the issue.
llama_in_bash_in_screen_session

System is FreeBSD 13.1

Icons are not correct

Icons not correctly showing. Example for .jpg, its showing a rocket icon. But when using exa (replacement program for ls), its showing correct icon. This is also applicable for extensions like .txt (showing a square with 4small squares).

Terminal : termux
Shell : bash

Can't open files in vim

This might be a user error but it's not obvious to me from the documentation how to open a file.
I have added both exports below to my bashrc.

export LLAMA_EDITOR=vim
export EDITOR=vim

I am assuming we navigate to a file and hit enter? Nothing seems to happen thought when I hit enter.
I am using Ubuntu v18 if that might have an impact.

Thanks in advance!

A config for disabling the `dd` shortcut. Mistakingly removing files

I just tried this neat thing out but after 10 seconds of testing out, I.. Hahah, tapped d two times in hopes of searching for the folder starting on the letter D.
An alert of a file being deleted with an undo came up, nice.
Unfortunately my fidgety and quick fingerbrains ran a ctrl+c (cancel)...

My file was deleted, not to be found in the trash :(

RIP "Invoices/Receipts" 2022-02-08. You will always be remembered here in this issue.

I'd love to continue using llama, but I'm afraid of this happening again with those fricken quick fingers acting on their own.

Is there any way we can either:

  • Config the dd shortcut to trash instead of deleting?
    Or
  • Disable the dd shortcut?

Big love

Compatibility with Starship

Using Starship (https://starship.rs/) 1.13.1 with PowerShell 7.2.1 and using the ll() function, exiting llama with ESC changes directory as expected, but the prompt is affected.

I see:

image

When I would expect to see this:

image

option --icons crashes if a directory is specified

I'm on Arch Linux, with Fish terminal. If I use the --icons option together with a directory, for example:

walk --icons /directory

the program crashes with this error:

panic: open /home/username/--icons: no such file or directory

goroutine 1 [running]:
main.(*model).list(0xc0001ce000)
	/home/runner/work/walk/walk/main.go:593 +0x2d6
main.main()
	/home/runner/work/walk/walk/main.go:101 +0x27b

Thanks for this great program!

Getting a "permission denied" error when trying to enter hidden directory on Kubuntu 22.04.1

I just downloaded llama via snap, and ran it on the home directory. Whenever I try to enter a hidden directory, (one with '.' at the beginning of the name), I get the following error:

open /home/huoknight/.local: permission denied

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /snap/go/10009/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /snap/go/10009/src/runtime/debug/stack.go:16 +0x19
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        /root/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:385 +0x95
panic({0x5149e0, 0xc0002f7ef0})
        /snap/go/10009/src/runtime/panic.go:838 +0x207
main.(*model).list(0xc00014c000)
        /root/parts/llama/build/main.go:631 +0x2d6
main.(*model).Update(0xc00014c000, {0x51fba0?, 0xc000098390?})
        /root/parts/llama/build/main.go:231 +0x1d47
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc0001380b0, {0x55ea18?, 0xc00014c000?}, 0x40c9a5?)
        /root/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:324 +0x602
github.com/charmbracelet/bubbletea.(*Program).Run(0xc0001380b0)
        /root/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:448 +0x8e7
main.main()
        /root/parts/llama/build/main.go:100 +0x1df

(The error is with /home/huoknight/.local, but it happens with any hidden directory.

Better serach

  1. Search input is temporary and you can't select next match with some hotkey
    2. you can't refine search because it dissapears
  2. It would be great to add option to filter out the fuzzy search results as one types.

Exit with pushd

Feature request:

Add a key binding (Ctrl+X) to exit with pushd.

Add ability to show icons

I'm using a nerd font, and the output of exa is much easier for me to quickly parse, when its used with the icons and colors.

I'm willing to work on this if that's a feature you'd like adding.

config file location?

Could you please add more instructions on how to create a config file?
I want to change the default editor to nano.

Terminal Picture Viewer

Wanted to know your thoughts on the addition of functionality to "print" a picture to the terminal. Got it working with a modified version of https://github.com/ichinaski/pxl, and appears to work in the terminals I've tested it in.

On one hand, I've been getting actual use out of it (remote viewing of scraped webpages/assets and remote rapid forensics), but on the other understand it could be seen as feature creep. I have a working version on a seperate branch on my fork. In its current implementation it does add another key ("q" for quit).

Command-line argument to start in search mode

This is a super neat tool, but what bothers me is that I have to press / everytime I use it. I would be extremely happy if someone could add a command-line argument (--search or something) that would make the app switch to search mode automatically after startup.

I practically want search to be active at all times, and I'm sure many others do as well. This extra keystroke cuts the usefulness, speed and productivity in half. The key is pretty far away too (so much hand movement needed) ๐Ÿ˜„

I realize it's a simple tweak and I could do it myself. Eventually I even might, once I have some time to get myself familiar with Go. But if someone beats me to it, that would be awesome!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.