Work dispatch on linux

出自 Chan
前往: 導覽搜尋

vim

安裝

add-apt-repository ppa:jonathonf/vim
apt update
apt install vim

composer

安裝

https://getcomposer.org/download/

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

常用

composer global require friendsofphp/php-cs-fixer

git

安裝

add-apt-repository ppa:git-core/ppa
apt update
apt install git

設定

git config --global user.name 'Chan'
git config --global user.email '[email protected]'
git config --global core.editor vim
git config --global core.autocrlf false

git config --global alias.cm commit
git config --global alias.ps push
git config --global alias.pl pull --reabase
git config --global alias.st status
git config --global alias.ch checkout

show branch in prompt

add to .bashrc

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[email protected]\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

nodejs

https://nodejs.org/en/download/package-manager/

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
aptitude install nodejs

常用

npm install -g tldr
npm install -g npm-check

eslint

npm i -g eslint eslint-config-airbnb-base eslint-plugin-import

.eslintrc.json

http://vim.chan15.info/download/.eslintrc.json

{
    "extends": "airbnb-base",
    "rules": {
        "arrow-body-style": 0,
        "comma-dangle": 0,
        "consistent-return": 0,
        "func-names": 0,
        "guard-for-in": 0,
        "indent": 0,
        "max-len": 0,
        "no-alert": 0,
        "no-console": 0,
        "no-continue": 0,
        "no-param-reassign": 0,
        "no-plusplus": 0,
        "no-restricted-imports": 0,
        "no-restricted-syntax": 0,
        "no-shadow": 0,
        "no-undef": 0,
        "no-unused-vars": 0,
        "no-use-before-define": 0,
        "no-var": 0,
        "object-shorthand": 0,
        "prefer-arrow-callback": 0,
        "prefer-template": 0,
        "radix": 0,
        "space-before-function-paren": 0,
        "vars-on-top": 0,
        "defalut-case": 0,
        "class-methods-use-this": 0
    }
}

fixjson

npm i -g fixjson

basic setting

設定 swag

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

校正時間

ntpdate time.stdtime.gov.tw
dpkg-reconfigure tzdata

啟動關閉服務

apt-get install sysv-rc-conf
sysv-rc-conf --list #列出服務
sysv-rc-conf apache2 on #將服務放置啟動區
sysv-rc-conf apache2 off #將服務從啟動區移除

tmux

add to .bashrc

cat <<EOF > ~/.tmux.conf
set -g default-terminal "xterm"
setw -g mode-keys vi
EOF

echo alias tmux=\'tmux -2\' | sudo tee -a $HOME/.bashrc