python2 autocompletes file names on BASH shell, python3 does not
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.
is there some package I can install, or some setting I can change, to enable the autocomplete for python3?
bash python
 |Â
show 1 more comment
up vote
1
down vote
favorite
When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.
is there some package I can install, or some setting I can change, to enable the autocomplete for python3?
bash python
What is the output ofcomplete -p python3
?
â wjandrea
Mar 20 at 18:53
outputbash: complete: python3: no completion specification
butcomplete -p python
outputs the same
â con
Mar 20 at 18:55
Just to clarify one thing, Bash is doing the completion. Readhelp complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
â wjandrea
Mar 20 at 18:57
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: typepython
, then a space, then press Tab, then erase it, and runcomplete -p python python2 python3
(python and python2 added for good measure).
â wjandrea
Mar 20 at 19:10
 |Â
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.
is there some package I can install, or some setting I can change, to enable the autocomplete for python3?
bash python
When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.
is there some package I can install, or some setting I can change, to enable the autocomplete for python3?
bash python
bash python
asked Mar 20 at 18:48
con
84
84
What is the output ofcomplete -p python3
?
â wjandrea
Mar 20 at 18:53
outputbash: complete: python3: no completion specification
butcomplete -p python
outputs the same
â con
Mar 20 at 18:55
Just to clarify one thing, Bash is doing the completion. Readhelp complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
â wjandrea
Mar 20 at 18:57
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: typepython
, then a space, then press Tab, then erase it, and runcomplete -p python python2 python3
(python and python2 added for good measure).
â wjandrea
Mar 20 at 19:10
 |Â
show 1 more comment
What is the output ofcomplete -p python3
?
â wjandrea
Mar 20 at 18:53
outputbash: complete: python3: no completion specification
butcomplete -p python
outputs the same
â con
Mar 20 at 18:55
Just to clarify one thing, Bash is doing the completion. Readhelp complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
â wjandrea
Mar 20 at 18:57
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: typepython
, then a space, then press Tab, then erase it, and runcomplete -p python python2 python3
(python and python2 added for good measure).
â wjandrea
Mar 20 at 19:10
What is the output of
complete -p python3
?â wjandrea
Mar 20 at 18:53
What is the output of
complete -p python3
?â wjandrea
Mar 20 at 18:53
output
bash: complete: python3: no completion specification
but complete -p python
outputs the sameâ con
Mar 20 at 18:55
output
bash: complete: python3: no completion specification
but complete -p python
outputs the sameâ con
Mar 20 at 18:55
Just to clarify one thing, Bash is doing the completion. Read
help complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.â wjandrea
Mar 20 at 18:57
Just to clarify one thing, Bash is doing the completion. Read
help complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.â wjandrea
Mar 20 at 18:57
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type
python
, then a space, then press Tab, then erase it, and run complete -p python python2 python3
(python and python2 added for good measure).â wjandrea
Mar 20 at 19:10
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type
python
, then a space, then press Tab, then erase it, and run complete -p python python2 python3
(python and python2 added for good measure).â wjandrea
Mar 20 at 19:10
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3
extensions. The problem is, Bash will only autocomplete scripts with .py
extensions.
I recommend using .py
extensions even for Python 3 scripts, since .py3
is non-standard. If the scripts require Python 3, you could...
- Use the shebang:
#!/usr/bin/env python3
- Check if
sys.version_info.major == 3
- Or check if
>= 3
, to allow forwards compatibility
- Or check if
- Maybe use
from __future__ import ...
to allow backwards compatibility
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3
extensions. The problem is, Bash will only autocomplete scripts with .py
extensions.
I recommend using .py
extensions even for Python 3 scripts, since .py3
is non-standard. If the scripts require Python 3, you could...
- Use the shebang:
#!/usr/bin/env python3
- Check if
sys.version_info.major == 3
- Or check if
>= 3
, to allow forwards compatibility
- Or check if
- Maybe use
from __future__ import ...
to allow backwards compatibility
add a comment |Â
up vote
3
down vote
accepted
As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3
extensions. The problem is, Bash will only autocomplete scripts with .py
extensions.
I recommend using .py
extensions even for Python 3 scripts, since .py3
is non-standard. If the scripts require Python 3, you could...
- Use the shebang:
#!/usr/bin/env python3
- Check if
sys.version_info.major == 3
- Or check if
>= 3
, to allow forwards compatibility
- Or check if
- Maybe use
from __future__ import ...
to allow backwards compatibility
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3
extensions. The problem is, Bash will only autocomplete scripts with .py
extensions.
I recommend using .py
extensions even for Python 3 scripts, since .py3
is non-standard. If the scripts require Python 3, you could...
- Use the shebang:
#!/usr/bin/env python3
- Check if
sys.version_info.major == 3
- Or check if
>= 3
, to allow forwards compatibility
- Or check if
- Maybe use
from __future__ import ...
to allow backwards compatibility
As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3
extensions. The problem is, Bash will only autocomplete scripts with .py
extensions.
I recommend using .py
extensions even for Python 3 scripts, since .py3
is non-standard. If the scripts require Python 3, you could...
- Use the shebang:
#!/usr/bin/env python3
- Check if
sys.version_info.major == 3
- Or check if
>= 3
, to allow forwards compatibility
- Or check if
- Maybe use
from __future__ import ...
to allow backwards compatibility
edited Mar 20 at 20:01
answered Mar 20 at 19:48
![](https://i.stack.imgur.com/eVuAv.png?s=32&g=1)
![](https://i.stack.imgur.com/eVuAv.png?s=32&g=1)
wjandrea
7,19342255
7,19342255
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017714%2fpython2-autocompletes-file-names-on-bash-shell-python3-does-not%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What is the output of
complete -p python3
?â wjandrea
Mar 20 at 18:53
output
bash: complete: python3: no completion specification
butcomplete -p python
outputs the sameâ con
Mar 20 at 18:55
Just to clarify one thing, Bash is doing the completion. Read
help complete
for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.â wjandrea
Mar 20 at 18:57
this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
â con
Mar 20 at 19:00
After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type
python
, then a space, then press Tab, then erase it, and runcomplete -p python python2 python3
(python and python2 added for good measure).â wjandrea
Mar 20 at 19:10