Small application with own service-based architecture.
Changing git user in .gitconfig
and SSH keys by round-robin.
1.9.3 and greater.
-
Separate users' configuration lines must be commented in
.gitconfig
:[user] # email = [email protected] # name = Sample User 1 email = [email protected] name = Sample User 2 # email = [email protected] # name = Sample User 3
-
(Optional)
<.ssh>
folder must have next tree structure:<.ssh> - id_rsa - id_rsa.pub <git-users> <[email protected]> - id_rsa - id_rsa.pub <[email protected]> - id_rsa - id_rsa.pub
-
Execute by
ruby actions/change.rb
-
After successful execution you will receive information about current user:
## Email was replaced to [email protected] ## ## Name was replaced to Sample User 3 ## ## SSH keys were replaced ## ## <.gitconfig> was changed successfully! ##
-
Current user will be changed to next in order:
[user] # email = [email protected] # name = Sample User 1 # email = [email protected] # name = Sample User 2 email = [email protected] name = Sample User 3
Also you can execute code in silent mode - just pass silent: true
to Change::Process
service.
Simplified version of application is placed in <script>
folder.
-
Move to
<script>
folder:cd script
-
Run shell script using
./guser.sh
Also you can execute code in silent mode - just pass true
on shell script execution.
./guser.sh true
-
Copy script to closer to home folder
mkdir -p ~/.ssh-swap && \ cp script/guser.rb ~/.ssh-swap/
-
Add alias to your console shell
# For OhMyZsh users echo '\nalias guser="ruby ~/.ssh-swap/guser.rb"' >> ~/.zshrc && \ source ~/.zshrc # For Bash users echo '\nalias guser="ruby ~/.ssh-swap/guser.rb"' >> ~/.bashrc && \ source ~/.bashrc
-
Execute the next command to swap git user
guser