Skip to content

Instantly share code, notes, and snippets.

@negokaz
Last active April 25, 2018 07:00
Show Gist options
  • Save negokaz/65b3b217ebe515ddd72d1f2f1261dcff to your computer and use it in GitHub Desktop.
Save negokaz/65b3b217ebe515ddd72d1f2f1261dcff to your computer and use it in GitHub Desktop.
sudo command for ConEmu
#!/bin/bash
# This is "sudo" command for ConEmu.
# Inspired by csudo.cmd in ConEmu.
# Usage:
# sudo choco upgrade all
# Installation:
# Place in ConEmu's directory.
# ex) C:\Program Files\ConEmu\ConEmu
base_dir="$(cd "$(dirname "$0")"; pwd)"
# Use split screen feature? Possible values: VERT, HORZ, NO
con_emu_split="HORZ"
# Show confirmation before closing SUDO tab
# You may set NO here, if confirmation is not needed
confirm_close="YES"
function main() {
"${base_dir}/$(conemu_exe)" //c "$@" "-new_console:a$(confirm_close_switch)$(con_emu_split_switch)"
}
function conemu_exe() {
if [ "${PROCESSOR_ARCHITECTURE}" == "AMD64" ]
then
echo "ConEmuC64.exe"
else
echo "ConEmuC.exe"
fi
}
function con_emu_split_switch() {
case "${con_emu_split}" in
"VERT") echo "sV" ;;
"HORZ") echo "sH" ;;
*) echo "" ;;
esac
}
function confirm_close_switch() {
if [ "${confirm_close}" == "YES" ]
then
echo "c"
else
echo "n"
fi
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment