Skip to content

Commit

Permalink
new script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed May 18, 2017
1 parent 0f2693e commit c7e83ac
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
30 changes: 27 additions & 3 deletions bashrc
Expand Up @@ -79,7 +79,7 @@ if [ -x /usr/bin/dircolors ]; then
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

#alias grep='grep --color=auto'
alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
Expand Down Expand Up @@ -132,12 +132,36 @@ export PATH=./composer/bin:$PATH

eval "$(hub alias -s)"

up(){ DEEP=$1; [ -z "${DEEP}" ] && { DEEP=1; }; for i in $(seq 1 ${DEEP}); do cd ../; done; }

function mkcd(){ mkdir -p $@ && cd $_; }

function vvv-debug(){ multitail -cS php -m 500 /var/www/VVV/www/$1/htdocs/wp-content/debug.log; }
function vvv-debug(){
log="/var/www/VVV/www/$1/htdocs/wp-content/debug.log"
if [ -f $log ]; then
actualsize=$(du -k $log | cut -f 1)
if [ $actualsize -ge 300 ]; then
rm $log;
fi
else
echo "" > $log
fi
multitail -cS php -m 600 /var/www/VVV/www/$1/htdocs/wp-content/debug.log;
}

function git-merge-last-commit() { git reset --soft HEAD~$1 && git commit; }

function commit() { commit=$(kdialog --title 'Commit message' --inputbox 'Insert the commit' '') && git commit -m "$commit"; }
function commit() { commit=$(kdialog --title 'Commit message' --inputbox 'Insert the commit' '') && git commit -m "$commit" && echo "$commit"; }

. ~/.bash_powerline

# add this configuration to ~/.bashrc
export HH_CONFIG=hicolor # get more colors
shopt -s histappend # append new history items to .bash_history
export HISTCONTROL=ignorespace # leading space hides commands from history
export HISTFILESIZE=1000 # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" # mem/file sync
# if this is interactive shell, then bind hh to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh -- \C-j"'; fi

59 changes: 59 additions & 0 deletions lokalize/msgfmt-po.py
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
# Lokalize script to compile and export the po files
# Author: Dimitrios Glentadakis <dglent@free.fr>
# https://bugs.kde.org/show_bug.cgi?id=181145
# License: GPLv3
# Edit by Mte90 (16/6/2015) for add new features:
# - Alert for wrong extension
# - Same path of the po/ts file
# - Better check for existing file

import os
import subprocess
import Editor
import Project


def _init():
global lang
global package
global currentFile
global fileType
currentFile = Editor.currentFile()
fileType = currentFile[-2:]
if not Editor.isValid() or currentFile == '':
return
lang = Project.targetLangCode()
(path, pofilename) = os.path.split(Editor.currentFile())
(package, ext) = os.path.splitext(pofilename)
currentFile = Editor.currentFile()
if fileType == 'po':
complilerPresent = cmd_exists('msgfmt')
if complilerPresent:
saveSameFolder()
else:
os.system('kdialog --sorry \
"The command <msgfmt> is not available.\nYou need to install the gettext package"')
return
# Alert for the wrong extension
else:
os.system('kdialog --sorry \
"This format is not supported"')


def cmd_exists(cmd):
return subprocess.call("type " + cmd, shell=True, \
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0


def saveSameFolder():
if fileType == 'po':
ext = '.mo'
compiler = 'msgfmt -o'
binPath = os.path.splitext(currentFile)[0] + ext
if binPath != '':
binPath = binPath.rstrip()
os.system('{0} {1} {2}'.format(compiler, binPath, currentFile))


_init()
8 changes: 8 additions & 0 deletions lokalize/msgfmt-po.rc
@@ -0,0 +1,8 @@
<!DOCTYPE KrossScripting SYSTEM "kpartgui.dtd">
<KrossScripting>
<collection comment="Tools" name="tools" text="Tools">
<script icon="text-x-python" comment="Compiles po" name="msgfmt-po" file="msgfmt-po.py" interpreter="python" text="Compile PO">
<property name="autorun">true</property>
</script>
</collection>
</KrossScripting>
5 changes: 5 additions & 0 deletions lokalize/readme.md
@@ -0,0 +1,5 @@
# Lokalize support to compile PO file

Add in the Tools menu the command to execute the PO of the file, actually the autorun on save of the po file is not working.

Path for this files `/usr/share/lokalize/scripts/`

0 comments on commit c7e83ac

Please sign in to comment.