Bash like installation suggestion in tcsh


up vote
0
down vote
favorite
In a bash shell, if you put some command that is not installed on your system, it throws an error and also gives you a package installation suggestion. For example-
$ iostat
Command 'iostat' not found, but can be installed with:
sudo apt install sysstat
My personal favorite is tcsh but it does not give any package installation suggestion while some command is not found. How can I get the package installation suggestion (like bash) in tcsh?
command-line execute-command tcsh
add a comment |Â
up vote
0
down vote
favorite
In a bash shell, if you put some command that is not installed on your system, it throws an error and also gives you a package installation suggestion. For example-
$ iostat
Command 'iostat' not found, but can be installed with:
sudo apt install sysstat
My personal favorite is tcsh but it does not give any package installation suggestion while some command is not found. How can I get the package installation suggestion (like bash) in tcsh?
command-line execute-command tcsh
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In a bash shell, if you put some command that is not installed on your system, it throws an error and also gives you a package installation suggestion. For example-
$ iostat
Command 'iostat' not found, but can be installed with:
sudo apt install sysstat
My personal favorite is tcsh but it does not give any package installation suggestion while some command is not found. How can I get the package installation suggestion (like bash) in tcsh?
command-line execute-command tcsh
In a bash shell, if you put some command that is not installed on your system, it throws an error and also gives you a package installation suggestion. For example-
$ iostat
Command 'iostat' not found, but can be installed with:
sudo apt install sysstat
My personal favorite is tcsh but it does not give any package installation suggestion while some command is not found. How can I get the package installation suggestion (like bash) in tcsh?
command-line execute-command tcsh
asked May 15 at 13:22
sabquat
285
285
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
The magic works because of command_not_found
package that provide a command_not_found_handle
function for both bash and zsh.
This works in bash because of this snippet in /etc/bash.bashrc
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not foundn" "$1" >&2
return 127
fi
fi
There is also a file /etc/zsh_command_not_found
that you can source to get that behavior for zsh - here, the function is called command_not_found_handler
.
From a quick search, it does not seem that tcsh include such a functionnality to define a command_not_found_handle
. So may be the name, is different, in that case you just need to convert the snippet in tcsh and include it in your ~/.tcshrc
, else you can't!
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The magic works because of command_not_found
package that provide a command_not_found_handle
function for both bash and zsh.
This works in bash because of this snippet in /etc/bash.bashrc
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not foundn" "$1" >&2
return 127
fi
fi
There is also a file /etc/zsh_command_not_found
that you can source to get that behavior for zsh - here, the function is called command_not_found_handler
.
From a quick search, it does not seem that tcsh include such a functionnality to define a command_not_found_handle
. So may be the name, is different, in that case you just need to convert the snippet in tcsh and include it in your ~/.tcshrc
, else you can't!
add a comment |Â
up vote
0
down vote
The magic works because of command_not_found
package that provide a command_not_found_handle
function for both bash and zsh.
This works in bash because of this snippet in /etc/bash.bashrc
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not foundn" "$1" >&2
return 127
fi
fi
There is also a file /etc/zsh_command_not_found
that you can source to get that behavior for zsh - here, the function is called command_not_found_handler
.
From a quick search, it does not seem that tcsh include such a functionnality to define a command_not_found_handle
. So may be the name, is different, in that case you just need to convert the snippet in tcsh and include it in your ~/.tcshrc
, else you can't!
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The magic works because of command_not_found
package that provide a command_not_found_handle
function for both bash and zsh.
This works in bash because of this snippet in /etc/bash.bashrc
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not foundn" "$1" >&2
return 127
fi
fi
There is also a file /etc/zsh_command_not_found
that you can source to get that behavior for zsh - here, the function is called command_not_found_handler
.
From a quick search, it does not seem that tcsh include such a functionnality to define a command_not_found_handle
. So may be the name, is different, in that case you just need to convert the snippet in tcsh and include it in your ~/.tcshrc
, else you can't!
The magic works because of command_not_found
package that provide a command_not_found_handle
function for both bash and zsh.
This works in bash because of this snippet in /etc/bash.bashrc
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not foundn" "$1" >&2
return 127
fi
fi
There is also a file /etc/zsh_command_not_found
that you can source to get that behavior for zsh - here, the function is called command_not_found_handler
.
From a quick search, it does not seem that tcsh include such a functionnality to define a command_not_found_handle
. So may be the name, is different, in that case you just need to convert the snippet in tcsh and include it in your ~/.tcshrc
, else you can't!
edited May 15 at 14:02
answered May 15 at 13:50
solsTiCe
4,87721642
4,87721642
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%2f1036531%2fbash-like-installation-suggestion-in-tcsh%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