Configuring the Starship Prompt for Bash
Starship is a minimal, fast, and highly customizable shell prompt written in Rust. It works the same way across Bash, Zsh, Fish, PowerShell, and more, so you only need to learn one configuration format no matter which shell you end up using. Here’s how to install it and set it up for Bash.
Installing Starship
The quickest way to install Starship on Linux/macOS is via its install script:
curl -sS https://starship.rs/install.sh | shThis drops a single starship binary onto your PATH (e.g. /usr/local/bin/starship). Verify it worked with:
starship --versionEnabling it in Bash
Starship doesn’t do anything until your shell’s init script asks it to render the prompt. Add this line near the end of ~/.bashrc:
eval "$(starship init bash)"Open a new terminal (or run source ~/.bashrc) and you should immediately see the default Starship prompt.
Configuring ~/.config/starship.toml
Starship reads its configuration from ~/.config/starship.toml. Here’s a config that trims the prompt down to what actually matters day-to-day: current directory, git status, a colored success/error indicator, and a right-aligned command duration/clock.
"$schema" = 'https://starship.rs/config-schema.json'
add_newline = true
right_format = """$cmd_duration$time"""
[character]
success_symbol = '[❯](bold green)'
error_symbol = '[❯](bold red)'
[directory]
truncation_length = 3
truncate_to_repo = true
[git_status]
ahead = '⇡${count}'
behind = '⇣${count}'
diverged = '⇕⇡${ahead_count}⇣${behind_count}'
staged = '+${count}'
modified = '!${count}'
untracked = '?${count}'
stashed = '${count}'
[cmd_duration]
min_time = 2000
format = 'took [$duration]($style) '
[time]
disabled = false
format = '[$time]($style)'
time_format = '%H:%M'
style = 'bold dimmed white'A few notes on what each section does:
$schemapoints editors like VS Code at Starship’s JSON schema, giving you autocomplete and validation while editing the file.add_newlineputs a blank line before each prompt, which keeps a busy terminal easier to scan.[character]swaps the default➜for a simple arrow (❯) that turns green on success and red after a failed command — an easy way to spot a bad exit code at a glance.[directory]truncates long paths to the last 3 segments, andtruncate_to_reposhows the path relative to the repository root when you’re inside a git repo instead of the full filesystem path.[git_status]swaps Starship’s defaults for compact glyphs:⇡/⇣for ahead/behind your upstream,⇕for diverged, and+/!/?/$for staged, modified, untracked, and stashed changes respectively.[cmd_duration]only shows up when a command takes 2 seconds or longer (min_time = 2000), so quick commands don’t clutter the prompt with atook 12msyou don’t care about.[time]andright_formatpush the clock and command duration to the right side of the terminal, keeping the left side focused on “where am I / what’s my git status” instead of getting crowded with extra info.
The result
With this in place, the left side of the prompt stays clean — directory, git branch/status glyphs, and a colored arrow — while the right side quietly shows how long your last command took (if it was slow) and the current time. None of these glyphs require a Nerd Font, so it works in a stock terminal without any extra font installation.
References:
Linked list using JavaScript
A linked list is a linear data structure that includes a series of connected nodes. Here each node stores the data and the address of the next node.
Linked list methods:
- size() - Returns the number of nodes present in the linked list.
- clear() - Empties out the list.
- getLast() - Returns the last node of the linked list.
- getFirst() - Returns the first node of the linked list.
class ListNode {
constructor(data) {
this.data = data;
this.next = null;
}
}
class LinkedList {
constructor(head = null) {
this.head = head;
}
size() {
let count = 0;
let node = this.head;
while (node) {
count++;
node = node.next;
}
return count;
}
clear() {
this.head = null;
}
getLast() {
let lastNode = this.head;
if(lastNode) {
while (lastNode.next) {
lastNode = lastNode.next;
}
}
return lastNode;
}
getFirst() {
return this.head;
}
}
let node1 = new ListNode(2);
let node2 = new ListNode(5);
node1.next = node2;
let list = new LinkedList(node1);
list.head.data;
list.head.next.data;
list.size();
list.getFirst();
list.getLast();References:
Print fibonacci sequence using recursion
Steps:
The fibonnaci sequence is the integer sequence where the first
two terms are 0 and 1. After that, the next term is defined as
the sum of the previous two terms.
Hence the nth term is sum of n-1 term and n-2 term.
function fibonnaci(num) {
if (num < 2) {
return num;
} else {
return fibonnaci(num - 1) + fibonnaci(num - 2);
}
}
let arr = [];
for(let i = 0; i < 10; i++) {
arr.push(fibonnaci(i));
}
console.log(arr);References:
Implement Queue using JS
Steps: Queue has following methods
- Enqueue - Add element to the end of queue
- Dequeue - Remove element from the front of queue
- isEmpty - Check if queue is empty
- isFull - Check if queue is full
- Peek - Get the value from front of queue without removing it
class Queue {
constructor() {
this.items = {};
this.headIndex = 0;
this.tailIndex = 0;
}
enqueue(element) {
this.items[this.tailIndex] = element;
this.tailIndex++;
}
dequeue() {
let el = this.items[this.headIndex];
delete this.items[this.headIndex];
if (this.isEmpty()) {
this.headIndex = 0;
this.tailIndex = 0;
} else {
this.headIndex++;
}
return el;
}
peek() {
return this.items[this.headIndex];
}
isEmpty() {
return (this.tailIndex - this.headIndex === 0);
}
clear() {
this.items = {};
this.headIndex = 0;
this.tailIndex = 0;
}
}
let q = new Queue();
q.enqueue(20);
q.enqueue(4);
q.items;
q.dequeue();
q.items;
q.clear();
q.items;References:
Implement Stack using JS
Steps:
- Stack has methods add, remove, peek, size, clear
class Stack {
constructor() {
this.items = [];
}
add(element) {
this.items.push(element);
}
remove() {
if(this.items.length > 0) {
return this.items.pop();
}
}
peek() {
return this.items[this.items.length - 1];
}
size() {
return this.items.length;
}
clear() {
this.items = [];
}
}
let s = new Stack();
s.add(2);
s.add(3);
s.size();
s.items;
s.remove();
s.peek();
s.items;
s.clear();
s.items;