複数バージョン併用などがあるかもしれないので。
概要
vim
を実行バイナリファイルでなくシンボリックリンクにする。
別バージョンのvimを入れるときはサフィックスにバージョン値を入れるようにする。そして使うのはvim
シンボリックリンクにリンクされたもの。こうすればvim
という名前を使ったままバージョンを変えることができる。
手順
vim
があるディレクトリへ移動する。
cd $(dirname $(which vim))
vim
は実行バイナリファイルである。
``sh $ ls -l | grep 'vim' -rwxr-xr-x 1 root staff 2464028 3月 18 13:12 vim
`vim`をリネームする。(接尾辞にバージョンを付与する)
sudo mv vim vim8.1.1017 sudo ln -s vim8.1.1017 vim
シンボリックリンク`vim`を作る。
sudo ln -s vim8.1.1017 vim
確認する。
$ ls -l | grep 'vim' lrwxrwxrwx 1 root root 11 3月 27 15:30 vim -> vim8.1.1017 -rwxr-xr-x 1 root staff 2464028 3月 18 13:12 vim8.1.1017
`vim`は`vim8.1.1017`のリンクである。 # 前回 * [vim 8.1 クリップボードにコピーできるバイナリをビルドする](http://ytyaru.hatenablog.com/entry/2020/05/22/000000) # 参考 ## `ln`コマンド
$ ln --help 使用法: ln [OPTION]... [-T] TARGET LINK_NAME (1番目の形式) または: ln [OPTION]... TARGET (2番目の形式) または: ln [OPTION]... TARGET... DIRECTORY (3番目の形式) または: ln [OPTION]... -t DIRECTORY TARGET... (4番目の形式) In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in the current directory. In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links by default, symbolic links with --symbolic. By default, each destination (name of new link) should not already exist. When creating hard links, each TARGET must exist. Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted in relation to its parent directory.
Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] 対象ファイルが存在する時にバックアップを作成する -b --backup と同様だが引数を取らない -d, -F, --directory スーパーユーザがディレクトリに対するハードリンク を作成することを許可する。(備考: スーパーユーザ であってもシステムの制限で失敗することがある) -f, --force 対象ファイルが存在する時に削除する -i, --interactive prompt whether to remove destinations -L, --logical dereference TARGETs that are symbolic links -n, --no-dereference treat LINK_NAME as a normal file if it is a symbolic link to a directory -P, --physical make hard links directly to symbolic links -r, --relative create symbolic links relative to link location -s, --symbolic make symbolic links instead of hard links -S, --suffix=SUFFIX override the usual backup suffix -t, --target-directory=DIRECTORY specify the DIRECTORY in which to create the links -T, --no-target-directory treat LINK_NAME as a normal file always -v, --verbose print name of each linked file --help この使い方を表示して終了する --version バージョン情報を表示して終了する
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values:
none, off バックアップを作成しない (--backup を付けた時でも) numbered, t 番号付きバックアップを作成する existing, nil 番号付きバックアップがあれば番号付き、 そうでなければ、simple で作成する simple, never 常に簡易バックアップを作成
Using -s ignores -L and -P. Otherwise, the last option specified controls behavior when a TARGET is a symbolic link, defaulting to -P.
GNU coreutils online help: http://www.gnu.org/software/coreutils/ ln の翻訳に関するバグは http://translationproject.org/team/ja.html に連絡してください。 Full documentation at: http://www.gnu.org/software/coreutils/ln or available locally via: info '(coreutils) ln invocation'
# 対象環境 * Raspbierry pi 3 Model B+ * Raspbian stretch 9.0 2018-11-13 * bash 4.4.12 * python 2.7.13, pip 9.0.1 * python3 3.5.3, pip3 9.0.1 * ranger 1.9.2
$ uname -a Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux