Various small additions
This commit is contained in:
parent
fe3c0fb5d5
commit
05f6bf7007
|
@ -4,7 +4,7 @@
|
|||
# daily use aliases
|
||||
##############################################################################{{{
|
||||
|
||||
alias ls="ls --color=auto"
|
||||
alias ls="ls -N --color=auto"
|
||||
alias ll="ls -hl --group-directories-first"
|
||||
alias lll="ls -hla"
|
||||
alias ds="du -sh"
|
||||
|
@ -56,6 +56,81 @@ cd(){
|
|||
# filesystem stuff
|
||||
##############################################################################{{{
|
||||
|
||||
t=${TAGSISTANT_ROOT:-$HOME/tagged}/store
|
||||
tagmount() {
|
||||
tagsistant ${TAGSISTANT_ROOT:-$HOME/tagged} &>/tmp/tagsistant.$USER
|
||||
}
|
||||
|
||||
tag() {
|
||||
if [[ -z $2 ]]; then
|
||||
printf "%s\n" \
|
||||
"Usage: tag FILE... [-n name] [-v] [-p] TAG..." \
|
||||
"" \
|
||||
"Each TAG must end with the @ delimiter component." \
|
||||
"Each File must have a name different from a single @"
|
||||
return 1
|
||||
fi
|
||||
local name preview
|
||||
|
||||
zparseopts -D -E n:=name -name:=name p=preview -preview=preview \
|
||||
v=verbose -verbose=verbose
|
||||
|
||||
local sources=()
|
||||
local tags=()
|
||||
|
||||
for i in "${@}"; do
|
||||
if [[ ${i:t} == "@" ]]; then
|
||||
tags+=${i}
|
||||
else
|
||||
sources+=${i:A}
|
||||
fi
|
||||
done
|
||||
|
||||
for source in "${sources[@]}"; do
|
||||
for tag in "${tags[@]}"; do
|
||||
target=~t/$tag
|
||||
if [[ ! -d $target ]]; then mkdir -p $target; fi
|
||||
if [[ -n $verbose ]]; then echo "Tagging $source with $tag"; fi
|
||||
${=preview:+echo} ln -s $source $target/${name[2]}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
papertag() {
|
||||
if [[ -z $2 ]]; then
|
||||
echo "Usage: papertag FILE [-v] [-y YEAR] [AUTHOR...] [:: OTHER TAGS]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local year
|
||||
zparseopts -D -E y:=year -year:=year \
|
||||
v=verbose -verbose=verbose
|
||||
|
||||
local paper=$1; shift
|
||||
|
||||
tag $verbose $paper paper/@
|
||||
if [[ -n "$year" ]]; then
|
||||
tag $verbose $paper meta:/year/eq/${year[2]}/@/
|
||||
fi
|
||||
while [[ -n $1 ]]; do
|
||||
local author=$1; shift
|
||||
if [[ "$author" == "::" ]]; then break; fi
|
||||
tag $verbose $paper meta:/author/eq/$author/@
|
||||
done
|
||||
for tag in "$@"; do
|
||||
tag $verbose $paper $tag
|
||||
done
|
||||
}
|
||||
|
||||
tcd() {
|
||||
rpath=$(realpath ~t/$1)
|
||||
if [[ -d $rpath ]]; then
|
||||
cd $rpath;
|
||||
else
|
||||
cd ${rpath:h}
|
||||
fi
|
||||
}
|
||||
|
||||
# count files in current or given directory
|
||||
count() {
|
||||
find $1 \( ! -path '*/.*' \) | wc -l
|
||||
|
@ -116,7 +191,7 @@ suffix() {
|
|||
|
||||
alias exifcopy="exiftool -tagsFromFile"
|
||||
photobydate() {
|
||||
for i in (#i)*.(JPG|CR2); do
|
||||
for i in ${*:-(#i)*.(JPG|CR2)}; do
|
||||
dir=$(exiftool -p '$DateTimeOriginal' $i | tr ':' '-' | cut -d' ' -f1;)
|
||||
mkdir -p $dir
|
||||
mv ${i:r}.* $dir
|
||||
|
@ -160,6 +235,8 @@ svn() {
|
|||
esac
|
||||
}
|
||||
|
||||
alias gitv='vim "$(git rev-parse --git-dir)/index" -c "Gitv --all" -c tabonly'
|
||||
|
||||
#}}}
|
||||
|
||||
#################################################################################
|
||||
|
|
27
aliases/git
27
aliases/git
|
@ -1,8 +1,8 @@
|
|||
#!/bin/zsh
|
||||
ginit() {
|
||||
git init;
|
||||
git add ${*:-"."};
|
||||
git commit -a -m "Initial Commit"
|
||||
git init;
|
||||
git add ${*:-"."};
|
||||
git commit -a -m "Initial Commit"
|
||||
}
|
||||
|
||||
gst() {
|
||||
|
@ -27,3 +27,24 @@ alias gco="git checkout"
|
|||
alias ga="git add"
|
||||
alias gap="git add --patch"
|
||||
alias gpu="git push"
|
||||
|
||||
|
||||
gls() {
|
||||
zmodload zsh/mapfile
|
||||
gitignore="$(git rev-parse --show-toplevel 2>/dev/null)/.gitignore"
|
||||
globalgitignore="$(git config core.excludesfile)"
|
||||
|
||||
typeset -a ignores
|
||||
for i in $gitignore $globalgitignore; do
|
||||
if [[ -e $i ]]; then
|
||||
for ignore in "${(f)mapfile[$i]}"; do
|
||||
ignores+="--ignore=$ignore"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
ls --color=auto -h $ignores "$@"
|
||||
}
|
||||
|
||||
alias gll="gls -l"
|
||||
alias glll="gls -la"
|
||||
|
|
8
aliases/mpd
Executable file
8
aliases/mpd
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/zsh
|
||||
|
||||
mpc() {
|
||||
eval $(mpd-host get)
|
||||
export MPD_HOST
|
||||
export MPD_PORT
|
||||
command mpc "$@"
|
||||
}
|
3
compdef/_conf
Normal file
3
compdef/_conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
#compdef conf
|
||||
|
||||
_arguments "1:Commands:(${(k)conf_locations})"
|
33
compdef/_tagsistant-helper
Normal file
33
compdef/_tagsistant-helper
Normal file
|
@ -0,0 +1,33 @@
|
|||
#compdef tagsistant-helper tag tcd
|
||||
|
||||
tagdir=${TAGSISTENT_ROOT:-$HOME/tagged}/store
|
||||
|
||||
_file_or_tag() {
|
||||
_alternative \
|
||||
"files:file:_files" \
|
||||
"tags:tag:_files -W $tagdir"
|
||||
}
|
||||
|
||||
_tag() {
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_arguments \
|
||||
"*:argument:_file_or_tag" \
|
||||
"-n[set target name]:target name:" \
|
||||
"--name[set target name]:target name:" \
|
||||
"-p[preview]"
|
||||
}
|
||||
|
||||
_tcd() {
|
||||
_files -W $tagdir
|
||||
}
|
||||
|
||||
_tagsistant-helper() {
|
||||
case $service in
|
||||
tag) _tag;;
|
||||
tcd) _tcd;;
|
||||
papertag) _papertag;;
|
||||
*) _message "Err";;
|
||||
esac
|
||||
}
|
8
compdef/_xd
Normal file
8
compdef/_xd
Normal file
|
@ -0,0 +1,8 @@
|
|||
#compdef xd
|
||||
|
||||
function _xd {
|
||||
typeset -a targets
|
||||
targets=("${(@f)$(xd -l)}")
|
||||
_describe target targets
|
||||
}
|
||||
|
|
@ -59,3 +59,7 @@ function zle-line-finish () {
|
|||
}
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
||||
|
||||
insert_sudo () { zle beginning-of-line; zle -U "sudo " }
|
||||
zle -N insert-sudo insert_sudo
|
||||
bindkey "^[s" insert-sudo
|
||||
|
|
22
modules/conf/init
Executable file
22
modules/conf/init
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/zsh
|
||||
|
||||
conf() {
|
||||
local target=${conf_locations[${1}]}
|
||||
if [[ -d ${target} ]]; then
|
||||
cd ${target}
|
||||
if ! [[ -w ${target} ]]; then
|
||||
su
|
||||
fi
|
||||
elif [[ -f ${target} ]]; then
|
||||
if ! [[ -w ${target} ]]; then
|
||||
sudoedit ${target}
|
||||
else
|
||||
$EDITOR ${target}
|
||||
fi
|
||||
elif [[ -n ${target} ]]; then
|
||||
echo "Conf target for $1 missing: $target"
|
||||
else
|
||||
echo "Unknown conf target: $1"
|
||||
fi
|
||||
|
||||
}
|
3
modules/fuck/init
Normal file
3
modules/fuck/init
Normal file
|
@ -0,0 +1,3 @@
|
|||
if exists thefuck; then
|
||||
eval "$(thefuck --alias)"
|
||||
fi
|
10
modules/localrc/init
Executable file
10
modules/localrc/init
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/zsh
|
||||
|
||||
load_localrc() {
|
||||
local dir=${1:-$PWD}
|
||||
if [[ -f $dir/.lzshrc ]]; then source $dir/.lzshrc
|
||||
elif [[ "$dir" != "/" ]]; then load_localrc ${dir:h}
|
||||
fi
|
||||
}
|
||||
|
||||
chpwd_hook load_localrc
|
14
zshrc
14
zshrc
|
@ -45,4 +45,18 @@ zstyle ':completion:*:messages' format ‘%d’
|
|||
zstyle ':completion:*:warnings' format ‘No matches for: %d’
|
||||
|
||||
|
||||
typeset -A conf_locations
|
||||
conf_locations=(
|
||||
vim $XDG_CONFIG_HOME/vim
|
||||
awesome $XDG_CONFIG_HOME/awesome
|
||||
mutt $HOME/.mutt/muttrc
|
||||
xd $XDG_CONFIG_HOME/xd.conf
|
||||
zsh /etc/zsh
|
||||
offlineimap $XDG_CONFIG_HOME/offlineimap/config
|
||||
compose $HOME/.XCompose.long
|
||||
vdirsyncer $HOME/.vdirsyncer/config
|
||||
xd $XDG_CONFIG_HOME/xd.conf
|
||||
ssh $HOME/.ssh/config
|
||||
)
|
||||
|
||||
exists todo && todo
|
||||
|
|
Loading…
Reference in a new issue