Skip to content

Zeroplex 生活隨筆

軟體開發、伺服器和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

標籤: Linux

Setting Vim from Command Line Argument

Posted on 2013 年 9 月 3 日2021 年 3 月 12 日 By 日落 在〈Setting Vim from Command Line Argument〉中尚無留言

因不同環境編碼不同,而需要從外部程式呼叫 vim 時直接設定編碼。苦想不到解法時,看到 NeoBundle 第一次執行 vim 要安裝 bundle 時,執行「vim +NeoBundleInstall」,翻了很久才找到「+」的說明文件 (天曉得為什麼要用 :h -c 才能找到文件啊 ….)

假設要在 vim 中執行「:set fileencoding=utf-8」,可以改做由 command line 執行:

vim +fileencodeing=utf-8

所以稍早在 .bashrc 裡面加了:

export SVN_EDITOR="vim +"fileencoding=utf-8 encoding=utf-8""
Tags:Linux, Vim

Set Remote Default Port for SSH Client

Posted on 2013 年 8 月 21 日2021 年 3 月 12 日 By 日落 在〈Set Remote Default Port for SSH Client〉中尚無留言

若 sshd 改成非 port 22,不少 ssh client 操作會變成很麻煩。

但可以在 .ssh/config 設定 host name 和 url、port,之後就可僅用 host name 連線。

vim ~/.ssh/config :

Host hq
HostName server.url
Port 9999
User zero

之後要連線時打「hq」即可:

  • ssh hq
  • git remote add origin hp:/path/to/repository

Reference:
git – Using a remote repository with non-standard port – Stack Overflow

Tags:Linux

Array Iterate in Bash

Posted on 2013 年 8 月 13 日2021 年 3 月 12 日 By 日落 在〈Array Iterate in Bash〉中有 2 則留言

Bash 裡面有個 for-in 可以很輕鬆的對多筆資料做迭代,不過我語法一直弄錯。

文字列表:

LIST="item1 item2 item3"

for ITEM in $LIST; do
   echo $ITEM
done

如果是陣列,語法要換:

LIST=(  
  item1 
  item2 
  item3 
)

for ITEM in ${LIST[@]}; do
  echo $ITEM
done

Reference:
Bash For Loop Array: Iterate Through Array Values

Bash Guide for Beginners – Chapter 10. More on variables

Tags:Bash, Linux

Alias Command Contains Spaces in Bash

Posted on 2013 年 7 月 9 日2021 年 3 月 12 日 By 日落 在〈Alias Command Contains Spaces in Bash〉中尚無留言

.bashrc 下設定 command alias 的方法是:

alias svm='svn'   # 我常常手殘

不過假設要 alias 的指令包含空白,如「svn commit」要 alias 成「svn commit –editor-cmd vim」,就得靠自訂 function 了。

新增一個 function 蓋掉原本的 svn 指令,如果 svn 後接的參數是 commit,便加上 –editor-cmd:

svn(){
   if [[ $@ == commit ]]; then
      command svn commit --editor-cmd vim
   else
      command svn "$@"
   fi
}

不過 svn commit 有時還會有其他參數,像是檔案路徑等,所以這樣寫還是會發生意外。要把參數判斷要改,順便在執行指令的時候把參數也塞回去:

svn(){
   if [[ $@ == commit* ]] || [[ $@ == ci* ]]; then
      command svn "$@" --editor-cmd vim
   else
      command svn "$@"
   fi
}
Tags:Bash, Linux

修改 Ubuntu 12.04 登入畫面背景圖片

Posted on 2013 年 6 月 29 日2021 年 3 月 12 日 By 日落 在〈修改 Ubuntu 12.04 登入畫面背景圖片〉中尚無留言

開啟 /usr/share/glib-2.0/schemas/com.canonical.unity-greeter.gschema.xml,並找到「com.canonical.unity-greeter」,將 key「background」改成新的圖片路徑:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="unity-greeter">
  <schema id="com.canonical.unity-greeter" path="/com/canonical/unity-greeter/">
    <key name="background" type="s">
      <default>'/usr/share/backgrounds/warty-final-ubuntu.png'</default>
      <summary>Background file to use, either an image path or a color (e.g. #772953)</summary>
    </key>

將設定值重新編譯:

cd /usr/share/glib-2.0/schemas/
sudo glib-compile-schemas .
Tags:Linux, Ubuntu

文章分頁

上一頁 1 ... 24 25 26 ... 32 下一頁

其他

關於我  (About me)

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Ubuntu Unix Vim Web Windows WordPress XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.