Skip to content

Instantly share code, notes, and snippets.

@trogdoro
Created September 25, 2017 01:04
Show Gist options
  • Save trogdoro/b314daef946e51682439532597488f0f to your computer and use it in GitHub Desktop.
Save trogdoro/b314daef946e51682439532597488f0f to your computer and use it in GitHub Desktop.
> @xiki .Shell action for navigating files
$ ls
|:anything
!.#
! # This shell action lets you expand the output of
! # the ls command, like this:
! #
! # $ ls
! # : etc/
! # : home/
! # : craig/
! # : guest/
! #
!
! # "$ ls", so change "|..." lines to ":..." lines...
!
! if args == []
! return "|\n| This action lets you expand the output of the 'ls' shell command.\n|" if ! shell_output
! return shell_output.gsub(/^\|/, ':')
! end
!
! path = args.map{|o| o.sub(/^: /, '')}.join("/")
!
! # ": dir" line passed...
!
! if File.directory? path
! return Shell.command("ls -p '#{path}/'").quoted
! end
!
! View.open path
! "" # Blank string means we handled
! # Shell.command("cat '#{path}'").snippet
!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment