<p>Try using <a href="https://www.gnu.org/software/screen/" rel="nofollow noreferrer">GNU Screen</a> or <a href="https://github.com/tmux/tmux" rel="nofollow noreferrer">Tmux</a>. These are called "screen multiplexers" but you'd get a number of benefits</p>

<ol>
<li>The commands you run will continue running even if you disconnect, or you have network related connection drops. Both software allow "re-attaching" to the running session</li>
<li>Command outputs will persist in memory. You can start a long running command, log off, then connect back some time later and see the output of the command.</li>
<li>Save the whole shell session to a file. You can have the log of all the commands you issued, as well as the output you got, in plain text format.</li>
</ol>

CC BY-SA 4.0
2019-05-14T01:35:53.647Z
Incidentally, tmux is much easier to automate than screen.
chicks
CC BY-SA 4.0
2019-05-13T23:44:26.563Z
2019-05-13T23:44:26.563Z
hayalci
<p>For the second part, what happens if you <code>export PS1</code> in <code>~/.bashrc</code> or <code>~/ .bash_profile</code></p>

<pre><code>export PS1='$(whoami)@$(hostname):$(pwd)'
</code></pre>

CC BY-SA 4.0
2019-05-14T01:41:09.457Z
It seems strange to loop through `$(pwd)` when it only returns on thing.
chicks
CC BY-SA 4.0
2019-05-14T01:56:01.213Z
Right. I think, exporting PS1 would be better
Rakib Fiha
CC BY-SA 4.0
2019-05-14T01:28:01.627Z
2019-05-14T02:15:22.953Z
2019-05-14T02:15:22.953Z
Rakib Fiha
<p>Every time I ssh into a server I might issue some bash commands and then sign off (hup signal?). Is there a way to write the shell commands that I issued on the server to some changelog file?</p>

<p>I want to remove basic commands like ls/cd, and duplicate commands, as well.  It's basically as if every command I issue in bash is like this:</p>

<pre><code>eval "$(my_command | tee "$HOME/change.log")"
</code></pre>

<p>but I don't know how to set this up, anybody know a good way to do this?</p>

<p>It would be really nice to eliminate commands like ls and cd, but also show the pwd of every command that was issued:</p>

<pre><code>command  (/home/ubuntu)
command1 (/root/.ssh)
command2 (/home/ubuntu/teros)
command1 (/usr/local)
command1 (/usr/local/lib)
command3 (/etc)
</code></pre>

<bash><ssh>
Automatically write new bash history to change-log file
Alexander Mills
# Automatically write new bash history to change-log file

(Asked by: username_0 on 2019-05-13)

Every time I ssh into a server I might issue some bash commands and then sign off (hup signal?). Is there a way to write the shell commands that I issued on the server to some changelog file?
I want to remove basic commands like ls/cd, and duplicate commands, as well.  It's basically as if every command I issue in bash is like this:
eval "$(my_command | tee "$HOME/change.log")"

but I don't know how to set this up, anybody know a good way to do this?
It would be really nice to eliminate commands like ls and cd, but also show the pwd of every command that was issued:
command  (/home/ubuntu)
command1 (/root/.ssh)
command2 (/home/ubuntu/teros)
command1 (/usr/local)
command1 (/usr/local/lib)
command3 (/etc)

**Tags:** bash, ssh


---

## 2 answers

### Answer by username_1 on 2019-05-13. Score: 2 | Accepted answer

Try using [GNU Screen](https://www.gnu.org/software/screen/) or [Tmux](https://github.com/tmux/tmux). These are called "screen multiplexers" but you'd get a number of benefits

1. The commands you run will continue running even if you disconnect, or you have network related connection drops. Both software allow "re-attaching" to the running session
2. Command outputs will persist in memory. You can start a long running command, log off, then connect back some time later and see the output of the command.
3. Save the whole shell session to a file. You can have the log of all the commands you issued, as well as the output you got, in plain text format.

> **Comments:**
> **username_2**: Incidentally, tmux is much easier to automate than screen.  

---

### Answer by username_3 on 2019-05-14. Score: 0

For the second part, what happens if you export PS1 in ~/.bashrc or ~/ .bash_profile
export PS1='$(whoami)@$(hostname):$(pwd)'

> **Comments:**
> **username_2**: It seems strange to loop through `$(pwd)` when it only returns on thing.  
> **username_3**: Right. I think, exporting PS1 would be better  

---

