summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasios Grammenos <anastasios.grammenos@noris.gr>2021-08-20 14:01:56 +0300
committerAnastasios Grammenos <anastasios.grammenos@noris.gr>2021-08-20 14:01:56 +0300
commitc642675ba86d841d881215e8e5e28013103bd0ff (patch)
tree12c382acd8ca593640d4afb4b9ef8847dc4df742
parent7288da0ba23bd7e9ca15d39446c4bf6c095b1e54 (diff)
downloadconf-c642675ba86d841d881215e8e5e28013103bd0ff.tar.gz
conf-c642675ba86d841d881215e8e5e28013103bd0ff.tar.bz2
conf-c642675ba86d841d881215e8e5e28013103bd0ff.zip
Add graphical editor
-rwxr-xr-xconf23
-rw-r--r--conf_completion7
2 files changed, 23 insertions, 7 deletions
diff --git a/conf b/conf
index 522217b..c7b8454 100755
--- a/conf
+++ b/conf
@@ -21,17 +21,24 @@ set -e
CONF_VERSION="0.1.0"
+CONF_HOME="${CONF_HOME:-$HOME/.conf}"
+
#################
# CONFIGURATION #
#################
-CONF_HOME="${CONF_HOME:-$HOME/.conf}"
+## Name of the default group
DEF_GROUP="default"
+
+## Substitution for $HOME so username is not relevant
HOME_SUB="/home"
## Indentation for tree listing
CONF_TREE_INDENT="|- "
+## Graphical editor
+GEDITOR="emacsclient -a"" -c"
+
########
# VARS #
########
@@ -65,7 +72,7 @@ function add {
while [ $# -gt 0 ]; do
case ${1} in
- -g) #a add next file to specified group
+ -g) #a add next file(s) to specified group
GROUP="${2}"
shift
shift
@@ -128,7 +135,7 @@ function list {
return 0
;;
g) #l list paths in <group>
- [ ! -d "${CONF_HOME}/${OPTARG}" ] && err "group ${OPTARG} doesn't exist"
+ ([ ! -d "${CONF_HOME}/${OPTARG}" ] || [ "${OPTARG}" == "" ]) && err "group ${OPTARG} doesn't exist"
find "${CONF_HOME}/${OPTARG}" -type f | sed -e "s#${CONF_HOME}/${OPTARG}${HOME_SUB}#${HOME}#"
return 0
;;
@@ -199,10 +206,12 @@ function relink {
SELECTED_GROUPS=()
for arg in "$@"; do
- if [ "$arg" == "-t" ]; then
+ if [ "$arg" == "-t" ] || [ "$arg" == "--test" ]; then
MODE="test"
elif [ "$arg" == "-h" ]; then
- echo relink help
+ cat <<EOF
+relink [group ...] [-t|--test]
+EOF
return 0
else
if [[ " ${CONF_GROUPS[@]} " =~ " ${arg} " ]]; then
@@ -272,6 +281,10 @@ case ${1} in
shift
edit "$@"
;;
+ editg | eg) ## edit managed files graphically
+ shift
+ EDITOR="$GEDITOR" edit "$@"
+ ;;
relink) ## relink managed files
shift
relink "$@"
diff --git a/conf_completion b/conf_completion
index ebeb482..a8d5d3b 100644
--- a/conf_completion
+++ b/conf_completion
@@ -4,7 +4,7 @@ _conf()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
- local commands="add ls list search edit relink grep help"
+ local commands="add ls list search edit relink grep help version"
if [[ $COMP_CWORD -gt 1 ]]; then
local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
case "${COMP_WORDS[1]}" in
@@ -22,13 +22,16 @@ _conf()
COMPREPLY=($(compgen -f -- ${cur}))
fi
;;
- edit|e)
+ edit|e|editg|eg)
COMPREPLY=($(compgen -W "$(conf ls -G) \
$(conf ls -l | xargs -If basename f) \
$(for g in $(conf ls -G); do \
conf ls -g $g | xargs -If basename f | sed -e "s#^#${g}/#"; \
done)" -- ${cur}))
;;
+ relink)
+ COMPREPLY=($(compgen -W "-t --test $(conf ls -G)" -- ${cur}))
+ ;;
esac
else
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))