diff --git a/dotconf.sh b/dotconf.sh index 4144c52..ebaf5b6 100644 --- a/dotconf.sh +++ b/dotconf.sh @@ -7,18 +7,19 @@ function dotconf () { ln -s $DOTCONFDIR/tmux/tmux.conf ~/.tmux.conf ln -s $DOTCONFDIR/vim/vimrc ~/.vimrc - # setup spacemacs - if [ -d ~/.emacs.d ]; then - echo "Backing up .emacs.d ..." - mv ~/.emacs.d ~/.emacs.d.bak - fi - git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d + # setup spacemacs + if [ -d ~/.emacs.d ]; then + echo "Backing up .emacs.d ..." + mv ~/.emacs.d ~/.emacs.d.bak + fi + git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d ln -s $DOTCONFDIR/emacs/spacemacs ~/.spacemacs ;; "update") - OLDDIR="$(PWD)" + OLDDIR="$(pwd)" cd "$DOTCONFDIR" && git pull origin + source dotconf.sh cd "$OLDDIR" ;; diff --git a/emacs/spacemacs b/emacs/spacemacs index 56fc7cb..ed9655f 100644 --- a/emacs/spacemacs +++ b/emacs/spacemacs @@ -31,18 +31,21 @@ values." ;; List of configuration layers to load. dotspacemacs-configuration-layers '( + yaml + markdown + swift python + git ;; ---------------------------------------------------------------- ;; Example of useful layers you may want to use right away. ;; Uncomment some layer names and press (Vim style) or ;; (Emacs style) to install them. ;; ---------------------------------------------------------------- helm - ;; auto-completion + auto-completion + docker ;; better-defaults emacs-lisp - ;; git - ;; markdown org ;; (shell :variables ;; shell-default-height 30 @@ -315,7 +318,8 @@ package is loaded, you should place your code here." (global-set-key "\C-cc" 'org-capture) (global-set-key "\C-cb" 'org-iswitchb) (custom-set-variables - '(org-agenda-files (quote ("~/Documents/docs-private/orgmode/org-mode.org"))) + '(org-agenda-files (list "~/Documents/docs-private/orgmode/org-mode.org" + "~/Documents/docs-sm/organisation/projects.om"))) '(org-enable-priority-commands t) '(org-highest-priority ?A) '(org-lowest-priority ?Z) @@ -323,10 +327,11 @@ package is loaded, you should place your code here." ) (setq org-agenda-log-mode-items '(closed)) (setq org-agenda-custom-commands - '(("b" "Purchases list" tags "BUY")) + '(("b" "Purchases List" tags-todo "BUY") + ("B" "Big Spendings List" tags-todo "+BIGSPENDS") + ("h" "Home Todo List" tags "HOME")) ) ) - ) (defun my-cal-exp () "test" @@ -335,6 +340,13 @@ package is loaded, you should place your code here." (org-agenda-write "test1.ics") ) +(defun browse-url-default-macosx-browser (url &optional new-window) + (interactive (browse-url-interactive-arg "URL: ")) + (if (and new-window (>= emacs-major-version 23)) + (ns-do-applescript + (format "tell application \"Safari\" to open location \"%s\"\n" url)) + (start-process (concat "open " url) nil "open" url))) + ;; Do not write anything past this comment. This is where Emacs will ;; auto-generate custom variable definitions. (custom-set-variables @@ -342,9 +354,15 @@ package is loaded, you should place your code here." ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. + '(org-agenda-files + (list "~/Documents/docs-private/orgmode/org-mode.org" "~/Documents/docs-sm/organisation/projects.om")) + '(org-default-priority 85) + '(org-enable-priority-commands t) + '(org-highest-priority 65) + '(org-lowest-priority 90) '(package-selected-packages (quote - (org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-mime org-download htmlize gnuplot yapfify pyvenv pytest pyenv-mode py-isort pip-requirements live-py-mode hy-mode dash-functional helm-pydoc cython-mode anaconda-mode pythonic ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers parent-mode highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make projectile pkg-info epl helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido flx fill-column-indicator fancy-battery eyebrowse expand-region evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state smartparens evil-indent-plus evil-iedit-state iedit evil-exchange evil-escape evil-ediff evil-args evil-anzu anzu evil goto-chg undo-tree eval-sexp-fu highlight elisp-slime-nav dumb-jump f dash s diminish define-word column-enforce-mode clean-aindent-mode bind-map bind-key auto-highlight-symbol auto-compile packed aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line helm avy helm-core popup async)))) + (dockerfile-mode docker json-mode tablist docker-tramp json-snatcher json-reformat helm-company helm-c-yasnippet fuzzy company-statistics company-anaconda company auto-yasnippet yasnippet ac-ispell auto-complete smeargle orgit magit-gitflow helm-gitignore gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link evil-magit realgud magit yaml-mode pandoc pandoc-mode mmm-mode markdown-toc markdown-mode gh-md swift3-mode swift-mode org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-mime org-download htmlize gnuplot yapfify pyvenv pytest pyenv-mode py-isort pip-requirements live-py-mode hy-mode dash-functional helm-pydoc cython-mode anaconda-mode pythonic ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers parent-mode highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make projectile pkg-info epl helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido flx fill-column-indicator fancy-battery eyebrowse expand-region evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state smartparens evil-indent-plus evil-iedit-state iedit evil-exchange evil-escape evil-ediff evil-args evil-anzu anzu evil goto-chg undo-tree eval-sexp-fu highlight elisp-slime-nav dumb-jump f dash s diminish define-word column-enforce-mode clean-aindent-mode bind-map bind-key auto-highlight-symbol auto-compile packed aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line helm avy helm-core popup async)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/tmux/tmux.conf b/tmux/tmux.conf index e59590d..f9be927 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,3 +1,5 @@ set-option -g prefix C-t set-option -g allow-rename off set-window-option -g allow-rename off +bind-key h swap-window -t -1 +bind-key l swap-window -t +1 diff --git a/zsh/zshrc b/zsh/zshrc index 2f4b656..0891179 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -15,7 +15,7 @@ fi ### Configure oh-my-zsh -ZSH_THEME="pygmalion" +# ZSH_THEME="pygmalion" plugins=( git @@ -30,6 +30,83 @@ source $ZSH/oh-my-zsh.sh ### Configure zsh +# Configure prompt + +prompt_segment() { + [[ -n $1 ]] && color=$1 || return + [[ -n $2 ]] && text='%{$fg['$color']%}'$2'%{$reset_color%}' || return + [[ -n $3 ]] && sep='%{$fg[red]%}'$3'%{$reset_color%}' || sep='' + echo -n $sep$text +} + +prompt_git() { + (( $+commands[git] )) || return + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}" + ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" + ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}" + ZSH_THEME_GIT_PROMPT_CLEAN="" + echo -n "git:$(git_prompt_info)" + fi +} + +prompt_virtualenv() { + local virtualenv_path="$VIRTUAL_ENV" + if [[ -n $virtualenv_path ]]; then + text="penv:`basename $virtualenv_path`" + echo -n $text + fi +} + +prompt_condaenv() { + local env_path="$CONDA_PREFIX" + if [[ -n $env_path ]]; then + text="cenv:`basename $env_path`" + echo -n $text + fi +} + +prompt_extensions=(prompt_virtualenv prompt_condaenv prompt_git) + +build_prompt() { + # build base prompt + PROMPT=$(prompt_segment magenta '%n') + PROMPT+=$(prompt_segment red '@') + PROMPT+=$(prompt_segment yellow '%m') + PROMPT+=$(prompt_segment red ':') + PROMPT+=$(prompt_segment cyan '%0~') + + # build prompt for extensions + local prompt_ext_text="" + local sep="" + for ext in $prompt_extensions; do + local ext_text=$(eval $ext) + if [[ -n $prompt_ext_text ]] && [[ -n $ext_text ]]; then + sep="," + else + sep="" + fi + prompt_ext_text+=$(prompt_segment green $ext_text $sep) + done + + # build prompt base - extension separator + if [[ -n $prompt_ext_text ]]; then + PROMPT+=$(prompt_segment red '|') + fi + PROMPT+=$prompt_ext_text + + # build prompt suffix + local prompt_nocolor=$(echo $PROMPT | perl -pe "s/%\{[^}]+\}//g") + local prompt_length=${#prompt_nocolor} + if [[ $prompt_length -gt 40 ]]; then + PROMPT+=$(prompt_segment cyan '\n%{\r%}⇒ ') + else + PROMPT+=$(prompt_segment cyan ' ⇒ ') + fi +} + +precmd_functions+=(build_prompt) + HISTSIZE=20000 HISTFILE=~/.zsh_history SAVEHIST=$HISTSIZE @@ -40,21 +117,85 @@ SAVEHIST=$HISTSIZE export LC_ALL='en_US.UTF-8' export WORKON_HOME=~/.virtualenvs -alias em='emacs -nw' +if [[ $(uname) = "Darwin" ]]; then + PATH=$PATH:~/Library/Anaconda/bin +fi source $DOTCONFDIR/dotconf.sh +### Shell function definition -# System specific config -SYS=`uname` -if [[ $SYS = "Linux" ]]; then +function sortimages () { + case $1 in + -d) + shift + for file in $@; do + DST=`identify -format "%[Exif:DateTimeOriginal]" $file | head -1 | awk '{print $1":"$2}' | awk -F':' '{print $1$2$3"-"$4$5$6}' | awk -F'.' '{print $1 }' | awk -F'::' '{print $1}'` + DST=`echo $DST.jpg` + echo mv $file $DST; + mv $file $DST; + chmod 640 $DST; + done + ;; + *) + echo "Rename files" + echo "Usage: sortimages " + echo " : for example *.JPG" + echo " : rename to "'$date'"-'$time'-suffix.jpg" + echo " : -d rename the files" + echo -n + for file in $@; do + DST=`identify -format "%[Exif:DateTimeOriginal]" ${file} | head -1 | awk '{print $1":"$2}' | awk -F':' '{print $1$2$3"-"$4$5$6}' | awk -F'.' '{print $1 }' | awk -F'::' '{print $1}'` + DST=${DST}'.jpg' + echo mv ${file} ${DST}; + done + ;; +esac +} + + +read -r -d '' REMOTE_CMD << EOF +if [ \$(command -v module 2> /dev/null | wc -l) -gt 0 ]; then + module load tmux +fi + +if [ \$(lsof -U 2> /dev/null | grep ^tmux | wc -l) -gt 0 ]; then + tmux a +else + tmux +fi +EOF + +function st () { + ssh -t $@ ${REMOTE_CMD} +} + +compdef st=ssh + + +### Alias configuration + +if [[ $(uname) = "Linux" ]]; then + alias em='emacs -nw' + alias ec='emacsclient -c' alias grep='grep --color' alias ls='ls --color' - alias open='xdg-open' alias l='ls -lh --color' - alias ec='emacsclient -c' + alias open='xdg-open' fi -if [[ $SYS = "Darwin" ]]; then +if [[ $(uname) = "Darwin" ]]; then PATH=$PATH:~/Library/Anaconda/bin + alias emacs='/usr/local/opt/emacs/bin/emacs' + alias em='emacs -nw' + alias ec='/usr/local/opt/emacs/bin/emacsclient -c' + alias grep='grep --color=always' + alias l='ls -lh' +fi + + +### Conda setup on MacOS + +if [[ $(uname) = "Darwin" ]]; then + source /Users/mschoengens/Library/Anaconda/etc/profile.d/conda.sh fi