diff options
| author | Conrad Ludgate <conradludgate@gmail.com> | 2021-02-14 17:18:02 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-14 17:18:02 +0000 |
| commit | 72c5ea79147f7bd486839cfeb4aab62a98a0bdd2 (patch) | |
| tree | b9bfffc47dc3a8ad457bb8bd414a215eea26504e /src/local/history.rs | |
| parent | Neaten the history listing code (#5) (diff) | |
| download | atuin-72c5ea79147f7bd486839cfeb4aab62a98a0bdd2.zip | |
tidy some stuff (#6)
Diffstat (limited to 'src/local/history.rs')
| -rw-r--r-- | src/local/history.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/local/history.rs b/src/local/history.rs index e46180b8..06a350fc 100644 --- a/src/local/history.rs +++ b/src/local/history.rs @@ -24,17 +24,11 @@ impl History { session: Option<String>, hostname: Option<String>, ) -> Self { - // get the current session or just generate a random string - let env_session = - env::var("ATUIN_SESSION").unwrap_or_else(|_| Uuid::new_v4().to_simple().to_string()); - - // best attempt at getting the current hostname, or just unknown - let os_hostname = hostname::get().unwrap(); - let os_hostname = os_hostname.to_str().unwrap(); - let os_hostname = String::from(os_hostname); - - let session = session.unwrap_or(env_session); - let hostname = hostname.unwrap_or(os_hostname); + let session = session.unwrap_or_else(|| { + env::var("ATUIN_SESSION").unwrap_or_else(|_| Uuid::new_v4().to_simple().to_string()) + }); + let hostname = + hostname.unwrap_or_else(|| hostname::get().unwrap().to_str().unwrap().to_string()); Self { id: Uuid::new_v4().to_simple().to_string(), |
