Skip to content

Instantly share code, notes, and snippets.

@jonasruth
Forked from eliotsykes/git-aware-bash-prompt.md
Created December 23, 2020 05:55
Show Gist options
  • Save jonasruth/d1a981a0a4fbf74d17a56180287efb14 to your computer and use it in GitHub Desktop.
Save jonasruth/d1a981a0a4fbf74d17a56180287efb14 to your computer and use it in GitHub Desktop.
Git Aware Bash Prompt

In Terminal

mkdir ~/.bash

Copy the raw git-prompt.sh file from git contrib in to the ~/.bash directory: https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh

Inside ~/.bashrc or ~/.bash_profile (choose the file where you normally put any bash customizations/setup), add the lines:

source ~/.bash/git-prompt.sh # Show git branch name at command prompt
export GIT_PS1_SHOWCOLORHINTS=true # Option for git-prompt.sh to show branch name in color

# Terminal Prompt:
# Include git branch, use PROMPT_COMMAND (not PS1) to get color output (see git-prompt.sh for more)
export PROMPT_COMMAND='__git_ps1 "\w" "\n\\\$ "' # Git branch (relies on git-prompt.sh)

As long as you're inside a git repo, your Bash prompt should now show the current git branch in color signifying if its got uncommitted changes.

@abdu-dotcom
Copy link

private void tablePenyewa(){

          try {
              
        Connection konekdulu = konek.getConnection();
        
        String dataPenyewa =  "SELECT tb_transaksi.id_transaksi, tb_transaksi.namaPenyewa, tb_transaksi.Notelp, tb_transaksi.tgl_Peminjaman, tb_transaksi.tgl_Pengembalian, tb_transaksi.Lama_Peminjaman, tb_transaksi.total "
                + ", tb_mobil.Harga_Sewa, tb_mobil.No_polisi FROM tb_transaksi, tb_mobil";
        Statement ps = konekdulu.createStatement();
        ResultSet rs = ps.executeQuery(dataPenyewa);
        while(rs.next()) {
            int id = rs.getInt("id_transaksi");
            String namaP = rs.getString("namaPenyewa");
            String noTelp = rs.getString("Notelp");
            String noPlat = rs.getString("No_Polisi");
            String hargaH = rs.getString("Harga_Sewa");
            String tgPemin = rs.getString("tgl_peminjaman");
            String tglPenge = rs.getString("tgl_Pengembalian");
            String lamaP = rs.getString("Lama_Peminjaman");
            int total = rs.getInt("total");
            
            tablePenyewa tp = new tablePenyewa(id,total, namaP, noTelp, noPlat, hargaH, lamaP, tglPenge, tgPemin);
            tbPenyewa.add(tp);
            
            model.addRow(new Object[] {
            tbPenyewa.get(tbPenyewa.size() - 1).getId_transaksi(),
            tbPenyewa.get(tbPenyewa.size() - 1).getNama(),
            tbPenyewa.get(tbPenyewa.size() - 1).getNoTelp(),
            tbPenyewa.get(tbPenyewa.size() - 1).getNoPolish(),

            tbPenyewa.get(tbPenyewa.size() - 1).getWaktuPeminjaman(),
            tbPenyewa.get(tbPenyewa.size() - 1).getWaktuPengembalian(),
            tbPenyewa.get(tbPenyewa.size() - 1).getHargaSewa(),
            tbPenyewa.get(tbPenyewa.size() - 1).getLamaWaktu(),
            tbPenyewa.get(tbPenyewa.size() - 1).getTotal(),
            });
            
        }
    } catch (Exception e) {
          JOptionPane.showMessageDialog(this, e.getMessage());

}

}

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