Zsh: consistent history between machines

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Use case: distribute zsh's history between machines in source control.
Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to avoid re-typing commands and quick trace.
zsh command-history version-control
add a comment |Â
up vote
0
down vote
favorite
Use case: distribute zsh's history between machines in source control.
Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to avoid re-typing commands and quick trace.
zsh command-history version-control
Zsh saves history in~/.zsh_history.
â Henrik
2 hours ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Use case: distribute zsh's history between machines in source control.
Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to avoid re-typing commands and quick trace.
zsh command-history version-control
Use case: distribute zsh's history between machines in source control.
Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to avoid re-typing commands and quick trace.
zsh command-history version-control
zsh command-history version-control
edited 2 mins ago
Jeff Schaller
35.2k952115
35.2k952115
asked 3 hours ago
Tuyen Pham
375111
375111
Zsh saves history in~/.zsh_history.
â Henrik
2 hours ago
add a comment |Â
Zsh saves history in~/.zsh_history.
â Henrik
2 hours ago
Zsh saves history in
~/.zsh_history.â Henrik
2 hours ago
Zsh saves history in
~/.zsh_history.â Henrik
2 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Modify PROMPT_COMMAND since it executes before each new prompt line.
11:40:22 jmunsch@pop-os network â export OLD_PROMPT=$PROMPT_COMMAND
11:52:38 jmunsch@pop-os network â unset PROMPT_COMMAND && export PROMPT_COMMAND="echo ssh copy the files to another machine; $PROMPT_COMMAND"
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â pwd
/etc/systemd/network
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â export PROMPT_COMMAND=$OLD_PROMPT
11:53:09 jmunsch@pop-os network âÂÂ
One possible way to do this, you can update the .zshrc on each machine, this would also work for a .bashrc, i'm not sure how reliable, or consistent it will be if a bunch of commands are running across multiple machines at the same time:
# across terminals, sessions, and machines
export machine1=192.168.43.70
export OLD_PROMPT=$PROMPT_COMMAND
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; scp ~/.zsh_history $machine1:~/.zsh_history; $PROMPT_COMMAND"
history flags explained:
-aappend the current session history to the history file-cclear the sessions history-rread the history file into the session history
scp explained:
- ssh copy your current ~/.zsh_history
- to a remote location on machine1 `$machine1:/home/someuser/remote/location
- you can do this for multiple machines by repeating the ssh copy for each address
To make it easier to do this
- Setup key based ssh login.
- Add hostnames/usernames to the
.ssh/ssh_config.
Can you give an explanation onexport PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.
â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Modify PROMPT_COMMAND since it executes before each new prompt line.
11:40:22 jmunsch@pop-os network â export OLD_PROMPT=$PROMPT_COMMAND
11:52:38 jmunsch@pop-os network â unset PROMPT_COMMAND && export PROMPT_COMMAND="echo ssh copy the files to another machine; $PROMPT_COMMAND"
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â pwd
/etc/systemd/network
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â export PROMPT_COMMAND=$OLD_PROMPT
11:53:09 jmunsch@pop-os network âÂÂ
One possible way to do this, you can update the .zshrc on each machine, this would also work for a .bashrc, i'm not sure how reliable, or consistent it will be if a bunch of commands are running across multiple machines at the same time:
# across terminals, sessions, and machines
export machine1=192.168.43.70
export OLD_PROMPT=$PROMPT_COMMAND
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; scp ~/.zsh_history $machine1:~/.zsh_history; $PROMPT_COMMAND"
history flags explained:
-aappend the current session history to the history file-cclear the sessions history-rread the history file into the session history
scp explained:
- ssh copy your current ~/.zsh_history
- to a remote location on machine1 `$machine1:/home/someuser/remote/location
- you can do this for multiple machines by repeating the ssh copy for each address
To make it easier to do this
- Setup key based ssh login.
- Add hostnames/usernames to the
.ssh/ssh_config.
Can you give an explanation onexport PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.
â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
add a comment |Â
up vote
1
down vote
Modify PROMPT_COMMAND since it executes before each new prompt line.
11:40:22 jmunsch@pop-os network â export OLD_PROMPT=$PROMPT_COMMAND
11:52:38 jmunsch@pop-os network â unset PROMPT_COMMAND && export PROMPT_COMMAND="echo ssh copy the files to another machine; $PROMPT_COMMAND"
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â pwd
/etc/systemd/network
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â export PROMPT_COMMAND=$OLD_PROMPT
11:53:09 jmunsch@pop-os network âÂÂ
One possible way to do this, you can update the .zshrc on each machine, this would also work for a .bashrc, i'm not sure how reliable, or consistent it will be if a bunch of commands are running across multiple machines at the same time:
# across terminals, sessions, and machines
export machine1=192.168.43.70
export OLD_PROMPT=$PROMPT_COMMAND
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; scp ~/.zsh_history $machine1:~/.zsh_history; $PROMPT_COMMAND"
history flags explained:
-aappend the current session history to the history file-cclear the sessions history-rread the history file into the session history
scp explained:
- ssh copy your current ~/.zsh_history
- to a remote location on machine1 `$machine1:/home/someuser/remote/location
- you can do this for multiple machines by repeating the ssh copy for each address
To make it easier to do this
- Setup key based ssh login.
- Add hostnames/usernames to the
.ssh/ssh_config.
Can you give an explanation onexport PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.
â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Modify PROMPT_COMMAND since it executes before each new prompt line.
11:40:22 jmunsch@pop-os network â export OLD_PROMPT=$PROMPT_COMMAND
11:52:38 jmunsch@pop-os network â unset PROMPT_COMMAND && export PROMPT_COMMAND="echo ssh copy the files to another machine; $PROMPT_COMMAND"
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â pwd
/etc/systemd/network
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â export PROMPT_COMMAND=$OLD_PROMPT
11:53:09 jmunsch@pop-os network âÂÂ
One possible way to do this, you can update the .zshrc on each machine, this would also work for a .bashrc, i'm not sure how reliable, or consistent it will be if a bunch of commands are running across multiple machines at the same time:
# across terminals, sessions, and machines
export machine1=192.168.43.70
export OLD_PROMPT=$PROMPT_COMMAND
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; scp ~/.zsh_history $machine1:~/.zsh_history; $PROMPT_COMMAND"
history flags explained:
-aappend the current session history to the history file-cclear the sessions history-rread the history file into the session history
scp explained:
- ssh copy your current ~/.zsh_history
- to a remote location on machine1 `$machine1:/home/someuser/remote/location
- you can do this for multiple machines by repeating the ssh copy for each address
To make it easier to do this
- Setup key based ssh login.
- Add hostnames/usernames to the
.ssh/ssh_config.
Modify PROMPT_COMMAND since it executes before each new prompt line.
11:40:22 jmunsch@pop-os network â export OLD_PROMPT=$PROMPT_COMMAND
11:52:38 jmunsch@pop-os network â unset PROMPT_COMMAND && export PROMPT_COMMAND="echo ssh copy the files to another machine; $PROMPT_COMMAND"
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â pwd
/etc/systemd/network
ssh copy the files to another machine
11:52:38 jmunsch@pop-os network â export PROMPT_COMMAND=$OLD_PROMPT
11:53:09 jmunsch@pop-os network âÂÂ
One possible way to do this, you can update the .zshrc on each machine, this would also work for a .bashrc, i'm not sure how reliable, or consistent it will be if a bunch of commands are running across multiple machines at the same time:
# across terminals, sessions, and machines
export machine1=192.168.43.70
export OLD_PROMPT=$PROMPT_COMMAND
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; scp ~/.zsh_history $machine1:~/.zsh_history; $PROMPT_COMMAND"
history flags explained:
-aappend the current session history to the history file-cclear the sessions history-rread the history file into the session history
scp explained:
- ssh copy your current ~/.zsh_history
- to a remote location on machine1 `$machine1:/home/someuser/remote/location
- you can do this for multiple machines by repeating the ssh copy for each address
To make it easier to do this
- Setup key based ssh login.
- Add hostnames/usernames to the
.ssh/ssh_config.
edited 44 mins ago
answered 1 hour ago
jmunsch
1,5331920
1,5331920
Can you give an explanation onexport PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.
â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
add a comment |Â
Can you give an explanation onexport PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.
â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
Can you give an explanation on
export PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.â Tuyen Pham
1 hour ago
Can you give an explanation on
export PROMPT_COMMAND="history -a; history -c; <...>, still look ambiguous to me. Even though I don't work at both machines at the same time, your setup look interesting for another use-case that I would cross in the future.â Tuyen Pham
1 hour ago
@TuyenPham updated
â jmunsch
51 mins ago
@TuyenPham updated
â jmunsch
51 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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%2funix.stackexchange.com%2fquestions%2f479592%2fzsh-consistent-history-between-machines%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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');
);
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');
);
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
Zsh saves history in
~/.zsh_history.â Henrik
2 hours ago