Archive for 十一月, 2017


Linux下atom安装及汉化

1、安装atom
到以下网址下载所需平台的atom安装包
https://github.com/atom/atom/releases/latest

————-
如果缺少依赖包就先安装
apt安装
sudo apt-get install build-essential git libsecret-1-dev fakeroot rpm libx11-dev libxkbfile-dev
安装更高版本的C++
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-5 80 –slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives –config gcc # choose gcc-5 from the list

yum安装
sudo yum install -y make gcc gcc-c++ glibc-devel git-core libsecret-devel rpmdevtools

2、安装汉化包
菜单栏“Packages -> Setting Views -> Install Packages/Themes”
搜索chinese,出现“simplified-chinese-menu"点击安装”Install"

3、常见报错处理
Q:TypeError: Unable to watch path
A:sudo sysctl fs.inotify.max_user_watches=32768
或者echo 32768 | sudo tee -a /proc/sys/fs/inotify/max_user_watches

Q:/usr/bin/env: node: No such file or directory
A:sudo update-alternatives –install /usr/bin/node node /usr/bin/nodejs 1 –slave /usr/bin/js js /usr/bin/nodejs

Q:sys.exit(gyp.script_main()) AttributeError: ‘module’ object has no attribute ‘script_main’ gyp ERR!
A:sudo yum remove gyp

PS:
https://github.com/atom/atom
https://github.com/atom/atom/blob/master/docs/build-instructions/linux.md

Linux下sublime安装及汉化

yum安装
1、导入公共密钥Install the GPG key:
sudo rpm -v –import https://download.sublimetext.com/sublimehq-rpm-pub.gpg

2、添加Stable稳定版的源:
sudo yum-config-manager –add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo

3、安装Sublime Text:
sudo yum install sublime-text

—————–
apt安装
1、导入公共密钥Install the GPG key:
wget -qO – https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add –

2、用https协议连接源Ensure apt is set up to work with https sources:
sudo apt-get install apt-transport-https

3、添加Stable稳定版的源:
echo “deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

4、更新源,安装Sublime Text
sudo apt-get update
sudo apt-get install sublime-text

=========================
汉化方法:
1、安装Package Control.sublime-package
菜单栏“View > Show Console”调出控制台,快捷键是“ctrl+`”复制如下代码粘贴进去执行。
import urllib.request,os,hashlib; h = ‘6f4c264a24d933ce70df5dedcf1dcaee’ + ‘ebe013ee18cced0ef93d5f746d80ef60’; pf = ‘Package Control.sublime-package’; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( ‘http://packagecontrol.io/’ + pf.replace(‘ ‘, ‘%20’)).read(); dh = hashlib.sha256(by).hexdigest(); print(‘Error validating download (got %s instead of %s), please try manual install’ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb’ ).write(by)

2、安装汉化包
菜单栏“Preference -> Languages”,或者快捷键“Ctrl+Shift+P”调出命令行窗口输入lmzhcn回车键安装。

PS:
https://www.sublimetext.com/docs/3/linux_repositories.html
https://packagecontrol.io/installation
https://packagecontrol.io/packages/LocalizedMenu

shell中$开头的变量含义

$# 是传给脚本的参数个数
$0 是脚本本身的名字
$1 是传递给该shell脚本的第一个参数
$2 是传递给该shell脚本的第二个参数
$@ 是传给脚本的所有参数的列表
$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个
$$ 是脚本运行的当前进程ID号
$? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误

#!/bin/sh
echo “number:$#"
echo “scname:$0″
echo “first :$1″
echo “second:$2″
echo “argume:$@"
echo “show parm list:$*"
echo “show process id:$$"
echo “show precomm stat: $?"