Skip to content

Instantly share code, notes, and snippets.

@sagarvora
Created January 12, 2023 12:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagarvora/e4f283ef965e606ef8092771381f5693 to your computer and use it in GitHub Desktop.
Save sagarvora/e4f283ef965e606ef8092771381f5693 to your computer and use it in GitHub Desktop.
Bash aliases for Frappe development
# Python is Python 3
alias python=python3
alias pip=pip3
# Activate a virtual environment if it is named .venv or env
alias venv='source .venv/bin/activate || source env/bin/activate'
# all benches reside here
export BENCHES_PATH="$HOME/Work"
# current bench file path
export CURRENT_BENCH_FILEPATH="$BENCHES_PATH/.current_bench"
# set current bench to bench name passed as first argument
set_bench () {
export CURRENT_BENCH=$BENCHES_PATH/$1;
cd $CURRENT_BENCH;
echo $CURRENT_BENCH > "$BENCHES_PATH/.current_bench";
}
# Load current bench if found
if [ -f "$CURRENT_BENCH_FILEPATH" ]; then
export CURRENT_BENCH=$(< $CURRENT_BENCH_FILEPATH)
fi
# shortcuts to set current bench and switch to that directory
dev () {
set_bench "dev";
}
v13 () {
set_bench "13";
}
v14 () {
set_bench "14";
}
# shortcut for bench use sitename.localhost (sitename being first argument)
bu () {
bench use "$1.localhost"
}
# start bench and open the current site in the browser (logged in as Administrator if supported)
# WARN: bench name patterns are hardcoded!!!
function bs () {
if [[ $CURRENT_BENCH == */dev ]] || [[ $CURRENT_BENCH == */postgres-dev ]] || [[ $CURRENT_BENCH == */14 ]]
then
gnome-terminal -q --window -- bash -c "cd $CURRENT_BENCH && bench browse --user Administrator && bench start"
else
gnome-terminal -q --window -- bash -c "cd $CURRENT_BENCH && bench browse && bench start"
fi
}
# run bench start in foreground from current dir
alias bs.='bench start'
# open console of current bench, current site
alias bc='(cd $CURRENT_BENCH; bench console)'
# open mariadb of current bench, current site
alias bm='(cd $CURRENT_BENCH; bench mariadb)'
# clear cache of currrent bench, current site
alias bcc='(cd $CURRENT_BENCH; bench clear-cache)'
# get name of current site
alias cs='(cd $CURRENT_BENCH; cat sites/currentsite.txt)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment