mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
Fix ps
command to show process name only (#4544)
* Fix `ps` command to show process name only * Remove `command_only` - it is no longer being used
This commit is contained in:
parent
da42100374
commit
3ecf17e7af
@ -303,20 +303,15 @@ impl ProcessInfo {
|
|||||||
|
|
||||||
/// Name of command
|
/// Name of command
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
// self.command()
|
|
||||||
// .split(' ')
|
|
||||||
// .collect::<Vec<_>>()
|
|
||||||
// .first()
|
|
||||||
// .map(|x| x.to_string())
|
|
||||||
// .unwrap_or_default()
|
|
||||||
self.command_only()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Full name of command, with arguments
|
|
||||||
pub fn command(&self) -> String {
|
|
||||||
if let Some(path) = &self.curr_path {
|
if let Some(path) = &self.curr_path {
|
||||||
if !path.cmd.is_empty() {
|
if !path.cmd.is_empty() {
|
||||||
path.cmd.join(" ").replace("\n", " ").replace("\t", " ")
|
let command_path = &path.exe;
|
||||||
|
|
||||||
|
if let Some(command_name) = command_path.file_name() {
|
||||||
|
command_name.to_string_lossy().to_string()
|
||||||
|
} else {
|
||||||
|
command_path.to_string_lossy().to_string()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String::from("")
|
String::from("")
|
||||||
}
|
}
|
||||||
@ -325,11 +320,11 @@ impl ProcessInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Full name of comand only
|
/// Full name of command, with arguments
|
||||||
pub fn command_only(&self) -> String {
|
pub fn command(&self) -> String {
|
||||||
if let Some(path) = &self.curr_path {
|
if let Some(path) = &self.curr_path {
|
||||||
if !path.cmd.is_empty() {
|
if !path.cmd.is_empty() {
|
||||||
path.exe.to_string_lossy().to_string()
|
path.cmd.join(" ").replace("\n", " ").replace("\t", " ")
|
||||||
} else {
|
} else {
|
||||||
String::from("")
|
String::from("")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user