When updating WordPress, updating site design, updating PHP, etc., I often connect to a rental server called [xserver] using SSH. It’s tedious to type the same long command every time, right?
I have to type the following command every time, but I’ll introduce a way to make this more convenient:
ssh -R 52698:localhost:52698 -p 10022 -i ~/.ssh/yuis.key [email protected]
To execute this easily, let’s create a shell script. I’ve made it so I can log into xserver by executing the command . ~/lib/xserv. This shell script looks like this:
cat ~/lib/xserv
The content is the above SSH command. Just creating this shell script makes work much easier.
For an even more efficient method, by setting cd ~/lib in the .bashrc file and creating an s file in the lib folder, you can execute the command just by typing . s the moment you open the terminal. Creating such shortcuts might be simple, but it’s one useful method.
Setting up shortcuts for frequently used commands improves work efficiency.
Bonus
Let me introduce another convenient trick. I mainly log into the server to change my main blog’s design, and every time I need to navigate to that blog’s public directory, especially the child theme directory. In that case, I use a command like:
[yuis@sv2031 ~]$ . s
[yuis@sv2031 haminfubard-child]$
This way, right after logging into the rental server, I can navigate to the child theme directory just by typing . s. Then I can start work immediately by executing commands like rmate /temp/hogehoge.php.
Now, let’s look at what’s inside this s file:
[yuis@sv2031 ~]$ cat s
cd $fuumin_net/wp-content/themes/haminfubard-child
Just this command. It’s a very simple method, but very convenient. It’s a useful trick when always updating WordPress files via SSH.
(Note: You could also consider adding these commands to the .bashrc file.)
These shortcuts and tricks will be useful when updating WordPress or managing sites using SSH. Try using these methods to improve your work efficiency.