mirror of
https://github.com/cmderdev/cmder.git
synced 2025-11-09 21:59:08 +08:00
Add shellcheck compliance and shebang to scripts
Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
## Config
|
||||
|
||||
All config files must be in this folder. If there is no option to set this folder
|
||||
directly, it has to be hardlinked.
|
||||
|
||||
* `user_aliases.cmd`: aliases in cmd; called from vendor\init.bat; autocreated from
|
||||
`vendor\user_aliases.cmd.default`.
|
||||
* `*.lua`: clink completions and prompt filters; autoloaded after all
|
||||
prompt filter and clink completions are initialized; add your own.
|
||||
* `user_profile.{sh|cmd|ps1}`: startup files for bash|cmd|powershell tasks; called from their
|
||||
respective startup scripts in `vendor\`; autocreated from
|
||||
`vendor\user_profile.{sh|cmd|ps1}.default` on first start of such a task.
|
||||
* `.history`: the current commandline history; autoupdated on close.
|
||||
* `settings`: settings for readline; overwritten on update.
|
||||
* `user-ConEmu.xml`: settings from ConEmu the UI of Cmder. ;
|
||||
Do not edit this file directly it is overwritten on each cmder.exe launch.
|
||||
@@ -1,3 +0,0 @@
|
||||
## Profile.d Folder
|
||||
|
||||
* Files in this folder named `*.{sh|cmd|ps1}`: Will be executed by the appropriate shell when starting the shell.
|
||||
9
vendor/cmder.sh
vendored
9
vendor/cmder.sh
vendored
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# DO NOT EDIT THIS FILE IT WILL BE OVERWRITTEN ON UPDATE
|
||||
#
|
||||
# Add portable user customizations ${CMDER_ROOT}/config/user_profile.sh,
|
||||
@@ -12,11 +13,13 @@
|
||||
run_profile_d() {
|
||||
local profile_d_scripts
|
||||
pushd "${1}" >/dev/null || return
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.sh 2>/dev/null)
|
||||
|
||||
if [ -n "${profile_d_scripts}" ]; then
|
||||
for script in ${profile_d_scripts}; do
|
||||
# echo Sourcing "${1}/${script}"...
|
||||
# shellcheck disable=SC1090
|
||||
. "${1}/${script}"
|
||||
done
|
||||
fi
|
||||
@@ -25,6 +28,7 @@ run_profile_d() {
|
||||
|
||||
# Detect and set CMDER_ROOT for bash admin sessions
|
||||
# Converts Windows paths to Unix paths if needed
|
||||
# ConEmuDir is set by ConEmu/Cmder environment
|
||||
if [ -z "$CMDER_ROOT" ]; then
|
||||
case "$ConEmuDir" in
|
||||
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
|
||||
@@ -41,6 +45,7 @@ CMDER_ROOT="${CMDER_ROOT%/}"
|
||||
# Exit early if CMDER_ROOT is not set
|
||||
if [ -z "$CMDER_ROOT" ]; then
|
||||
echo "Warning: CMDER_ROOT is not set. Cmder integration skipped."
|
||||
# shellcheck disable=SC2317
|
||||
return 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
@@ -56,7 +61,7 @@ elif [ -f "${CMDER_ROOT}/vendor/git-for-windows/cmd/git.exe" ]; then
|
||||
fi
|
||||
|
||||
# Add Git to PATH if not already present
|
||||
if [[ -n "${GIT_INSTALL_ROOT}" && ! "$PATH" =~ "${GIT_INSTALL_ROOT}/bin:" ]]; then
|
||||
if [[ -n "${GIT_INSTALL_ROOT}" && ! "$PATH" =~ ${GIT_INSTALL_ROOT}/bin: ]]; then
|
||||
PATH="${GIT_INSTALL_ROOT}/bin:$PATH"
|
||||
fi
|
||||
|
||||
@@ -101,6 +106,7 @@ if [ -n "${CMDER_USER_CONFIG}" ]; then
|
||||
|
||||
# Source user profile from CMDER_USER_CONFIG
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
fi
|
||||
fi
|
||||
@@ -120,5 +126,6 @@ fi
|
||||
|
||||
# Source the users .bashrc file if it exists
|
||||
if [ -f "${HOME}/.bashrc" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${HOME}/.bashrc"
|
||||
fi
|
||||
|
||||
7
vendor/cmder_exinit
vendored
7
vendor/cmder_exinit
vendored
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copy this file to your non integrated *nix-like environment,
|
||||
# Cygwin/MSys2/Git for Windows SDK, installs '/etc/profile.d/'
|
||||
# folder to integrate the externally installed Unix like environment
|
||||
@@ -29,14 +30,17 @@ run_profile_d() {
|
||||
pushd "${1}" >/dev/null || return
|
||||
|
||||
if [ -n "${ZSH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.zsh 2>/dev/null)
|
||||
elif [ -n "${BASH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.sh 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ -n "${profile_d_scripts}" ]; then
|
||||
for script in ${profile_d_scripts}; do
|
||||
echo "Sourcing ${1}/${script}..."
|
||||
# shellcheck disable=SC1090
|
||||
. "${1}/${script}"
|
||||
done
|
||||
fi
|
||||
@@ -48,6 +52,7 @@ run_profile_d() {
|
||||
|
||||
# Detect and set CMDER_ROOT for bash admin sessions
|
||||
# Converts Windows paths to Unix paths if needed
|
||||
# ConEmuDir is set by ConEmu/Cmder environment
|
||||
if [ -z "$CMDER_ROOT" ] && [ -n "$ConEmuDir" ]; then
|
||||
if [ -d "${ConEmuDir}../../vendor" ]; then
|
||||
case "$ConEmuDir" in
|
||||
@@ -97,6 +102,7 @@ if [ -n "$CMDER_ROOT" ]; then
|
||||
|
||||
# Source user profile from CMDER_ROOT config
|
||||
if [ -f "${CMDER_ROOT}/config/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${CMDER_ROOT}/config/user_profile.sh"
|
||||
fi
|
||||
|
||||
@@ -111,6 +117,7 @@ if [ -n "$CMDER_ROOT" ]; then
|
||||
|
||||
# Source user profile from CMDER_USER_CONFIG
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user