如何在 .bashrc 檔案中建立命令的捷徑?

如何在 .bashrc 檔案中建立命令的捷徑?

我在 Infomaniak 的共用伺服器上安裝了 Drupal 9。上面安裝了 Drush 和 Composer。

目前要使用 Composer,我必須執行composer2命令。

目前要使用 Drush 我必須執行vendor/bin/drush指令。

我創建了一個.bashrc文件,因為它不存在:

cd ~
touch .bashrc
nano .bashrc

我應該在這個檔案中放入什麼才能透過輸入drush命令來使用 Drush 以及如何透過輸入composer命令來使用 Composer ?

source ~/.profile
alias composer="composer2"

我將上面的程式碼新增到文件中,但它沒有執行任何操作。以下是 Drush 指令的 Infomaniak 文件:

https://www.infomaniak.com/en/support/faq/2152/administering-drupal-on-the-command-line-with-drush

答案1

您可以在全域檔案中執行類似的操作。這允許我輸入la而不是ls -lah

使用您喜歡的文字編輯器將以下內容新增至系統範圍的設定檔/etc/bash.bashrc或使用者的設定檔:~/.bashrc

export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias la='ls -lah'

透過執行命令應用更改

~$ source /etc/bashrc; source ~/.bashrc

答案2

採取

source ~/.profile

運行時在 .bashrc 之外。它正在尋找 ~/.profile 來運行,但沒有找到它並退出。

相關內容