dotfiles script v0.4.5
- add command 'edit' to open a file in vim
This commit is contained in:
parent
81687f5418
commit
a0c75c28b6
12
bin/dotfiles
12
bin/dotfiles
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
##
|
##
|
||||||
## binaryDiv's dotfiles management script
|
## binaryDiv's dotfiles management script
|
||||||
## Version 0.4.4
|
## Version 0.4.5
|
||||||
##
|
##
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
|
@ -19,6 +19,7 @@ usage() {
|
||||||
|
|
||||||
Dotfile management:
|
Dotfile management:
|
||||||
ls [DIR] list contents of .dotfiles directory (or DIR relative to it)
|
ls [DIR] list contents of .dotfiles directory (or DIR relative to it)
|
||||||
|
edit FILE open ~/.dotfiles/FILE in vim
|
||||||
diff FILE use vimdiff to compare ~/FILE to ~/.dotfiles/FILE
|
diff FILE use vimdiff to compare ~/FILE to ~/.dotfiles/FILE
|
||||||
link FILE... create a symlink from ~/FILE to ~/.dotfiles/FILE (multiple files possible)
|
link FILE... create a symlink from ~/FILE to ~/.dotfiles/FILE (multiple files possible)
|
||||||
(-q: be quiet, only print something if an error occurs)
|
(-q: be quiet, only print something if an error occurs)
|
||||||
|
|
@ -165,6 +166,11 @@ case "$cmd" in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
edit)
|
||||||
|
[[ -n $1 ]] || { echo "$(basename $0) $cmd: Missing argument."; exit 1; }
|
||||||
|
vim "$dotfilesdir/$1"
|
||||||
|
;;
|
||||||
|
|
||||||
diff)
|
diff)
|
||||||
[[ -n $1 ]] || { echo "$(basename $0) $cmd: Missing argument."; exit 1; }
|
[[ -n $1 ]] || { echo "$(basename $0) $cmd: Missing argument."; exit 1; }
|
||||||
file_A="$homedir/$1"
|
file_A="$homedir/$1"
|
||||||
|
|
@ -268,14 +274,14 @@ case "$cmd" in
|
||||||
_dotfiles() {
|
_dotfiles() {
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
local commands="help install ls diff link linkstatus createfrom git pull"
|
local commands="help install ls edit diff link linkstatus createfrom git pull"
|
||||||
local gitcommands="add commit diff fetch log pull push rebase status"
|
local gitcommands="add commit diff fetch log pull push rebase status"
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||||
COMPREPLY=($(compgen -W "$commands" -- $cur))
|
COMPREPLY=($(compgen -W "$commands" -- $cur))
|
||||||
else
|
else
|
||||||
case "${COMP_WORDS[1]}" in
|
case "${COMP_WORDS[1]}" in
|
||||||
ls|diff)
|
ls|edit|diff)
|
||||||
[[ $COMP_CWORD -eq 2 ]] && _dotfiles_filenames
|
[[ $COMP_CWORD -eq 2 ]] && _dotfiles_filenames
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue