Sublime is a powerful cross-platform code editing tool, not much to say.
Want to use sublime to complete the code editing work for the Django website under the Linux platform to improve efficiency (originally using Vim under Linux is less efficient and suitable for editing some of the little feet).
Download sublime_text_2.0.2_x64.tar.bz2 (http://www.sublimetext.com/) under the Linux platform
Unzip using:
TAR-XJVF sublime_text_2.0.2_x64.tar.bz2
CD sublime\ text\ 2/
Run
./sublime_text
Error
./sublime_text:/usr/lib64/libstdc++.so.6:version ' glibcxx_3.4.11 ' not found (required by./sublime_text)
./sublime_text:/usr/lib64/libstdc++.so.6:version ' glibcxx_3.4.9 ' not found (required by./sublime_text)
./sublime_text:/lib64/libc.so.6:version ' glibc_2.11 ' not found (required by./sublime_text)
The reason is that the system used is centos5, the version number is too low, and the C/S library version number is too low.
The company's computer can not easily upgrade the library or upgrade the system, only to find another way.
Imagine one:
The code on the Linuxserver is pulled down on the Windows machine, edited using sublime on the Windows platform, and then uploaded to Linuxserver.
Problem: Code editing often requires actual debugging, especially for site-type code. You often need to edit it and immediately verify the results. And our entire execution environment is built under the Linux platform, in this way, we need to pull the code from Linuxserver down the Windows platform, modify a place and then back to Linuxserver, test execution. If there is a problem, pull down the editor again. Upload and test again. So go on. It's tedious and time-consuming. Is there a better way?
Scenario Two:
Use Git to build a repository for code on Linuxserver, and clone the repository on Windows. Use sublime to edit the code in the clone's repository. After editing, a push command pushes all submitted updates to the remote code repository for testing. The process, like the idea, is improved by using GIT commands to push updates to remote linuxserver instead of manually uploading the updated files to the remote server individually.
Do not know if there is a problem, try it first:
has already created the Code warehouse on Linuxserver. Location
/VAR/WWW/SITE/MYCITSM
Use the. git folder under the/var/www/site/mycitsm folder to create a code repository for other machine clones
sudo git remote add Origin ssh://[email protected]:P ort/var/www/site/mycitsm/.git
The remote machine will be able to use
git clone ssh://[email protected]:P ort/var/www/site/mycitsm/.git d:/www/mycitsm
This command will pull the code warehouse on the remote server down the local d:/www/mycits folder
We download and install Git-1.9.2 (Http://git-scm.com/download/win) or third-party github on the Windows platform
Clone repository:
go to Git Bash (command-line tool created after installing git)
$git clone ssh://[email protected]:P ort/var/www/site/mycitsm/.git D:/WWW/MYCITSM
You may be prompted to enter OP1 password on the remote server (assuming that the local server's public key is written to the Authorized_keys file of the remote server without password. Detailed information on how to set up no passwordssh to a remote host, the same setup method between the Windows and Linux systems and the Linux and Linux systems.
may also be prompted not to find Git-upload-pack because the location of the GIT installation in remote server is not the standard default location. Simply copy these tools to a standard location, or set a soft connection in a standard location to connect to these tools. You can also specify the location of the tool in the Clone command, such as--upload-pack/home/op1/bin/git-upload-pack.
Since then, the folder structure and contents in the remote repository have been clone to the local WindowsServer D:/www/mycitsm folder, and you can use sublime to open the folder directly to edit the internal files.
Go to the local repository in Git bash
$CD D://WWW/MYCITSM
View git status
$git status
Submit Changes
$git Add filename
$git commit-m "some text"
To push a local warehouse to a remote repository
$git push (Origin master)
Error:
remote:error:refusing to update checked out Branch:refs/heads/master
Remote:error:By default, updating the current branch in a Non-bare repository
Remote:error:is denied, because it'll make the index and work tree inconsistent
Remote:error:with What do you pushed, and would require ' git reset--hard ' to match
Remote:error:the work tree to HEAD.
Remote:error:
Remote:error:You can set ' receive.denycurrentbranch ' configuration variable to
Remote:error: ' Ignore ' or ' warn ' in the remote repository to allow pushing into
Remote:error:its Current Branch; However, this isn't recommended unless you
Remote:error:arranged to update their work tree to match the what's pushed in some
Remote:error:other.
Remote:error:
Remote:error:To squelch This message and still keep the default behaviour, set
Remote:error: ' receive.denycurrentbranch ' configuration variable to ' refuse '.
To Ssh://[email Protected]:1022/var/www/site/mycitsm/.git
! [Remote rejected] master, master (branch is currently checked out)
Error:failed to push some refs to ' ssh://[email protected]:1022/var/www/site/my
Citsm/.git '
This means: By default, the current branch is updated in a non-bare repository, because the pushed content causes the index and working folder tree to be inconsistent.
Although it is possible to agree to push to the current branch by setting the value of the ' receive.denycurrentbranch ' variable in the git configuration file to ignore or warn, it is not recommended unless you schedule an update of the working folder tree to match what you push.
In that case, what happens if we set up a ROM warehouse?
Come to Linuxserver's/var/www/site/folder
Create a bare repository (detailed Http://git-scm.com/book/zh):
$ git clone--bare mycitsm mycitsm.git
The command is actually equivalent to
$ CP-RF Mycitsm/.git Mycitsm.git
Then move the warehouse to where you want it to be.
$sudo git remote Add origin ssh://[email protected]:P ort/var/www/site/mycitsm.git
$git clone Ssh://[email protected]:P ort/var/www/site/mycitsm.git D:/WWW/MYCITSM
Edit with Sublime, submit locally, push to remote repository.
No exception was seen.
Does that mean we can test it in a remote warehouse?
Even to linuxserver into the/var/www/site/mycitsm/folder found inside the file did not happen no matter what changes. Oh yes, we pushed the update to the bare warehouse mycitsm.git on Linuxserver.
Enter the Mycitsm.git. Well, there is no working folder tree (this is why ROM warehouse is called Bare warehouse). It only records the submission history information.
It took a lot of effort, which means we wouldn't be able to sync the latest local content to the Linux original repository in this way, just to sync the change information to the relevant bare repository. And we can't get a folder file that can be tested in a bare repository.
Both of these options have a problem. That's the file change in Linuxserver. Cannot actively direct feedback to the Windows side, we must again pull back the latest file talent see this change.
Imagine three:
It is tempting to know that Sublime has a plugin called SFTP that can be edited directly by opening files on the remote machine and syncing directly to the remote machine after saving.
Install the package management plug-in for sublime first:
Press CTRL + ' bring up the sublime console, paste the following code into the console and enter
Import Urllib2,os;
Pf= ' Package control.sublime-package ';
Ipp=sublime.installed_packages_path ();
Os.makedirs (IPP) if not os.path.exists (IPP) else None;
Open (Os.path.join (IPP,PF), ' WB '). Write (Urllib2.urlopen (' http://sublime.wbond.net/' +pf.replace (', '%20 '). Read () )
Restart the sublime and see the package control entry in Perferences->package settings to install successfully.
Installing plug-ins with the package control
Press Ctrl+shift+p to bring up the command panel
Enter install to bring up the Install Package option and enter the FTP, and some related plugins will appear in the drop-down list. Select SFTP for installation, and configure the following for example: select File->sftp/ftp->set up Server in the menu bar. Then a configuration form appears such as the following:
{
The TAB key would cycle through the settings when first created
Visit http://wbond.net/sublime_packages/sftp/settings for help
SFTP, FTP or FTPS
"Type": "FTP",
"Sync_down_on_open": true,
"Sync_same_age": true,
"Host": "IP",
"User": "username",
"Password": "Passowrd",
"Port": "22",
"Remote_path": "/var/www/site/mycitsm/",
"File_permissions": "664",
"Dir_permissions": "775",
"Extra_list_connections": 0,
"Connect_timeout": 30,
"KeepAlive": 120,
"Ftp_passive_mode": true,
"Ftp_obey_passive_host": false,
"Ssh_key_file": "~/.ssh/id_rsa",
"Sftp_flags": ["-F", "/path/to/ssh_config"],
"Preserve_modification_times": false,
"Remote_time_offset_in_hours": 0,
"Remote_encoding": "Utf-8",
"Remote_locale": "C",
"Allow_config_upload": false,
}
The general configuration of the parameters can be
"Host": "Yourip",
"User": "YourUserName",
"Password": "YOURPASSOWRD",
"Remote_path": "Yourpath",
Such a method requires that the remote Linux server be able to connect via SFTP or FTP, and that there is something like FTP server on the remote Linux server. The FTP server product is very many, choose one installs the configuration to be OK.
Installation configuration for detailed product.
Both the FTP server side and the sublime end of Linux are configured so that you can view the folders and files on the remote server through File->stfp/ftp/browser server. You can then rename the folder, edit the file, and so on, based on the commands provided. The edited file can be synced to a remote Linux server immediately after it is saved.
The program seems to have tackled our problems very well. But let's not be perfect, the experience of working folders in the Linuxserver in sublime is very bad. You must use a command to return the value to the previous folder, edit the file, rename the operation. Navigating in different folders and files is very inconvenient.
Is there a plan to synchronize the specified folders in the remote Linuxserver to Windows Local. Open the Windows Local folder directly with sublime and display a perfect folder tree. Quickly switch edits between folders and files, and synchronize updates to remote server in real time?
Finally solution:
Kung Fu is a conscientious, find that there is really such a thing. It is possible to attach a folder of remote server locally to a remote server via SSH, and remote or local changes can react to one end in real time (in fact. Both are in the same location, and you are editing the files on the linuxserver.
So we just need to mount the desired folder on Linuxserver to Windows Local, and using sublime to open the folder is exactly the same as opening the other local folder. Edit the files in the folder directly.
This tool is called SSHFS using SSH to access the remote host, which is used by the Windows version number and the Linux version number to mount the remote folder on Windows and Linux respectively.
Download the Install Windows version number tool
To first install the dependency: Dokan library-->dokaninstall_0.6.0.exe (Http://dokan-dev.net/wp-content/uploads/DokanInstall_0.6.0.exe)
In the installation SSHFS itself: Win-sshfs-0.0.1.5-setup.exe (Https://win-sshfs.googlecode.com/files/win-sshfs-0.0.1.5-setup.exe)
After you start, configure the specified host, port, username, password, directory, and so on, the folder is mounted locally, and then you can use sublime's arbitrary editing.
The goal is finally reached!
Windows platform is on the sublime edit files on the remote Linux platform