# Can plain sh do tab completion?



## Swapjim (Oct 14, 2015)

Well, I'm pressing the TAB key and nothing happens 

`set -o` also doesn't give anything relative to tab completion.

Does sh(1) have tab completion or not? And if yes, how do I enable it?

(I know  that tcsh(1) has tab completion. It's working fine.)


----------



## Oko (Oct 15, 2015)

Swapjim said:


> Well, I'm pressing the TAB key and nothing happens
> 
> set -o also doesn't give anything relative to tab completion.
> 
> ...


sh()

My man on OpenBSD machine has this paragraph


```
vi-tabcomplete  In vi command-line editing, do command and file
                                       name completion when tab (^I) is  entered                  
                                      in insert mode.
```


----------



## protocelt (Oct 15, 2015)

Oko said:


> sh()
> 
> My man on OpenBSD machine has this paragraph
> 
> ...


sh(1) on OpenBSD is really just pdksh. To quote OpenBSD's man page:


> NOTES
> *    sh* is implemented as a run-time option of *pdksh*, with only those *sh* fea-
> tures whose syntax or semantics are incompatible with a traditional
> Bourne shell disabled. Since this leaves some *sh* extensions exposed,
> ...



As far as I'm aware, sh(1) does not have tab command completion.


----------



## Swapjim (Oct 15, 2015)

Well, to be accurate, I can do tab completion in filenames but not in commands.


----------



## protocelt (Oct 15, 2015)

D'oh! Sorry about that. I did mean to write _command_ completion.


----------



## Oko (Oct 15, 2015)

protocelt said:


> sh(1) on OpenBSD is really just pdksh.


Are you 100% sure about that? Of course I am aware that I am using pdksh which is also default for root account but I would swear that I also have Bourne shell for scripts. Please see




```
predrag@oko$ man sh
SH(1)  General Commands Manual  SH(1)

NAME
  sh - public domain Bourne shell

SYNOPSIS
  sh [-+abCefhiklmnpruvXx] [-+o option]
  [-c string | -s | file [argument ...]]
```


```
predrag@oko$ man ksh
KSH(1)  General Commands Manual  KSH(1)

NAME
  ksh - public domain Korn shell

SYNOPSIS
  ksh [-+abCefhiklmnpruvXx] [-+o option]
  [-c string | -s | file [argument ...]]
```

and I personally write scripts in shells/ksh93


----------



## bugzeo (Jul 18, 2021)

Swapjim said:


> Well, to be accurate, I can do tab completion in filenames but not in commands.


True. You can just run bash for autocompletion too on the command, but I wouldn't set it as default shell.


----------



## SirDice (Jul 18, 2021)

bugzeo you're responding to a 6 year old thread.


----------



## bugzeo (Jul 18, 2021)

I know, but for newcomers (like me) still helpful.


----------

