Skip to content

Quirks Troubleshootings

suewonjp edited this page Jun 13, 2017 · 1 revision

Quirks & Troubleshootings

✔️ Using a Separate Asterisk (*)

Avoid using a separate asterisk (*) like lf doc work *

  • This won't work and may produce unexpected results
  • Most shells including Bash will execute pathname expansion when they see wildcards such as * and if * is used alone, it will be expanded every path name under the current working directory
  • This behavior is based on POXIS specification and there is little lf.sh can do about it
  • Though, concatenating * to other patterns will be OK like lf doc work important*.pdf
  • However, even in this case, a space is preferable to *
    • e.g) lf doc work important .pdf is equivalent to lf doc work important*.pdf
  • If your intention is to denote arbitrary files, then use -- notation instead:
    • lf doc work * => BAD (X)
    • lf doc work -- => GOOD (O)

✔️ [WARNNIG] pbcopy/pbpaste aliases can't be defined! (On some Linux/Unix systems)

You may see the following warning message, when you load lf.sh

lf.sh [WARNNIG] pbcopy/pbpaste aliases can't be defined!
    - This means you can't use some extra features requiring system clipboard access via shell
    - Install tools such as xsel or xclip to enable the features

This message will be printed out when your system has no system clipboard command line utility installed.
Systems like OS X and Windows Cygwin have such utility shipped by default, so there is no problem.

However, on some systems, especially Linux or Unix, you may need to manually install such utility.
Fortunately, popular tools such as xsel and xclip are easy to install on Linux.
Installing either of xsel or xclip is recommended in order for lfs or lff to fully work on Linux.

If you can't install either of them ( e.g., because the target marchine is a shared server and you are not the administrator ), you may see this warning message whenever you login to that machine. But you'll have no problem with using most functionalities of lf.sh except you can't use + notation with lff or lfs commands.

$ lf --

files/empty.txt
files/folder 0/empty.txt
files/folder 0/folder 2/empty.txt
files/folder 0/foo.txt
files/folder 1/bar.txt

## The selected path will be copied to the system clipboard on OS X, Cygwin, Linux/Unix equipped with `xsel` or `xclip`.
## Some error messages will be printed out on all other systems.
$ lfs 1 +
files/folder 0/empty.txt

✔️ Using The Silver Searcher for g or gi Commands on Ubuntu/Debian/Linux Mint

g or gi commands may make your day-to-day text searching job a little bit easier because they leverage conveniences of lf or lfi commands

$ cat Documents/test/tmp.txt
Java
JavaScript

$ g [Jj]ava$ . Docu .txt
Documents/text/tmp.txt:1:Java

Also you can choose which grepping tool to use by setting _LIST_FILE_GREP_TOOL variable like so:

   _LIST_FILE_GREP_TOOL=egrep

( While you touch nothing, g or gi command will use grep, which is shipped with most of Unix-like systems on Earth )

Personally, I prefer The Silver Searcher - ag to grep because it is faster and has more convenient features. So I use the following setting when I use lf.sh:

   _LIST_FILE_GREP_TOOL=ag

( BTW, this tool may not be shipped on your machine by default. Refer to https://github.com/ggreer/the_silver_searcher#installing about how to install it. )

This configuration is OK with OS X and Cygwin, but it's not with some popular Linux distros such as Ubuntu/Debian/Linux.

The easiest way to install ag on those systems is:

    sudo apt-get install silversearcher-ag

However, sadly, the version of ag installed by this method is too old to be compatible to lf.sh.

The best workaround is installing the latest version of ag by either of the following methods:

  1. Build ag from the source code
  2. Install ag using Linuxbrew
    • How to install Linuxbrew
    • After installing Linuxbrew, install ag like so:
      • brew install the_silver_searcher