adding archive command + XDG_* environnment variables (not finished)
In its essence, the archive command does this : archive /tmp/TEST.png mv /tmp/2013-10-20--TEST.png I follow here the principle from gmail that you should 98% of the time, archiving is better of deleting. XDG Base Directory Specification http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html Please review this patch, I'm not a real bash programmer.pull/232/head
parent
8c03cc4297
commit
0fd2277762
|
|
@ -25,7 +25,6 @@ alias c='clear'
|
|||
alias k='clear'
|
||||
alias cls='clear'
|
||||
|
||||
alias edit="$EDITOR"
|
||||
alias pager="$PAGER"
|
||||
|
||||
alias q='exit'
|
||||
|
|
|
|||
|
|
@ -353,3 +353,48 @@ all_groups ()
|
|||
cat $file | sort | uniq
|
||||
rm $file
|
||||
}
|
||||
edit () {
|
||||
FILES=$1
|
||||
if [ -z "$FILES" ]
|
||||
then
|
||||
$EDITOR $HOME/.bash-it/custom/FILES
|
||||
else
|
||||
$EDITOR $FILES
|
||||
fi
|
||||
}
|
||||
|
||||
archive () {
|
||||
FILE=$1
|
||||
BASEFILE=$(basename "$FILE")
|
||||
TODAY=$(date --rfc-3339=date)
|
||||
TARGET="$TODAY--$BASEFILE"
|
||||
|
||||
if [ -z "$FILE" ]
|
||||
then
|
||||
echo "move a file in the '$ARCHIVE' directory, timestamping it with $TODAY"
|
||||
echo "Syntaxe : archive <file>"
|
||||
return 1
|
||||
fi
|
||||
if [ -d "$FILE" ]
|
||||
then
|
||||
echo "sorry, archive doesn't work for directories"
|
||||
return 2
|
||||
fi
|
||||
if [ ! -r "$FILE" ]
|
||||
then
|
||||
echo "Cannot read file '$FILE'"
|
||||
return 3
|
||||
fi
|
||||
if [ -z "$ARCHIVE" ]
|
||||
then
|
||||
ARCHIVE=$HOME/archive
|
||||
fi
|
||||
if [ ! -r "$ARCHIVE" ]
|
||||
then
|
||||
mkdir -p "$ARCHIVE"
|
||||
fi
|
||||
|
||||
echo "Archiving '$FILE' in '$ARCHIVE'"
|
||||
/bin/mv -- "$FILE" "$ARCHIVE"/"$TARGET"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Set where your want to archive your files with the archive command
|
||||
export ARCHIVE=$HOME/archive # default
|
||||
|
||||
# Set the XDG_* environnment variable
|
||||
# See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
export XDG_DATA_HOME=$HOME/.local/share
|
||||
export XDG_CONFIG_HOME=$HOME/.config
|
||||
export XDG_CONFIG_DIRS=/etc/xdg
|
||||
export XDG_CACHE_HOME=$HOME/.cache
|
||||
# export XDG_RUNTIME_DIR=we won t set this for you, read the spec
|
||||
# export XDG_DATA_DIRS=we won t set this for you, read the spec
|
||||
# TODO : those directories should be created if they don't exist
|
||||
|
||||
|
||||
# Load RVM, if you are using it
|
||||
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
|
||||
|
||||
|
|
@ -39,5 +53,6 @@ export TODO="t"
|
|||
# https://github.com/xvzf/vcprompt
|
||||
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt
|
||||
|
||||
|
||||
# Load Bash It
|
||||
source $BASH_IT/bash_it.sh
|
||||
|
|
|
|||
Loading…
Reference in New Issue