Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

I've been looking for something like <() for a long time. Thanks for sharing it!

Regarding :h, is it any different than just using dirname?



sort by: page size:

You almost never need to use "*". Use ".", or go up a dir and type the name of the dir.

Yeah, I couldn't make that work for me (on Linux or MacOS) .. although I'd love it if there were a way to quickly get 'just the directory' or 'just the filename' in bash with a shortcut, instead of having to resort to $(dirname blah) and so on .. I'm sure there is some way but :h doesn't look to be the shortcut as expected.

Except when you pass `-r` and you pass a directory in place of the filename. But maybe it should have been `-r <directory>` and still no positional file parameter. The ship has been sailed a long ago though.

So basically instead of doing

    dir C:\
I have to learn to type

   List-Directory-With-Files Drive=C Folder=/
(made up example, but you get the point)

I use pup a lot too, which just prints the dir.

I just wanted the directories, not the files. Your command is great if you want it down to the file level. The -h args are of course a matter of preference.

"dir <dirname>" didn't work. :/

I like

  alias h="cd -"
to go to the last directory I was in. Inspired by how you move the cursor to the left in vim.

Sorry, I was mistaken. I confirm that that works too. I was just comparing with wdired.. wdired (Emacs) creates that foo/ dir if it doesn't exist.

What is the dir/... syntax. I never saw the doc on that one.

console.dir is really useful. It give you variable structure in console.

i use it a lot but want an accompanying binding just for directories

edit: okay done

http://i.imgur.com/n12DYUu.png

Two examples in case you have a preference w/ or w/o the preview:

    fzf_insert_directory_preview() {
      local dir
      dir=$(find . -type d -not -path '*/\.*' | fzf --height 40% --reverse --preview 'tree -C {} | head -200')
      if [[ -n $dir ]]; then
        READLINE_LINE="${READLINE_LINE}${dir}"
        READLINE_POINT=$((${#READLINE_LINE}))
      fi
    }

    fzf_insert_directory() {
      local dir
      dir=$(find . -type d -not -path '*/\.*' | fzf --height 40% --reverse)
      if [[ -n $dir ]]; then
        READLINE_LINE="${READLINE_LINE}${dir}"
        READLINE_POINT=$((${#READLINE_LINE}))
      fi
    }

    bind -x '"\ey": fzf_insert_directory_preview' # alt-y
    bind -x '"\et": fzf_insert_directory' # alt-t
http://ix.io/4rtn/sh

Sent from a LLM


And with CDABLE_VARS set, you can simply do: dir_name In fact, you don't even have to use the directory hash for this, you just do, e.g.: MY_DIR=/path/to/dir; MY_DIR

Frankly, this is far superior to the linked method.


dir works fine for that.

:)

I actually didn't know that dir supported multiple globs for filenames! I've never had a need for that.

Super cool.


Weird that it doesn't seem to support basename (1) and dirname (1) and their Windows equivalents (e.g. %~dp0%)

Quite a few of my scripts need to find files relative to the location of the script, or compute the path to an output file by replacing the extension of an input file.


>However, for root components of a directory, use index.jsx as the filename and use the directory name as the component name

I used to do this, but I find it really confusing having dozens of files all called "index.jsx". I eventually moved to './ComponentName/ComponentName.jsx' in my personal projects. It's a bit more verbose, but I find it makes everything else do to with navigating and finding files easier.


directory-local variables in emacs? thank you! I will look at that.

For canonicalizing directories, you can use this portably:

  dir=$(cd -P -- "$dir" && pwd)
with the usual gotcha that $() strips trailing newlines.

> go ./... magic custom (that means this and all recursive subdirectories).

There. I did just learn it without following a tutorial or somethin. It's so simple, easy to remember. It's even faster to write that -R or -r.

next

Legal | privacy