Envy - add command for editing profile
This commit is contained in:
parent
4dcce7405b
commit
f797c489dd
@ -6,23 +6,31 @@ function _envy_start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _envy_load() {
|
function _envy_load() {
|
||||||
local new_env_path="${ENVY_CONFIG_DIR}/${1}"
|
local new_profile_path="${ENVY_CONFIG_DIR}/${1}"
|
||||||
|
|
||||||
if [[ ! -f ${new_env_path} ]]; then
|
if [[ ! -f ${new_profile_path} ]]; then
|
||||||
echo "Cannot find envy file '${new_env_path}'"
|
echo "Cannot find envy file '${new_profile_path}'"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source ${new_env_path}
|
source ${new_profile_path}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _envy_create() {
|
function _envy_create() {
|
||||||
local new_env_path="${ENVY_CONFIG_DIR}/${1}"
|
local new_profile_path="${ENVY_CONFIG_DIR}/${1}"
|
||||||
|
|
||||||
[[ -z "${1}" ]] && echo "No profile name argument" && return 1
|
[[ -z "${1}" ]] && echo "No profile name argument" && return 1
|
||||||
[[ ! -d "${ENVY_CONFIG_DIR}" ]] && mkdir -p ${ENVY_CONFIG_DIR}
|
[[ ! -d "${ENVY_CONFIG_DIR}" ]] && mkdir -p ${ENVY_CONFIG_DIR}
|
||||||
echo "#!/bin/bash" > ${new_env_path}
|
echo "#!/bin/bash" > ${new_profile_path}
|
||||||
echo "Created empty profile: ${new_env_path}"
|
echo "Created empty profile: ${new_profile_path}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _envy_edit() {
|
||||||
|
local profile_path="${ENVY_CONFIG_DIR}/${1}"
|
||||||
|
|
||||||
|
[[ -z "${1}" ]] && echo "No profile name argument" && return 1
|
||||||
|
[[ ! -f "${profile_path}" ]] && echo "Profile does not exists" && return 1
|
||||||
|
${EDITOR} ${profile_path}
|
||||||
}
|
}
|
||||||
|
|
||||||
function envy() {
|
function envy() {
|
||||||
@ -31,6 +39,10 @@ function envy() {
|
|||||||
_envy_create ${2}
|
_envy_create ${2}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
edit)
|
||||||
|
_envy_edit ${2}
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
_envy_load ${1}
|
_envy_load ${1}
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user