Fish command

If you’re a bash user, you probably still aren’t aware of this little trick.

Say you have an alias for ls in your .bashrc:

alias ls='ls -rtlh --color=auto'

This is my preference for when I use the ls command. It prints the newest items last, and has nice formatting. However, there are times when you want to use another flag with ls. For example ls -1 prints just the filenames, each on one line. This is really handy for piping to another program.

However, this doesn’t work, since ls has an alias that includes other flags.

The workaround is simple:

\ls -1

The backslash tells bash to ignore all aliases and call the original ls command. This is also handy from a security perspective. If you suspect a command has been tampered with, you can use the backslash to ensure you’re running the original command, and not some alias.

After switching to the fish shell (because bash is being replaced by zsh in places like Kali Linux and OS X), I discovered that the \ trick no longer works. The equivalent in fish is command.

So, these bash & fish commands are equivalent:

# bash
\ls -1
# fish
command ls -1