Skip to content
Snippets Groups Projects

Shell functions used every day.

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Reviewer Intergaláctico

    Funciones que utilizo repetidas veces, transformadas para facilitar el uso. Realizadas para ZShell, no fueron probadas en Bash.

    Edited
    Aliases.zsh 721 B
    function fields() {
    	if [[ $1 == '' ]] || [[ $2 == '' ]];then
    		echo "\nUsage: fields database model\n"
    	else
    		psql -d $1 -c "SELECT name,ttype,relation,
    		CASE WHEN required = 't' THEN 'True' ELSE 'False' END AS Required
    	        FROM ir_model_fields WHERE model='$2' ORDER BY name;"
    	fi
    }
    
    function search() {
    	if [[ $1 == '' ]] || [[ $2 == '' ]];then
    		echo "\nUsage: search string file_extension\n"
    	else
    		grep -iRn $1 --include="*.$2"
    	fi
    }
    
    function arch() {
    	if [[ $1 == '' ]];then
    		echo "\nUsage: arch database string\n"
    	else
    		psql -d $1 -c "SELECT iuv.id,iuv.name,iuv.model,iuv.inherit_id,imd.module
    		FROM ir_ui_view iuv JOIN ir_model_data imd ON imd.id = iuv.model_data_id
    		WHERE arch ~* '.*$2.*';"
    	fi
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment