Skip to content

Instantly share code, notes, and snippets.

@mike-bourgeous
Created August 16, 2016 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-bourgeous/66e62f91b49debf4f2cb065ab29b3859 to your computer and use it in GitHub Desktop.
Save mike-bourgeous/66e62f91b49debf4f2cb065ab29b3859 to your computer and use it in GitHub Desktop.
Scripts to improve launching Oracle's sqlplus client (put these in ~/bin, call orasql)
#!/bin/sh
# Launches an application with the Oracle instant client environment set.
# Created by Mike Bourgeous, DeseretBook.com
export CLIENT_PATH=/usr/lib/oracle/11.2/client64/lib
export PATH="$PATH:$CLIENT_PATH"
export LD_LIBRARY_PATH="$CLIENT_PATH"
export SQLPATH="$HOME/.oracle:$CLIENT_PATH"
export TNS_ADMIN="$HOME/.oracle"
export NLS_LANG="american_america.utf8"
"$@"
#!/bin/sh
# Script to generate a simple login.sql for sqlplus based on window size.
# Created August 2014 by Mike Bourgeous, DeseretBook.com
mkdir -p $HOME/.oracle
cat > $HOME/.oracle/login.sql <<SQL
-- This file was automatically generated by $0. Modifications will be lost.
set serveroutput on size unlimited
set editfile $HOME/.oracle/afiedt.sql
set pagesize $(tput lines)
set linesize $(tput cols)
set sqlprompt '$(printf "\033[35m&_user\033[0m@\033[36m&_connect_identifier\033[0m> ")'
set timing on
define _editor=vim
SQL
#!/bin/sh
# Oracle sqlplus launch script (requires rlwrap -- sudo apt install rlwrap)
# Created by Mike Bourgeous, DeseretBook.com
# Regenerate login.sql based on current window size
oralogin
if [ "$RLWRAP" = "0" ]; then
oralaunch sqlplus64 "$@"
else
oralaunch rlwrap -A sqlplus64 "$@"
fi
@mike-bourgeous
Copy link
Author

Launch with orasql user@DATABASE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment